From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 574A839DBCD for ; Mon, 18 May 2026 22:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141762; cv=none; b=akeF3furclF2rLkcI5MriR6u7ME/AOmyznDwt2OfwCMY8Q8FaH54Aw+85bXN17mRbplt8L1LpApJDXlGTlbxzkuR/I11/QBaPWXHwoKxqgH+ezG7/EMLF583a3TOuaD45NNcKb3koioM7Ax1IxbrjN41pRs6Gm2Vxk0fR20tojs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141762; c=relaxed/simple; bh=+3gyUX7aaxHg4IEnt/cUPAS4EOyirl10zVxCVaQOWKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NhD7qHIxqtklpOzwr4vhH4kaYgJndtUHwiqlMX0WTW9yIJhVBsWgRzHx5dkh7pSubWT1wmWQx4kjResRIllEcYK7TzVhT0uTScZmyKGNgrD/wwrYUUPYykURbXdKIrHza9CSgVcUcWKRIEscOdFOJS7LzJz64mHZewSWGQ8+MNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DfUKKFCN; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DfUKKFCN" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-838d0b7c950so1964092b3a.3 for ; Mon, 18 May 2026 15:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141761; x=1779746561; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HRHhm0urB9xrof3Z10YFKkp6gED8PHSdFFw3oxkxeVY=; b=DfUKKFCNbsn63+wnTq/ZUkqu13WQUxWJIDG+mp5BN54sIwY8pK0qyqMt+F4VEFMdDU NducPBw8PzknezmbMgxRIcNYptrXhD50J92f60AAYZRBwwHLxwDJKKOoytULaC9g097j KTxeWuIIy3ZwEhdz78TLW5Fcd8zeoUj04u986AUPH60nY8Oy+ygLgUCP+OujkRAYCzGH 6B0br76JdeHD1x4Qsig+cBD5r0hDGL60VB/XacJJPNWbnerz6Buxcdh8IQQrSkOE+Yai EkkiuFziGYJ+g84Ho7SG5gsmNxaUJvhU9ckXcNsdDe7cpZZaFpGJFRMruTh+BAC3Xknb qnsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141761; x=1779746561; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HRHhm0urB9xrof3Z10YFKkp6gED8PHSdFFw3oxkxeVY=; b=mWAy2N40ciFyRqL8eIyyPqmcmyG4e8E0fnRCMTU45+h1BFllNizfeQxvPKJganpvUq L9HDizEb8kEGT6JEf+P9EGxYmd0D6nSz9TIg67/N1eyg5B46XAUWsXDTkQNs984gbdSU O1d3wriI2hYQ4Y3UmST5R45rCBKof8sKqGVFRMsi5Pwynqan5XCblTiBo4372ZjPZ8Aj OCdt4LISdAXnsGDoWj0p4fagMbAH2WeKEiVPfgQliyhTzzecKjWhQZykQG2budsGyedx BiltxaSLr89qCVl/kyD2I/KVazYnzYgLOnQY/1mfGWD72p40RuyMC71mmEZIobm04GKx wUrQ== X-Forwarded-Encrypted: i=1; AFNElJ/d8jhmiNlWM1ny0THUyFyoDU8yuQcs2n98/Cl5Wn3k0l5ceQz92LDvwb5wqGpm5Q2d7FhfFkpN4Sa5S+o=@vger.kernel.org X-Gm-Message-State: AOJu0YxP4Wk4qe9rGmv24H/khgc4XqWE7MD2pBJpyPYju4KTXIAOM11L XXl8ryXyD15Crpal7rZqNG6EhalI6N61a747UIBNbkYc2oFSDp5F4GwN X-Gm-Gg: Acq92OEHnAsz+O2UmXJaIHJET5PnUjmaH8BGZFJRQNK+uML8KSNuV6hWGZpNVKvzW48 aZSaUOEjJ8WW3DMUaXWv4MLpiKFKcl7G9cI4yG7PC2VzkS1KS1CSg6GFI6pBEK4a45RBNru+g56 DYaree/TT8XdtNCvpfMuMeGhCldQqTcI5AUTgqNpm9LatB2+ugokztCN1Syk79kDoCQFGlGOPkC P0bWL38hJORyGMos1nR7N4nIRSiFF/Iq5bivZU3k6tCKyvy9MLMHKVZERoqN3TDyyw/eMrD46cV rifCzfBShp6GwRipDx+/C0b+DC4iAjNJC+0fNF5ilXspVergAmu/E+9cp+IOiw8gP2khCCQ8Xfe 6DlY1z6pYpuWoYTeqfLei3X9hj25XXgh9o70R3N6Zh9ef655QzU2S0oQ6dqzc09lW3fvOylN+S4 wWTwLcZE1SFshhZkTnYejauN53s5OtTLLRKhzcjf5Z3HsK23Ybfr5Hrj6IQ3LQGc8N+/XCV3W6+ QQjlBIISU6uFj01to6DwEZvakj9lI3IoSbNUXXLD09clZXir4hQZTfE9f7J X-Received: by 2002:a05:6a00:414e:b0:82f:4a4d:377e with SMTP id d2e1a72fcca58-83f33d9d741mr17598050b3a.28.1779141760496; Mon, 18 May 2026 15:02:40 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:02:40 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Tue, 19 May 2026 03:32:17 +0530 Message-ID: <20260518220228.63322-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rewrite the binding description and property text so it describes the existing HX711 hardware behavior directly instead of documenting old driver implementation details. Also clarify that clock-frequency controls the SCK bit-bang timing. No functional change. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko Acked-by: Conor Dooley --- No change from v8. Already applied to iio.git testing branch. .../bindings/iio/adc/avia-hx711.yaml | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 9c57eb13f892..1ea60dff98d5 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -10,14 +10,9 @@ maintainers: - Andreas Klinger =20 description: | - Bit-banging driver using two GPIOs: - - sck-gpio gives a clock to the sensor with 24 cycles for data retrieval - and up to 3 cycles for selection of the input channel and gain for the - next measurement - - dout-gpio is the sensor data the sensor responds to the clock - - Specifications about the driver can be found at: - http://www.aviaic.com/ENProducts.aspx + The HX711 is a 24-bit ADC with selectable gain (32/64/128) and two + differential input channels. Channel A supports gain 64 and 128; + channel B supports gain 32. =20 properties: compatible: @@ -26,23 +21,23 @@ properties: =20 sck-gpios: description: - Definition of the GPIO for the clock (output). In the datasheet it is - named PD_SCK + GPIO for the clock output (PD_SCK in the datasheet). maxItems: 1 =20 dout-gpios: description: - Definition of the GPIO for the data-out sent by the sensor in - response to the clock (input). - See Documentation/devicetree/bindings/gpio/gpio.txt for information - on how to specify a consumer gpio. + GPIO for the data output from the sensor (DOUT in the datasheet). maxItems: 1 =20 avdd-supply: description: - Definition of the regulator used as analog supply + Analog supply voltage (AVDD). =20 clock-frequency: + description: + Controls the SCK bit-bang timing. The value is used to derive the + delay between SCK edges; keep the SCK high time below 60 us to + avoid triggering chip power-down mode. minimum: 20000 maximum: 2500000 default: 400000 --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0867739E177 for ; Mon, 18 May 2026 22:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141766; cv=none; b=mC2V6EvmNKfMWBnHSuIZ4wKOZz60YYwy5LsttWk7gkVSrg3sCSB8oKmqFV7voyd+h+15VF3/FpgKG2euXLZ3XoCalef2mz7dVDYr7a2ngAO+X05aZ/H2tyg+A/Gx5N9vjn8R0gs7Ql41MEez1FhAlphHonClRf/C9hmBx6NS4c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141766; c=relaxed/simple; bh=Z5CmtTG5nugdJKWxji3kQim9emZIMVZ3uEpEgfiinmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eAQQehRXPWDj5CMx1LclNd1UIlYBSztfZR7qURaUSxVssP+6iKYXeOTImwGFpT+OPeD9EHApTdmPFOwJbeDxJrNM3DW/g0Jfhn4pPYCptOABX2QTayh23P88iFTXOZrmS76H0X0GNvE7+9RsTrN4bJ1Dz1czlhlVfpSpKG970GQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ksiSqaxg; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ksiSqaxg" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-83537a80ab6so1916753b3a.1 for ; Mon, 18 May 2026 15:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141764; x=1779746564; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mr8yQH7e/wAhaKceJuwttlGCTuxK+V52TPcaq/q0rs8=; b=ksiSqaxghg2d8hnZJhdK0yRp8RKIDe+zjwuJVMDiAD3vRirFw6tjq5ovtQ8rTOiqAf aDSuRaU69yGOSOEXiAFX4s0yIKbo2/zb5JoRIgbVWbYEdz5CDBSPDH/z/IXA1WmNmdQT sr1NFOlIfLr8Ebs2SnF+CdCXLBbGRAdJInHHkOsTxkSQ465t7aakqtlHuzj0SeJ+cs+T 0cdYn5tyX54PGdeHIs8LbnMwroAQyyGiaCrJGi6sYQ6IAPgoiGmcO5Nnzw8p/TwoLMM7 FwOcdg0LoDEheFvpnV/jDn7ypKv6+f3xkBvlIXk1KRaBHudb7eMGYoaNYdE5o0A/o3o0 P9KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141764; x=1779746564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mr8yQH7e/wAhaKceJuwttlGCTuxK+V52TPcaq/q0rs8=; b=SYxn1xH9JzT4XtVZmv78gHPwdqGqRWnvt/xsb8blCHtqdmEZSPkfkA3JIu+ZArk0Ur HZPDyNUhTxUvRibqdxc26PEF9jdNGhSU+T72+02Lm/jGBOsKEU4x//Qf7piy2hC2kEq9 MznY6/5BKAIrFQRoUHPonQ9OlOeQIZos6jBCkTTf88Y/0mla09fOTPMprF0CRW0t59be kAnUoxxKdzZMWkX+KQRlYxskyzV2UH5Ylfszy/hHTnUD2XpuwdK2MKh1lts5odj9KFhF rahPvDzocqrei8OAoM5IaplkU4jb8VspA/oVWfXAJprG6mBVpHTQNz6Cc8+7j5nRfCj2 2y/Q== X-Forwarded-Encrypted: i=1; AFNElJ+TS3q2xRCFJUtgPs9uz7RB0szAmKZ9ItmS1gJrn2uIHUr0OOCF+OKjEJBH80PRR2uTWw0R1jsQ5EaN/50=@vger.kernel.org X-Gm-Message-State: AOJu0YzdQpOEHX7qIfd3pbzFSpRT2I2ac4EeGLvMkRui6+rY16/mEXXe krGOTvoR8QUdrxxRQu1sCI9qEa28Z50+so3ToO8Qn6iggwEs4hh1Ml6x X-Gm-Gg: Acq92OHE6P65idXxYRRT0StRtpcgtXPLRutCZaS+zPzn0kQPc/0JVYr5kjMszhT5U4b QrJxXQs2qhRhvdVYiebObG4oTakTpPB24oQ4yOEtcJe3q1FMF7oYHCZcDZKRnnfoEEsg173MYKY 07scQ2lu0ID8v7SLlHx2u8GEXoRQeL9yz1nyFyXThQHnyM9vSG+Gf0GRLPXrApWOG775YBNsaRW 1hCcNYA2ghBM1eUQMH7qWNDDBmXj8Brar3uVEdEHQDkDwudXrrmvooVHkP9J9YXW4OeZ8yJkWzI 6AK4Mt4apWozBoQwqhwCwgeeNSHZCXJFaj/z49mtW1/xSyb8gtSCIO30NRTlVoA8bUqyWxPa7Zi sxM2iLWLXzYlDPDPX/V9UrrsrcxmsEjSmiD9ci0nejpTVUg/wJHZgNldB03qt58IRcqtNPrqtMv xnRUzHwb54XH5lU881I2piQ+igSPojY1L/IadsdpuBPlIljiicWv6VN6TqqAnMpUBN+Ow/O58xE sycYDaHXF0nK8iCfeYRN5Kn2jHIaHASA81gL79CsfNJGUMoJ49p+0bi0om+aM8SBdkKDjQ= X-Received: by 2002:a05:6a00:3e22:b0:839:dd77:3501 with SMTP id d2e1a72fcca58-83f33c33546mr16660661b3a.1.1779141764388; Mon, 18 May 2026 15:02:44 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:02:43 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Tue, 19 May 2026 03:32:18 +0530 Message-ID: <20260518220228.63322-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the optional VSUP supply used by the HX711 on-chip regulator. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko Acked-by: Conor Dooley --- No change from v8. Already applied to iio.git testing branch. Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 1ea60dff98d5..a8eaa1f18de5 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -33,6 +33,10 @@ properties: description: Analog supply voltage (AVDD). =20 + vsup-supply: + description: + Supply voltage for the on-chip regulator (VSUP). + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D7B5399015 for ; Mon, 18 May 2026 22:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141771; cv=none; b=Fr/d2fK3bMDDpQTX+gWTbuVBGPY/dlRjS+tzuHOnzykO0yTKSZMdXZCjrAgpURp7I10xGa6cRtcHWEQs44rDpQJLW9lc8wFDXSG2xotkrxfa5tURqm6vf11oqoVp2dDzV3oeqZ9Ug82BrgdCioFAPH9HdadHXdgFR4PU0YYmjSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141771; c=relaxed/simple; bh=iOpsr7xBX7iZc/Y56TCDEse6CoQ7xoJPWO4TydbAp14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D7xmTOWcNAInhxdDgdzp+9w/mjoghxl5s/ss36YnqzjHtlY6C5YqIjT4sap7pBiBgTaW5qOu01mcndMSvuORJ7Gb5LTkdj2KAICIzaaUpfkHtP5B04/Btc2RnM4yauNR3s7llWq6sC1UUQ997OpYXtPsgV2Y7kM2lsBJCs8wEgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fJ9jwT1V; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fJ9jwT1V" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-836ebdeb969so1238460b3a.3 for ; Mon, 18 May 2026 15:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141770; x=1779746570; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wkqgpIclOI6u8+yfVZQ8lp/GgYb/zGUhAdnG940poqU=; b=fJ9jwT1VB+L2OHlUSP2Fd0qpob3QBM/vTE2FpoVMDdeu5GDvM1LoEMzMi6UVSn5ca/ 722oVlm2RdxWXf/mxVP0pYFlL8ee/WUqhu924s4R1o16KgAnIlu85qIXE6N1UD1yPxU0 dgAR+xXO99HzjoMKOxXWBIYgQmuxi+V2oez9EECfPKiyRUL1QQ5SNc3bIyfLFG5oLxr/ d68D2Bo721htJlQ9wE43qAmBdcjNXiONuUzJeNpNoedoQyl5mgH7p2dOismLrG//uMSq zLErwfIoI89Zy/pqqsHEGp0zQ9Z1gwed1q00sykvkb8SPCzeqxk2CkLE1HA+aZWu9Q7i V2fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141770; x=1779746570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wkqgpIclOI6u8+yfVZQ8lp/GgYb/zGUhAdnG940poqU=; b=Me/R/IE1TzaMHqPOuaQJkyUU8YVHu5oU/RTmdyJxwqrJ+sqnWGzBYFowtcpRtJFAdC BfxK5JpY4elrml3pTXN0nGi0mYUTmpsPdapqsAxe5nNYSX1XDDv+SRkxFjy/+T5G92ar mF/DKTuKjaRzBlaAx5gqKFK9EJVAVrUwATeRweRjc6YnnsfxmtNKOXqisX97RW0DKcod 5Lm/laIKTo9i353MSdcpaLi133fa872mm/2nFmsTKDoffDrLKyuarku9s/L697eQ+EX8 dqrFRbfcnvNFbnP1Z66Y7ZfjHfW89n7q15/OsV43Da+U28y3mK+oYpRKIKqEUA3KBsvf 93MA== X-Forwarded-Encrypted: i=1; AFNElJ8iqFq/yjGd1jTSXFuZNImSba5YwdJaduL2dvCnMcHhZVSB4xVbAEyjEMWlwca2H/FYJbThYerhBGv+mu4=@vger.kernel.org X-Gm-Message-State: AOJu0YxhWa2wadflUtsScX95Iyus8wKG/tuJDCw7Ear2XlhYLQfPUOqi ApCOoPRm1nQ3oqMejjvnATmh/hPPYYd+5/OknfYTE0U01YgWeT1mfna/ X-Gm-Gg: Acq92OFqcfaXB2A3ERZt6nM347U2Z1Ge4ZLhXHehQ0Bbs/hQMbt/FpfFFBB2KWlScrf DYcI53dFG/ggd5Zwff/+yurbmXLrnXetgUS7/5PkMqeW/8w/jl5WTsY4FWEUO3+hb+p5YDmGdY+ QqaHAOZCQu52U08TEK1qJRlhY7qFw4dPiVml62wf/IoSznWamPlC72/G/nu2ozI5UZVqo9+duME IMPw7qRSSSuJhgTjpc+M97ULdZvNrcg5V7OytU732kDYbVZnae3wbYkonSVxfHmAIAQtpg82BvL tJWb4MQCMZ8L1NgZb5K5QJTec5GXUgfwdc6soOulzR9vTUjKUUcCrqqlPiQ0o5dw2uiuSNuLRFA X7C6/cjSuYY2S2Ca06AL8AWhoie3jc/PF7I7OF/VaQDCgGr7U4FNOllTs10Z5N82Q8grc+fXgaQ 89a66hQRMlQ5VhiW88KcVV2QMxawJmTz/juqtA7v845uS+XLOpVc6DokuKG/95aCyUyAwF2vgdT VQDZZ8uRtZgx7+j1Y1u4QFAzgApPN5iyBa1kP60sIy7wZo+W7sG652BaW4BjbqC34N7YXs= X-Received: by 2002:a05:6a00:2295:b0:82f:832a:75cd with SMTP id d2e1a72fcca58-83f33d547ccmr17483191b3a.39.1779141769584; Mon, 18 May 2026 15:02:49 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:02:47 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Tue, 19 May 2026 03:32:19 +0530 Message-ID: <20260518220228.63322-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the optional RATE pin GPIO used to select the HX711 output data rate. Update the example to show the property in use. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko Acked-by: Conor Dooley --- No change from v8. Already applied to iio.git testing branch. Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index a8eaa1f18de5..9134bbe41379 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -37,6 +37,13 @@ properties: description: Supply voltage for the on-chip regulator (VSUP). =20 + rate-gpios: + description: + GPIO connected to the RATE pin. When driven low the output data + rate is 10 SPS; when driven high it is 80 SPS. If omitted the + RATE pin state is determined by the board wiring. + maxItems: 1 + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the @@ -61,6 +68,7 @@ examples: compatible =3D "avia,hx711"; sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + rate-gpios =3D <&gpio0 9 GPIO_ACTIVE_HIGH>; avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6476639E16B for ; Mon, 18 May 2026 22:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141775; cv=none; b=ifVN/knan6Co02NaNGDqCpOj8XA5xjmxPvU//uenWUTsDQ+gMhpF2O3jJMocbhhg3KBAC+MB0U5mhDc9T4AekDcKrFGu+l7WM22vwGdyDTZzTCj3BDg0rE18+RTVa/WlLZgaBUWyG5HM5Hbxtv3eHuxTLhOMgaE2lDBTrYNIqsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141775; c=relaxed/simple; bh=58hXK3+jjxdURzdM62kYNdhGnylmydkjDZ6DhB7yRAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ceXodY5Kp3Sg+6yip6UqYoGfTk008AKzDGDkNyRI7RmdODc4kJ1D7b8h5EhqmAmEZlG18f1BCW+JmB1x5Jq6BJFnFurryu2W1ogXFhP6huS6E8bsiwEwKMq2fgM7cIbomc0CgaWH239FgR7A4zNrCWJYfjeU80b0kvBkTweyBzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=sxX/gfG0; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sxX/gfG0" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8353ca0f1f1so1221120b3a.1 for ; Mon, 18 May 2026 15:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141774; x=1779746574; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MZ3L7gIVtDuWxh9a4b/o7Up/IHdND0VWYFyTOBzXy1Q=; b=sxX/gfG0UoxLsEk/xjAuUpaTiWBqzm/ajeS08EpqCK1mXtqtV45s2C8xd92M7TlEij HMErpGKYd5+YGfGCLU0fdbAJzCil9heEPubQqASmpZ18srp1H2HBJlMqbdAN+sa23eUX gZ8JG+hV5ve0nz63Mu3+lzYtorDd4rt2pDLe5WqyrQKEqgV7FIWkXzi1mviXgn+yxBRD 0nWTitswxb1/RDPycnsOevI4UBMlY9F15VW7pypya68OeglDcTl2DV0idxymhmnzYWgM MnDDS/fzPd+FGevLXGBs9waUP9VAPSPHfPIBMSNolGY39CHcSniijOdgVPctm9oeeWTf YIwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141774; x=1779746574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MZ3L7gIVtDuWxh9a4b/o7Up/IHdND0VWYFyTOBzXy1Q=; b=WznXxcgSLdo1JT4tz5SZnovaitb9M3Y8jMdu0wJWCKwzQGDXXIk8FAMmO770OZVB/Q e2zV2LoOxjD81vkqXKLVoaY2FNi8OcYwnHHJwqZFwB2J1SWlu9wfCqBIcN4u65aXpsFK mIaBlXd/Aqh/tidY9iGQmztdX4wmBNgpfBXTLRMPWDibcEvimnqzsBD+0t2hbap0TvzH ps4tzqN51JSlKza2G/dLFiEZhsBipwvvl2B0zcvhqzRHRUaVroD3K0V18GDE3rPEh+Yh Jp629Yx9yBTlccWGr/mTg7+C1eSvygK+6k0PytohRLfxKe9ia7El/YMFXdOu1FNk/ze5 SwDA== X-Forwarded-Encrypted: i=1; AFNElJ+j7TJpMw8m18Iekv0I4lDdMn65FEuig7EGJm1IAA1DdPDH/eIoEeGoAkEaMcd2pM/d8EKiEiTTEbW32QM=@vger.kernel.org X-Gm-Message-State: AOJu0YyLABxGjkxBPPsnqy8h5Fy+jVuP13lkSmEigSKu5/5Gx+ma7lT7 9aBakQmkLmK4/TwHdHDmeLG/5yq1Vk/g44kgFNqFLi1TkuLA3qNwPWEN X-Gm-Gg: Acq92OG3Rzic+0aPvc6yqW8y0hdO5EgZ5N+nATG9arVUy3vD9zxW2aDxwR/5hk0SrN7 pJPah78hfevIa3PEJ6CMKUNF5Q0v4EmaU7cVHFAjcUcIx/UOHByAN+obtE3UarD2B5wZPnUarKw 7OhCgDemUkVHK4fzXRhOnqJbs53BD45JOvLnoZQcU+D1sAPtPDNxAvFjz3xy1hO7Klts9kWgBjV xEPenWZ/dwycwFUoxSEHYExGCvUibe9pGxXPlrqKZGFpMLZxTtT75/7CNZNwt44ohnz/jQYtf+q UmqpaxjkKzKa1bWClyvuZ2LCjAuPTktP3Wu+0Wdz59OgQMF31yuMaEuVXUvH8GNQvcFxCTyYUMg esdkX8e7XkapTHA1QJBneJ64PJJhfvlf6aU5MXq2IuvXlnWiz52TzzYySZ7kOFuSA6uF9VIssV7 Jqj8fj4DfzocBqr8H9S8UuAEXum4sCPMwcusoEgYwXP4LQ7v49DdnqPETbFr3veOVnRVDQ1jASm BT+TQHopiTvpN/0q+i/t/wXUL1GMNNONe2z2vhdA63r8AKh6r7ozfirk6zI X-Received: by 2002:a05:6a00:14c4:b0:82a:146d:36a3 with SMTP id d2e1a72fcca58-83f33c9570fmr13371904b3a.21.1779141773709; Mon, 18 May 2026 15:02:53 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:02:53 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Tue, 19 May 2026 03:32:20 +0530 Message-ID: <20260518220228.63322-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the avia,hx710b compatible and document the HX710B-specific DVDD and VREF supplies. Add constraints that forbid HX711-only properties on HX710B nodes and require vref-supply for HX710B, then add a separate HX710B example. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko Acked-by: Conor Dooley --- Changes from v8: - Dropped the trailing sentence "Keep the existing HX711-only binding extensions in earlier patches so this change is limited to the new variant." from the commit message. The earlier patches in this series extend the shared top-level binding (VSUP, RATE GPIO, etc.) which are valid for both chips; there are no HX711-only binding extensions kept separate from this patch. .../bindings/iio/adc/avia-hx711.yaml | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 9134bbe41379..b2b5c7bdf05e 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/adc/avia-hx711.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: AVIA HX711 ADC chip for weight cells +title: AVIA HX711 and HX710B ADCs =20 maintainers: - Andreas Klinger @@ -14,9 +14,14 @@ description: | differential input channels. Channel A supports gain 64 and 128; channel B supports gain 32. =20 + The HX710B is a 24-bit ADC with fixed gain of 128. One input measures + the differential voltage between the two input pins; a second measures + the DVDD-AVDD supply voltage difference for battery level detection. + properties: compatible: enum: + - avia,hx710b - avia,hx711 =20 sck-gpios: @@ -44,6 +49,17 @@ properties: RATE pin state is determined by the board wiring. maxItems: 1 =20 + dvdd-supply: + description: + Digital supply voltage (DVDD). For the HX710B, DVDD must be + greater than or equal to AVDD. When DVDD is a battery rail and + AVDD is a regulated supply, one channel monitors the DVDD-AVDD + difference for battery level detection. + + vref-supply: + description: + Reference voltage input (VREF). + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the @@ -53,6 +69,21 @@ properties: maximum: 2500000 default: 400000 =20 +allOf: + - if: + properties: + compatible: + const: avia,hx710b + then: + properties: + vsup-supply: false + rate-gpios: false + required: + - vref-supply + else: + properties: + vref-supply: false + required: - compatible - sck-gpios @@ -72,3 +103,12 @@ examples: avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; + - | + #include + weight { + compatible =3D "avia,hx710b"; + sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; + dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + avdd-supply =3D <&avdd>; + vref-supply =3D <&vref>; + }; --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C72A381AFA for ; Mon, 18 May 2026 22:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141781; cv=none; b=p+7tpZtOn/UJ50uhU0bFWfgbvlHjlY/5zH6aj70sIrHaJd2AMuUJhcFloN5gcQ1cMPwKJ4ksR4K8/Ru8HsptJQKK0N1FDhtG75cVMFOGKGE4q8mUSFbvveqwbXbkj5+2X28Dv9bgKSKek8avSLBmE8rZhgkrEvhxwRbOA+OBj18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141781; c=relaxed/simple; bh=YIgzdEh/qr3hlX5d3x7wEDgkdp098G1nkKAjjuV5Y7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SwsIod0KDZ61Y2l9k5G2DXDMYBIwFDUpbFxg+KQX1xfQBleCSDDxCsAgPdJ9UVvlAqWiWlCebjojG3J2ap/2BqfcZ3tgHuOGPQlepvByGTnDWUpHOTEOsyENg6IGKNzu6Qpmav7qNRvbbvYR1/q9sADFd4A74LvtcHoZW+j0LVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uzmnk/Mb; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uzmnk/Mb" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-837b39eb078so1910621b3a.2 for ; Mon, 18 May 2026 15:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141778; x=1779746578; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bvK2VJD8fl/Rjr0aAvzpby1wY4IjpgTnX0YvfLJpkFQ=; b=Uzmnk/MbTBsVOb9lDVD5zubjipoeduNTWfuI6vYvMENntdWqcHbhR3rqCMjyDO7m5n auY7hJNcvxvxnyypYDEZArlZVan4aEpI3wx0aueuGx/RG6n39LMWEaTJ0X8QnoeXRo6C AZ7zRVHkIa8XnF1GdcgZMGTXJfOgmByPIk8jpcI0YyLDdMpmbwViwD9KOGOxGcKHjr0V RbvvMwuHwV7OLK24jO09udZncwfSx6lDRcAclXB8dveVz+OXv7fpWZdElpnyhix1q35e uIQk7qpZS67XjpagzhH1/a4DN92RjAdIQGvyuGI2vidSowntKFPvc+WnKOjTmuHJnmrN 2DXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141778; x=1779746578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bvK2VJD8fl/Rjr0aAvzpby1wY4IjpgTnX0YvfLJpkFQ=; b=YXZbToQtCOZ8CnRWIaefze8c8vu3CX+PKKjemS6cY54KjbOuTpW268N6mueF8FdDhw 4c4JaPQ691aEQyjbGMFFBdPue66URJeX0YPltf/6BXf51yJ/cASc+oz3iI9rx7/zN/wc p9nuWBBbd4cFnAD0naBJ6lOK1Spe+RHm/B6i3/2BiaCiiPZqE25sPOsZO2z04utKSudu tSxESwcZzSBC9afke045WcTvifypiQ3FFu+YGm+zKRqOm4+Pj8ukmzQMO6Ol59w2CFeR BudzBx7ddpDMb8REG5kAwKdkQKHQjhiq0TjHvySsrXeK/5oacn6i2XzQSljajJl/N8nU FMfw== X-Forwarded-Encrypted: i=1; AFNElJ8CITan3WiW3Cm2aICtJckJf/SkCqvUjG2iGhtY3vFd4Mc56o7w2MwI92Ca3aC4sR1qOXdk78oU820IWu0=@vger.kernel.org X-Gm-Message-State: AOJu0YwJQkhXbEcdby1T0G3Z1Kfsolv44vAxrhcGLAiE2fJghLuFAcqX 6WoavBvpQxGQhCfXKjDsPZDtVD2YrLksBda01vGWSDugmuQ1vzU/PTUO X-Gm-Gg: Acq92OHvr/dcf//mWzzMKG3DnRICQlBBwZsOZ3Kw3kgM2/a1XDk/cSFyiM7c9MFOpYJ tXrrqPUwk+Mr2SMp5ZBAQGe+GHtsoVZGZUUMzOk2N7FvXagPt+eUt2aE773HOOLgZDqMz4M7MMu 7bhGctdKoyJxxoy/OLhoQQWTl6BzFT8UXj1+Mr9vzuPIU3K50p+PO0/Zw/kc2LL+AENHhBOmjei MpHBPS5EeW9SVmmi+FaGXKHYSKvosAa4rZWwi22vEbqGC3CFwJiBSxzoo/j3+7e7PjLFx0HQHkh JZ7BYIvYXFeoAudgi/gaXQUFuS7zDXdqg4XYKJXKbQ/SNur0siT3pV6gG21E92XGRaGzgKgNzRT kLCOf1vkrSiI9RZnKYldXu2Ravz/ylJq5J2PLfd2mXdFdIqPzLJgB0aOiIgQSD9LUFJNjABPzz7 WlfSaMuxPjya/s17vO2Fy9HRTSZPU9vpIJy5dDPR7+BEjrwdWfCLgO+cSE1pPy9TOvvVKFrNkPK LsEi9J15XRQr26BfSBqgKnnz4UkhfCtritmJ3evLvskdR3bDoGayKGNm6h9kEwnlY7TK68= X-Received: by 2002:a05:6a00:2d19:b0:82f:a89e:e16f with SMTP id d2e1a72fcca58-83f33b2f58fmr17303350b3a.14.1779141777904; Mon, 18 May 2026 15:02:57 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:02:57 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Tue, 19 May 2026 03:32:21 +0530 Message-ID: <20260518220228.63322-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The gain-to-scale table is global today, so probe-time scale updates for one device overwrite the values used by any earlier device instance. Fix this by making the gain table const and storing the computed scale values per device in hx711_data. No functional change for single-sensor configurations. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No change from v8. Already applied to iio.git testing branch. drivers/iio/adc/hx711.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 1db8b68a8f64..86d2a70dd3de 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -28,22 +28,20 @@ struct hx711_gain_to_scale { int gain; int gain_pulse; - int scale; int channel; }; =20 /* * .scale depends on AVDD which in turn is known as soon as the regulator - * is available - * therefore we set .scale in hx711_probe() + * is available; it is stored per device in hx711_data.gain_scale[] * * channel A in documentation is channel 0 in source code * channel B in documentation is channel 1 in source code */ -static struct hx711_gain_to_scale hx711_gain_to_scale[HX711_GAIN_MAX] =3D { - { 128, 1, 0, 0 }, - { 32, 2, 0, 1 }, - { 64, 3, 0, 0 } +static const struct hx711_gain_to_scale hx711_gain_to_scale[HX711_GAIN_MAX= ] =3D { + { 128, 1, 0 }, + { 32, 2, 1 }, + { 64, 3, 0 }, }; =20 static int hx711_get_gain_to_pulse(int gain) @@ -56,22 +54,22 @@ static int hx711_get_gain_to_pulse(int gain) return 1; } =20 -static int hx711_get_gain_to_scale(int gain) +static int hx711_get_gain_to_scale(const int *gain_scale, int gain) { int i; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) if (hx711_gain_to_scale[i].gain =3D=3D gain) - return hx711_gain_to_scale[i].scale; + return gain_scale[i]; return 0; } =20 -static int hx711_get_scale_to_gain(int scale) +static int hx711_get_scale_to_gain(const int *gain_scale, int scale) { int i; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) - if (hx711_gain_to_scale[i].scale =3D=3D scale) + if (gain_scale[i] =3D=3D scale) return hx711_gain_to_scale[i].gain; return -EINVAL; } @@ -82,6 +80,7 @@ struct hx711_data { struct gpio_desc *gpiod_dout; int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ + int gain_scale[HX711_GAIN_MAX]; struct mutex lock; /* * triggered buffer @@ -290,7 +289,8 @@ static int hx711_read_raw(struct iio_dev *indio_dev, *val =3D 0; mutex_lock(&hx711_data->lock); =20 - *val2 =3D hx711_get_gain_to_scale(hx711_data->gain_set); + *val2 =3D hx711_get_gain_to_scale(hx711_data->gain_scale, + hx711_data->gain_set); =20 mutex_unlock(&hx711_data->lock); =20 @@ -321,7 +321,7 @@ static int hx711_write_raw(struct iio_dev *indio_dev, =20 mutex_lock(&hx711_data->lock); =20 - gain =3D hx711_get_scale_to_gain(val2); + gain =3D hx711_get_scale_to_gain(hx711_data->gain_scale, val2); if (gain < 0) { mutex_unlock(&hx711_data->lock); return gain; @@ -386,6 +386,7 @@ static ssize_t hx711_scale_available_show(struct device= *dev, struct device_attribute *attr, char *buf) { + struct hx711_data *hx711_data =3D iio_priv(dev_to_iio_dev(dev)); struct iio_dev_attr *iio_attr =3D to_iio_dev_attr(attr); int channel =3D iio_attr->address; int i, len =3D 0; @@ -393,7 +394,7 @@ static ssize_t hx711_scale_available_show(struct device= *dev, for (i =3D 0; i < HX711_GAIN_MAX; i++) if (hx711_gain_to_scale[i].channel =3D=3D channel) len +=3D sprintf(buf + len, "0.%09d ", - hx711_gain_to_scale[i].scale); + hx711_data->gain_scale[i]); =20 len +=3D sprintf(buf + len, "\n"); =20 @@ -511,7 +512,7 @@ static int hx711_probe(struct platform_device *pdev) ret *=3D 100; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) - hx711_gain_to_scale[i].scale =3D + hx711_data->gain_scale[i] =3D ret / hx711_gain_to_scale[i].gain / 1678; =20 hx711_data->gain_set =3D 128; --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998EF39EF2C for ; Mon, 18 May 2026 22:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141784; cv=none; b=ogYcyXW7DTmwJPOoJpiZ/Ptapzu15nYiiJliOxk3yl9VlmIKDp3JbtKXVJ0+IR0nfocbbTLodsqEeV+7zG16PtF5oUI7mclOVG3YqLrk71uEpsjGdRv+L4ck2C9hbyBWW72DREaNnfNlXMf6xZdwnnFBUo2EczqfBCmOAuvsmw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141784; c=relaxed/simple; bh=/PNDd1zkwk3hDyvDb6EEtW8rYpRWUoc8QUNLfK9WR8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TZPX5eSsvc6EPhnVuZFfoJaFiq+lTljhL0Em+S1nG/Buq78s6XjgxbspC/GvlqxSIBo/ty+Uun+FvITe9DJNrElOikx3TAiKsVIbfV+o/FSl0pzx1jflEXfwDIAFoc6rj67sirsbrEwQ1eGx2pn9vGMKNqJ9NaJgVbmOHZnKtes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RzxP95nd; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RzxP95nd" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82f8b60e54dso2371570b3a.2 for ; Mon, 18 May 2026 15:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141782; x=1779746582; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5fjhdCnbV8ukBtWzUYd6fHgql0XE/IRGNUdKMo9fQMM=; b=RzxP95ndTU2X/JgovZNgeCxSc/6gRqDr4+Z+lK5iGYAM+gAN2FWx6qUPW/Ab/xB7OE L/BAfu+pWC4h1yG5NGsN0S9HkvGdeSUfw0wDTFTWHTLzj6iXdGOxZw5otatAnz1muHdr 87lPENNBXNu+ck9eKya+V6VuTGQujiKtr7EOM+b4nqsNWyRvc7sE5FqlXZnIFc24d9SR sqtCk8yL6N5IIIP6dR1Qn/sbU+Z9XGF7dEoH3xts3CXm720R1FDqcoH1GkTM+9rpejqB 14MpxWhqUQN0zlRpusbazDOrWq/I7rKC45hv8uh/Vul0gxd8UMaQYYZfU2cVA4M9xbB1 CGCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141782; x=1779746582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5fjhdCnbV8ukBtWzUYd6fHgql0XE/IRGNUdKMo9fQMM=; b=RBdUCjxeV/tOIIDsDwKctujSMPcd2w7Hc3Ty+prg0Hw1oiqGM6733V4GO2f3swQwI8 4A98HECjBWtOrZWWfnurYH8+ATDkfLf58jXhyrNbyLOM85lEUYlMCbur3fjt/Pys86b6 eEI9cE5Nc30OTfOWekLYvBNxWvIxeK6Me47NR2MP3Pkrg7lT8nF9pfbIeuQs3YTQC/8h evIQ0TcDTAJzNKAf/GNZvPxeJ4UyfpyJ4hvrKT4riBM8KPNt7KgSPf4D8/5j1pwY2hat /lv9uej738z42WgwRDhRQ6VOe8OuASm4k0/+hdSZ22JiSq36smFgZ4jl/rHKnHHxttLx WgNw== X-Forwarded-Encrypted: i=1; AFNElJ9s2e3EtZKxFk+Ey1gjNigO/N/umlkzB+eIo0O63/Wzdw6lGu7Gx/+kygi9ARszqutpP2HW+gDtNxl60yk=@vger.kernel.org X-Gm-Message-State: AOJu0YxTmqjHajCKis9by0gdLKWmHAmXD3HKQQgBggp9HVdbvqtDzhDU 5zLjlJXmB09p+BF81Pz95/0UkmGM6UvwRBAmnA644b85fRUdkdk5l4kd X-Gm-Gg: Acq92OEchd+Y3rJdoYx/AqEPxDBGj1JkPMD4Mz1c6z8COZ18b5w1PY7I3VmeUF1VkRu ej3wVemow8v8WKAWo1TUm31Xi1yKUQsUlwACSz5lwxCgGA3HL9vJDGT1HbeaO/ksuwUH7ORxnAi u81lWGSR3hWw/jT15Ed2fmMkqySQ3iG0seVZCCwY/J331FdihQtNOMhQxeCt7SXzkvYauyQUHIJ K5IXtUoDCJhsNqr4TmHESLtauL322Uw4NcyErMSySOW/31YqPisli+CLy8DgKMDcPpzAz1wk8KA cgqQdbokHKjdaGibhNcmTDMq6AsbB3n71YTLFLS3dwYIGp6wXhEmoctZAvsn7hFxU4UfGn/RnwA HYVHSlDWSaO7ZxQyb6B05D9frZUwersC5hVoZLcIVecr0ni9fDNfstuho07aJ7V9+T2QT/BeAWf q6DV//NQCqE2EbKDS0teRzhTPUi8e6Vi/IeVcOBa2NxK/gGgKqjUkDsdJojrFcR6dUzMVKSQ6p3 BqSAECDeHsmVtlzLdi1rfRpKplGvnMINpWkiNcJLbW6HE3eZlTcvsPqOzvY X-Received: by 2002:a05:6a00:4fc8:b0:81f:5037:a317 with SMTP id d2e1a72fcca58-83f33c957bcmr17839336b3a.11.1779141781908; Mon, 18 May 2026 15:03:01 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:01 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Tue, 19 May 2026 03:32:22 +0530 Message-ID: <20260518220228.63322-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a per-variant static configuration structure and populate the IIO device fields from it at probe time. This is a preparatory change for adding support for more HX711-compatible hardware variants without duplicating the probe-time setup. No functional change for existing HX711 users. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No code change from v8. Regarding the __counted_by_ptr() annotation on hx711_chip_info.channels: this annotation was introduced in include/linux/compiler_types.h in commit 4b8a2e8e09be ("compiler_types.h: Add __counted_by_ptr()") which landed in 6.12-rc1. This tree is 6.17, so the macro is well-defined. Jonathan Cameron requested this annotation in his v7 review; Sashiko's v8 bot flag was a false positive. Regarding the legacy platform_device probe path: the concern that probe could succeed without chip_info (returning a useless device) was acknowledged. Jonathan has indicated the current device_get_match_data() guard is acceptable, so no change was made. drivers/iio/adc/hx711.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 86d2a70dd3de..10ccc69f209b 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -4,6 +4,8 @@ * * Copyright (c) 2016 Andreas Klinger */ +#include +#include #include #include #include @@ -74,6 +76,20 @@ static int hx711_get_scale_to_gain(const int *gain_scale= , int scale) return -EINVAL; } =20 +/** + * struct hx711_chip_info - per-variant static configuration + * @name: IIO device name + * @channels: channel specification array + * @num_channels: number of entries in @channels + * @iio_info: IIO info ops for this variant + */ +struct hx711_chip_info { + const char *name; + const struct iio_chan_spec *channels __counted_by_ptr(num_channels); + unsigned int num_channels; + const struct iio_info *iio_info; +}; + struct hx711_data { struct device *dev; struct gpio_desc *gpiod_pd_sck; @@ -81,6 +97,7 @@ struct hx711_data { int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ int gain_scale[HX711_GAIN_MAX]; + const struct hx711_chip_info *chip_info; struct mutex lock; /* * triggered buffer @@ -456,8 +473,16 @@ static const struct iio_chan_spec hx711_chan_spec[] = =3D { IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 +static const struct hx711_chip_info hx711_chip =3D { + .name =3D "hx711", + .channels =3D hx711_chan_spec, + .iio_info =3D &hx711_iio_info, + .num_channels =3D ARRAY_SIZE(hx711_chan_spec), +}; + static int hx711_probe(struct platform_device *pdev) { + const struct hx711_chip_info *chip_info; struct device *dev =3D &pdev->dev; struct hx711_data *hx711_data; struct iio_dev *indio_dev; @@ -473,6 +498,12 @@ static int hx711_probe(struct platform_device *pdev) =20 mutex_init(&hx711_data->lock); =20 + chip_info =3D device_get_match_data(dev); + if (!chip_info) + return dev_err_probe(dev, -ENODEV, "missing driver data\n"); + + hx711_data->chip_info =3D chip_info; + /* * PD_SCK stands for power down and serial clock input of HX711 * in the driver it is an output @@ -534,11 +565,11 @@ static int hx711_probe(struct platform_device *pdev) hx711_data->data_ready_delay_ns =3D 1000000000 / hx711_data->clock_frequency; =20 - indio_dev->name =3D "hx711"; - indio_dev->info =3D &hx711_iio_info; + indio_dev->name =3D chip_info->name; + indio_dev->info =3D chip_info->iio_info; indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels =3D hx711_chan_spec; - indio_dev->num_channels =3D ARRAY_SIZE(hx711_chan_spec); + indio_dev->channels =3D chip_info->channels; + indio_dev->num_channels =3D chip_info->num_channels; =20 ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, iio_pollfunc_store_time, @@ -555,7 +586,7 @@ static int hx711_probe(struct platform_device *pdev) } =20 static const struct of_device_id of_hx711_match[] =3D { - { .compatible =3D "avia,hx711", }, + { .compatible =3D "avia,hx711", .data =3D &hx711_chip }, { } }; =20 --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BA73A0B1D for ; Mon, 18 May 2026 22:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141788; cv=none; b=C6elu0VEoQrXsy1YN/m5U4GZ+gxPqcS0DHVO3jWAQ/r9iwB5Z/21azBz13RxZIwa14frnW+rxwyqPLLE0xFpRPTsFLWKHt1Pcbi3q6/BFe3qiLoN4QD1zIW3fRhC6ARCiUls16dP2MPmgJL+u15yhLzDHGKxJp5iQTGRifczvo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141788; c=relaxed/simple; bh=LSkPnfPS7dcFx2Ts93fh7yYVwcsinXFO6Unbb7I42hk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H33qI9xEcFp7vlH7d7a1bD+skzEKCFEU33eBnB5AAGGZKiwB0r0OMXmWIEnKIPLR4PaB1SZj1P1fYTjK39AkpDhYClBzRnjmoyU/w5KlZA6ojU510ooDYTBFl6JbLziCt7zmHyCrihjDYM2uUig1GKdZ9PD2GWyrtC48YoauosA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cjTnV4E1; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cjTnV4E1" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-8353ca0f1f1so1221174b3a.1 for ; Mon, 18 May 2026 15:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141786; x=1779746586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Y4Byz56kRE8Cxdx3gujtJfcSGY+V3XNAqSrgerlsus=; b=cjTnV4E1FN94UzbG+w/64LLNGLfXWozksBIEsF5e0eHzwVpuCPSHm1qSndQcoS7SJX m4PBiwqcj+N2b7A1HjzUYNKJvIZDfo6ZENg930fLAZ5OqMOZ4mqC88YkDQyOSnFo5JSg J9rwW431ZqwJ2cKTxA4EUoy8QCnvw4K+XDuGNLsk3h17Lfx2RFmxn3RDPmjuqZusPhYM r8bEo+bM1WW25pm0sht0hKGCADBwaL6Qg71XRi2x4aTjjpQphdcGU8cOCpIKEc4OKFs2 10/2GOSDYX/Qm+FAmBylg+WKgVn9FgTMxBzPAx8XRCticFfPgThkxEUQr5/XUEx6Td6I 5wyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141786; x=1779746586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8Y4Byz56kRE8Cxdx3gujtJfcSGY+V3XNAqSrgerlsus=; b=SOgGoEEqgZUYtEbbDrNgYqg/i8YfBiHQDMILSAlfvcqI7rCC/Gss6BOnXbePJ5n4zn SV027GWjF6sByqp+XCHDoZCya/AArystx3X+YZ84yFUkQFr3Q6esP/HWQAMIFH7eFHAg DVLqEyw9K2VjmCK0NKmcV78fQjJU/puwURFydbX504pOtIHFmM2/Krz0GlyhvmckNTEQ s/JqluyhwazzaWl/gtk1IZFr0aveCxkATdbuFO2L07+agK7kLt7XyjwUJN/KZujYFzce HT3Iyc4Y4GsyfWd/2vcImimvOLKf9d5lkVLQmgN1Md58FFjuxuVyxL7WmSbHD1kD5z8A gmbw== X-Forwarded-Encrypted: i=1; AFNElJ83SpODIqcNVm+iMLNBDnZz3ZyVpGa7XWH5+VrsKz/yPumviZ6xAhLx7rlU3M2S4VG0LdSedRqmser53ro=@vger.kernel.org X-Gm-Message-State: AOJu0YxAgfvKY0iDk76EAhucGg9E3cVr9maQtB5pyOcxVazEPsxCZ2wi hjKnV2crjgH36wPCaXsT3DKLTKLN+AbTMJZz8c4UH/zWV9DU5y8feA/Z X-Gm-Gg: Acq92OEEiyDsNyfAx8q299An4epCZeBXzP49ifrwuWXiVSTKhGLoeH9zas6r4qqVrFP 5qVMsO8Zv76zYP0kwN7o/08J3BOP+lelfZZRPMTs/lwjk3xiJhz6KjZJ2DTlJA+9KwhDBNemMJ/ 30jV7PQPqrBqieDyckvO1q+O96mAlFyFtG24SpN1lCHYh9UsEYoGETBFIoC+czIiLglE0rf0C32 MIX0xsVQiJv43D43Qs2y1YM/Oq+BP+cKH52n1h4/0iwg6ePl4ICbcUGnSn2lxd234w3y0E6a7Iy +AzUdGz32xNuAvXoX1auFvId5epeH36nUvZB/8lhY9yYxYUFBHmQNMjFUBD5iqvdlZO2mP5CE1J Iir7+mdNnAses1CF3b/7MbldW12hVFQfwKrtok4os6nIJJxOmKjY/ca/0S014jWGOBUSDRVcrTi ybI9mxWIoXxCPDv+zeztUJIKk+ovF56isFaJy3nnExZ5Qe30H3Q28tzQHNUXmRYcJwuReYZ0VpP 9Fd1fBXCYWUpzoNEyt6i10l+KO+cBL2/aC9i6vq3d4jRTgRBg/k7hT2TVYjtNklVyWbXz8= X-Received: by 2002:a05:6a00:124f:b0:82f:1f43:7190 with SMTP id d2e1a72fcca58-83f18d5bf1fmr16153852b3a.3.1779141786230; Mon, 18 May 2026 15:03:06 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:05 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Tue, 19 May 2026 03:32:23 +0530 Message-ID: <20260518220228.63322-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the trailing-pulse selection out of hx711_read() and into its callers. This is a preparatory change so later variant-specific code can pass the per-channel pulse count without adding a separate read path. No functional change. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No change from v8. drivers/iio/adc/hx711.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 10ccc69f209b..30e1ce321747 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -155,7 +155,7 @@ static int hx711_cycle(struct hx711_data *hx711_data) return gpiod_get_value(hx711_data->gpiod_dout); } =20 -static int hx711_read(struct hx711_data *hx711_data) +static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses) { int i, ret; int value =3D 0; @@ -174,7 +174,7 @@ static int hx711_read(struct hx711_data *hx711_data) =20 value ^=3D 0x800000; =20 - for (i =3D 0; i < hx711_get_gain_to_pulse(hx711_data->gain_set); i++) + for (i =3D 0; i < trailing_pulses; i++) hx711_cycle(hx711_data); =20 return value; @@ -237,7 +237,8 @@ static int hx711_set_gain_for_channel(struct hx711_data= *hx711_data, int chan) if (hx711_data->gain_set =3D=3D 32) { hx711_data->gain_set =3D hx711_data->gain_chan_a; =20 - ret =3D hx711_read(hx711_data); + ret =3D hx711_read(hx711_data, + hx711_get_gain_to_pulse(hx711_data->gain_set)); if (ret < 0) return ret; =20 @@ -249,7 +250,8 @@ static int hx711_set_gain_for_channel(struct hx711_data= *hx711_data, int chan) if (hx711_data->gain_set !=3D 32) { hx711_data->gain_set =3D 32; =20 - ret =3D hx711_read(hx711_data); + ret =3D hx711_read(hx711_data, + hx711_get_gain_to_pulse(hx711_data->gain_set)); if (ret < 0) return ret; =20 @@ -264,8 +266,8 @@ static int hx711_set_gain_for_channel(struct hx711_data= *hx711_data, int chan) =20 static int hx711_reset_read(struct hx711_data *hx711_data, int chan) { + int trailing_pulses; int ret; - int val; =20 /* * hx711_reset() must be called from here @@ -280,9 +282,8 @@ static int hx711_reset_read(struct hx711_data *hx711_da= ta, int chan) if (ret < 0) return ret; =20 - val =3D hx711_read(hx711_data); - - return val; + trailing_pulses =3D hx711_get_gain_to_pulse(hx711_data->gain_set); + return hx711_read(hx711_data, trailing_pulses); } =20 static int hx711_read_raw(struct iio_dev *indio_dev, @@ -349,7 +350,8 @@ static int hx711_write_raw(struct iio_dev *indio_dev, if (gain !=3D 32) hx711_data->gain_chan_a =3D gain; =20 - ret =3D hx711_read(hx711_data); + ret =3D hx711_read(hx711_data, + hx711_get_gain_to_pulse(hx711_data->gain_set)); if (ret < 0) { mutex_unlock(&hx711_data->lock); return ret; --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FEBB3A1683 for ; Mon, 18 May 2026 22:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141792; cv=none; b=XGBFgxiO6X5sTC5XKKisrfKxvtmCbS1fnp/Pf0xk+jeKih693lVD83IgDcHbPrFWuDnad0e32DW/5N7mSAFPk2mQkGBZ3FDq7j0WIDm8zORDpaUTmYSLnfleChnKNGoJkpuiYaerHckb+MrcPOo5ur83eQaQX7+r10IinDHSs88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141792; c=relaxed/simple; bh=SYBXHINTBKF35umDA/Ci4NtfcsdeWgeH1PRaMh4zRvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NvaC2gwbFzyWUZJ1LL4Z8kHE7o2zc/kAnAhkL+Pie9kgo3u7G7xYwSgrGQitKtBXNN/W+wAbWMF/1PbRVhLvklXSYxVOTi5Op+rvWG0FRTF7Wzst4ET2Qw9UmWmW3jMzABJJfXz0rqvfkM58Fe/su61tbUrnTlwWVd8vH0bCRLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ROTD/znj; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ROTD/znj" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82f9fdfc965so1195698b3a.1 for ; Mon, 18 May 2026 15:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141790; x=1779746590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Ae3/JbEJyowtyIvHRgRioSvia9PJ2dzMefDwMaXfbE=; b=ROTD/znj1SOgZt/pjwiZlK4xbcIP/SomI6Pwa4FE0oKjdsTqS8gy9kXRbDGeQEdiGT EKjpSO/1u3kbQcbT1wx9iM/5/4g+nivA8qfuXmWZWdZlFfwoxYedSml61OknuMghw/Gm kUptQWuZDvKvNiJ4B0hnIXCUdk7E7FV883F6pQfh+BFZbsX3fSrrbOZ7NBZ1RNMNEDg9 3/AMw6c8Q6X3axgAelyNvHaei4BjyO+alqtYgFFdGHlbduNETTY7CiHoJuuQn7awrSti sG/zWdByBdxC6Q2wxzOvDhn4dadFdP/j0ki6VcPCbfa3KgLIOL2JlzlleYzUjO2WjxPk 94tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141790; x=1779746590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6Ae3/JbEJyowtyIvHRgRioSvia9PJ2dzMefDwMaXfbE=; b=TXxqUFzyE3QS6nv9RuMKPIq+aY3GyH+rB6gvDmguyHLBeI+Gnqjn7MyMnPhvaM5y7v +whaNzGgjpDEuNo5KwT/QNDaCvaLz9r396hMftqFHoCMS5zwuNBiAJ7EqDFwC9FmZ3Qd r/v2J81QiNWDhwn6ny0qfdu8CcQsSFA0yMUSm4YVtfsorWontqBQa9MrOPWi+DJ6OAlB kNuQzZ/AeqFi01f5WMC4cLxeTFXVCfmknd3RLKizafZbGLX1swF91hqZMRYUvj+oYDRE B9XaOWmJpVowDMqCSDmVqxR5M/DL9mcVlVLYnEjUAw3OUx6f7BS/unyP6ay5r/lFDO7q N3Vw== X-Forwarded-Encrypted: i=1; AFNElJ+uJnSoHsgRBqcCW69aZEHx0/VAr/zcPnMFxbNEbSG7w3lz+RG54DBeKarFtyD/CFfCKUwj5M3ZEEa2sF4=@vger.kernel.org X-Gm-Message-State: AOJu0YyjWD9mPjSuEP5VFCqaNj3b+Wm3OmVyr42Axhn87+PG8ZMLaxlS mQqK8E9Zq3EKUGx/couvDCpAMOB+/L3/RCSj7iBUtCMJ/wzUfDOlLVtK X-Gm-Gg: Acq92OEcpJBrsiWf4VnEpFjRJqUvveGVNqdvHEbXgFK53U5NYfhW4Ic156OsdWQBtOR djZESSb1Nu+Ggy2dyrxNFfKGYg04c+fRCDMPnRmlHBuc0ZDF+0Iji6r1O8M2ucXsJQv7CFCkkaZ 8Pe4tsLWa8jY37vKLFjPdveD2GMPId4ekBvA0bitH64sNjBl/r7GbLQv+BaAZvfpHC7t9ILURkk mFDB/cy8PO/9X2QFrVaS5Wv/d6sL8YHd2+107gym/dODwdAEBB+YSQdHkasRs57p+/YpLUzW49s oMyvMksRLydQroLPWNjTWIiIFZI+QQtTx1kp+55vFUdORfVnn8J/0LAoY9FpM/ob4OFeUoueJDZ mEK6U9r3Xn8i7adJ/riXALcddPD3bsh6GsyWJBYQju2SYpfR+t3ldn8vB+2sYm4hZzbbDfFtxKU CInxtQKjuli8Hj72HK3H+dsRLLKFA7waFZDy5ld5A++WawsDYykevhh+KGzhniyHGM4VJeT8Ob+ aQOxa623NJPLMcD+d2tD+FHMjnex90nB7QAwwo4HDVnXva4IAaAWXbyKkYq X-Received: by 2002:a05:6a00:3907:b0:82d:556b:7a01 with SMTP id d2e1a72fcca58-83f33c25b5bmr17418803b3a.16.1779141790385; Mon, 18 May 2026 15:03:10 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:09 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Date: Tue, 19 May 2026 03:32:24 +0530 Message-ID: <20260518220228.63322-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Separate the initial value assignments from the declarations in hx711_read() and hx711_reset(). This is a small preparatory cleanup before the later loop-iterator and variant-specific changes adjust the local variable layout in these functions. No functional change. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No change from v8. drivers/iio/adc/hx711.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 30e1ce321747..9e5cafa1e307 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -159,9 +159,10 @@ static int hx711_read(struct hx711_data *hx711_data, i= nt trailing_pulses) { int i, ret; int value =3D 0; - int val =3D gpiod_get_value(hx711_data->gpiod_dout); + int val; =20 /* we double check if it's really down */ + val =3D gpiod_get_value(hx711_data->gpiod_dout); if (val) return -EIO; =20 @@ -204,7 +205,9 @@ static int hx711_wait_for_ready(struct hx711_data *hx71= 1_data) =20 static int hx711_reset(struct hx711_data *hx711_data) { - int val =3D hx711_wait_for_ready(hx711_data); + int val; + + val =3D hx711_wait_for_ready(hx711_data); =20 if (val) { /* --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E39673A1A29 for ; Mon, 18 May 2026 22:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141796; cv=none; b=UBf7zJP4xFg2/ENvz3u+RVDrJGn0GrKt7+U4XtbzcRcvpDZTcy1vNgeoKffCp+GGj8gwBm4GghXOTJJQi9M8LPTH4hRBFcvw+d6r9kFC9GTkU4RB+s9nfGLgvSB4VvDwJJIactFloSdL9xs8CsXC4a3GICDXDH4m+T9HABRGWd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141796; c=relaxed/simple; bh=R9bwTFIJwq+fwIoSatBtXQNRjV3224ZU1kWtKpEQ9Qg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IIDrvxqRUK97Pq6qeoBCj9z/PWRm7hS3UxvpFXCoIntzyfONXJOXksyOZDdbpAXn7DMR64xth6z1OySPe76zGdN+My3cmQM5lREGhTthR0TH8RRjvd+4cjl9f29p4qmdGezhbaZHyUUKHwT39xZquWfzBNuwjN9uYZCmtsE6HPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WbXdtKU/; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WbXdtKU/" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-836ebdeb969so1238571b3a.3 for ; Mon, 18 May 2026 15:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141794; x=1779746594; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yvUEwi2/32Pm+I7ySH9JgCFLggtG2+BEwjV7D+cKqy0=; b=WbXdtKU/eCEjZuKwBI7CdlHCVikh+9TI8m7nb2YVRmOmS+nE40OgOXIKXuIbfALRMQ +Yvv6KqZ2g5nuXDflz4hNH6o85IAfRlHT8m+1zK9cQythbltEplGt0qQuRPg1wHPcY3R PeuIZAR8BfKOLVkig+x3do1N1IF3+ok0k3YzQpFRyVo5C1Vj/9JmGPN9us5CWHXJxx8O V2vyR7Z/3ou0Lmon+IlDPP7sBg6rrRg5qlgS+i8PVa+oq2MauzJ2sF1PbDzb0G5ELtkh S2jJmFIZxm7XPhztWOAKv/APy5XKTvGH21ID8oHciVfULlAPbD1IQMTorIg2VwFhzkUq Nw7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141794; x=1779746594; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yvUEwi2/32Pm+I7ySH9JgCFLggtG2+BEwjV7D+cKqy0=; b=hrCgZY/MqJbne/k9eqtJTngzAkpM6VD+aaeMmPTx8EVVlkvp/y0J6DGYoqldh9jGfF X0c0+5UF0gd3lb2Q1NbdD4Q028WRW3UIXS8rBE0mmH24TQtqlqB76YTtcZ/yang6hnUo XJyQbAYUPEk+mVlMWuaKSanUbnY9SBK3DBah0xwg8A6P9JOyAYmGd39nH+a5Fs+MQjD9 OBu/a5TQaiAheGjBRzro56F9g8PkP0Y7rPjNzAcghoxNP8BjvYcPCrB5ms/GsVFq8LCs QVbwaE3oVWHuW9Ft2ImAjQk4/tWNJzjdEKxYcBS5L9b/mWB7ivOd0zK9+FMG1ki0lhN8 dDlg== X-Forwarded-Encrypted: i=1; AFNElJ/7ulPuBecCx3AmAfkNhv8wHhF2M8kdBvOxjEmKByONMjp11DMavBulF8SOIiF3p6jRD1Sgq4hAy/+Q/BU=@vger.kernel.org X-Gm-Message-State: AOJu0YzUdeVe6stn3euCEj780hbFMv67ZwuGaRw1m54Sb0TRX7wIZY/y q8Gz4PXh+SG7+JYAkIyzrqQdmSoNLSO2d4XDgdFCnV5AOBqGsYCimM+d X-Gm-Gg: Acq92OGZcK7sj+02DUcTyDEL6HIGN0Y+ZcE7Gzc3X0FZrUOyNSBQXvXpgca678d/bh0 v3+7VQ5WokgSF+vGmZaPd6K7+TGQXYtdf/9GNaoXjYk5wko4r9q7Nvd90zmS8MbG2Bf43Y/bgzE VTws5ZhjSMH+gODBZILDn/mBrDpP81eKKNowgvFop90BWHjxJhDbQMG1NA/YLao3MIvd5azvlau bB3L4PlZ1c2/MV7vXF8G9hZ3JaLmVCDhee38lOXweAIu39BPWkBNlSZLgwg/246hEOWn44yi/l0 cG781BfHf26BUHNlybxr0aWD4T3GivI93cMkIXHs35Q2wG+AF94JDMXbTqjtWv6cCg0gM+3usMq toe/AwDrrFBw6QdygPAOSqaHLca/QayVBhYfLUcJPaGF+lNLqcvqQFvb3DYI6eNjSwuhDa93kpN KaBZmi8H1nh4P/Ab2nvcDHVrfgAgKzr9ijb5GW32tKredgy8/zjuj7KIZ2QngyVm2pe1QnW8Cho gnzAWWL5LQU9Bt7wsJwV5IvpMudGpalLp1RdqxhZh13Em8I//Mzhx64FzLlXipjEdP//Tg= X-Received: by 2002:a05:6a00:12e7:b0:837:666f:8fcb with SMTP id d2e1a72fcca58-83f33ba1603mr16232568b3a.5.1779141794380; Mon, 18 May 2026 15:03:14 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:13 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 09/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Tue, 19 May 2026 03:32:25 +0530 Message-ID: <20260518220228.63322-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Tighten the scope of the loop variables in hx711_read() now that trailing-pulse selection is already handled by the callers. Also replace the 24-bit loop bound with a named constant while touching the same code. Suggested-by: Andy Shevchenko Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No change from v8. drivers/iio/adc/hx711.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 9e5cafa1e307..0db2d2db9242 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -23,6 +23,8 @@ #include #include =20 +#define HX711_DATA_BITS 24 + /* gain to pulse and scale conversion */ #define HX711_GAIN_MAX 3 #define HX711_RESET_GAIN 128 @@ -157,16 +159,16 @@ static int hx711_cycle(struct hx711_data *hx711_data) =20 static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses) { - int i, ret; int value =3D 0; int val; + int ret; =20 /* we double check if it's really down */ val =3D gpiod_get_value(hx711_data->gpiod_dout); if (val) return -EIO; =20 - for (i =3D 0; i < 24; i++) { + for (int i =3D 0; i < HX711_DATA_BITS; i++) { value <<=3D 1; ret =3D hx711_cycle(hx711_data); if (ret) @@ -175,7 +177,7 @@ static int hx711_read(struct hx711_data *hx711_data, in= t trailing_pulses) =20 value ^=3D 0x800000; =20 - for (i =3D 0; i < trailing_pulses; i++) + for (int i =3D 0; i < trailing_pulses; i++) hx711_cycle(hx711_data); =20 return value; --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 462473A1A29 for ; Mon, 18 May 2026 22:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141800; cv=none; b=tVzdiKVmZISLGnQpZH5LAOL3YllAQblqHvbhh0X6HnjVLAKolRIZ/d6CzEJdRrcduvt9FCwEF0Kdo9OJzpeyJ7kszH2wV+YQDgPrH4RYFnAhUjLpe0KaSHhZ7DXjOlKiFJDCppHs9hKeoy7EYhzC+TVsFHEZRjybsBFpuHJpWTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141800; c=relaxed/simple; bh=WhtpzRjiFjKxJX+KV+nt4yvclp6WLo5XCxauQPqKOP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q2vuG2WVZ4pj5zVLAhTT0W0l4uYeEn0BK+nd+51OdLJ2+kawhQxi0wYhMbHG1FDQ1WUbKMhSuyoXVeM0nRCgN5QjAqCSUvglVc6FErjKJQwXVasIyAY/i87KWz7mOCBkXUK6Vjvt5r+L+Bmhn+0BrdVPuVkvzY5GjOnrfjeZIbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oCBPhy4A; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oCBPhy4A" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8383fb7143aso1228475b3a.3 for ; Mon, 18 May 2026 15:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141798; x=1779746598; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c6ABU32L9kWqfPPVPaRPH2nySKI3U/9YaJ4r872onSA=; b=oCBPhy4AmK525XiIB86YO///xcN+QvPc98HT+XVD45MgYHHdtWQ9nldP2nyu9sGkyF 6euCte2hFUYnphhd/U4+/9KBCLWviEg4lqtX+wIX88nmj5PZdX7udhgMzZ7PgyLjGIdN IWcejE7ICjaaU3xVHgXLEvgADgpuAi6DUTw7nlnWzJfOyTPG7Wj3gNuxTnPjT7HH1R2l icJMNZ4QP3v1UnxjE+y8vCqmr6aPhpaUIus0Vv2q59DWVwDMEy+pN9OSaa87f4jiPzAI Y9rAhGlWRU8ftOmhANQOCJG5pFcFi5GeF241XXDbcMNPbdEvUCjThuai6qb1+JBmxvUK LqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141798; x=1779746598; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=c6ABU32L9kWqfPPVPaRPH2nySKI3U/9YaJ4r872onSA=; b=euuSDuwURnyg/UZf9zV8j0zm5UbOZX91nCVvcM11sJFzsS1UXfxqpa99q7zGx4jyF1 uIWgWh2d4BXiE37Oy97yqtrekuB6HuogrDjczYfLo1Yvn79p3ZeFvQd/LgZR6fXymM/B 2zIjOlK+Yv9GMDjtoVaeUyGGbPF7XbXvt4y1BzlwrIWKB1OHg34g8hI1cEWtMtbzxZBL 1dticpbnU9hKcsTNyKiEQMgOjypimfsHWU6vksncv24H2l7vozMYZeBYqkgafwc0kDct ao9fmp89qHIOVnCfezysYhgNN2J4fsLjspTDpSknJXbLVOpR8DaBPmmqx7Ma9y1UwN/z 8ptQ== X-Forwarded-Encrypted: i=1; AFNElJ9rp5e6Fs/gzrkWVdpeAHPhL69XysmQcFXW6HMW/J/dMlUKBWPcJqHGYWEoDI8giW4ptfrPUKq44qDLw78=@vger.kernel.org X-Gm-Message-State: AOJu0YyxXXAwmH4C5UmlZ5Ozs8j8/DNcuHRy9HJi8zJ1EQ9YqZe6jdmj alGaIrtFJRHN2T8CByUdZF6gbIJAyzoN/fyDFOF5hvTtM1vaEDnHd21w X-Gm-Gg: Acq92OE23wQ5ukBlXd2UPsLbhRjSWP/awRUPJPA1xppxPXZ5LKbKItxwapJSSCAaaTE 49+WE28Yqp7UbcOip9gZLSDA8nU9Rq0zcqOoIRiw0FTXMeG8Q4r6n8G/Fl9DQlUdGl8s5zvdR9p UaD1N4JKw29pzfFEWVxtYZyXUXcfTxYEAmTPKAPA9qHcTfgUn/3XK1T+WGndyrZdGUi0Vo7zJrX rHowP9X3W59HyzlU5zdV/emV5kw0aDhk4fl6FFKt9gH0X0xamN5sRWVsJfDdgFGs2XxjL3RiFMu eicMBFVZ9LmSD5thQ9JSgSsz2F/6xkjWdR7p/aDPCMezVjnPNWS7icCXFgp+iGIX31KYr0XsP20 lD052ljMXaIdDKgECWNCcnfEM4aiP06BM5XaSbWwy3tROlwiH3eLOwe80dPpd5qcPU0rGiOdG3o FmSjVU3+ZMqiEe6YMf//kuJEyVvg97A36fjYMC3uudjvGY5FNhf9NfC5SXs7MpSEaWcEfAlDyhB MrK0zcktkBIj6+CHtBH0X++4sr7IDzGW1UtYXkk7uxb+7DRTxUtEbTJaX0p X-Received: by 2002:a05:6a00:94f1:b0:83e:cc27:9af7 with SMTP id d2e1a72fcca58-83f33d39f79mr17554373b3a.31.1779141798573; Mon, 18 May 2026 15:03:18 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:18 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Tue, 19 May 2026 03:32:26 +0530 Message-ID: <20260518220228.63322-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Change hx711_reset_read() to accept the channel descriptor directly and update its callers accordingly. Split the existing HX711 channel-selection work into a small helper so a later variant-specific change can add a matching helper without growing hx711_reset_read() further. No functional change. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- No change from v8. drivers/iio/adc/hx711.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 0db2d2db9242..183568196d52 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -269,7 +269,23 @@ static int hx711_set_gain_for_channel(struct hx711_dat= a *hx711_data, int chan) return 0; } =20 -static int hx711_reset_read(struct hx711_data *hx711_data, int chan) +static int hx711_set_hx711_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan, + int *trailing_pulses) +{ + int ret; + + ret =3D hx711_set_gain_for_channel(hx711_data, chan->channel); + if (ret < 0) + return ret; + + *trailing_pulses =3D hx711_get_gain_to_pulse(hx711_data->gain_set); + + return 0; +} + +static int hx711_reset_read(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) { int trailing_pulses; int ret; @@ -283,11 +299,10 @@ static int hx711_reset_read(struct hx711_data *hx711_= data, int chan) return -EIO; } =20 - ret =3D hx711_set_gain_for_channel(hx711_data, chan); + ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); if (ret < 0) return ret; =20 - trailing_pulses =3D hx711_get_gain_to_pulse(hx711_data->gain_set); return hx711_read(hx711_data, trailing_pulses); } =20 @@ -301,7 +316,7 @@ static int hx711_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&hx711_data->lock); =20 - *val =3D hx711_reset_read(hx711_data, chan->channel); + *val =3D hx711_reset_read(hx711_data, chan); =20 mutex_unlock(&hx711_data->lock); =20 @@ -391,8 +406,8 @@ static irqreturn_t hx711_trigger(int irq, void *p) memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer)); =20 iio_for_each_active_channel(indio_dev, i) { - hx711_data->buffer.channel[j] =3D hx711_reset_read(hx711_data, - indio_dev->channels[i].channel); + hx711_data->buffer.channel[j] =3D + hx711_reset_read(hx711_data, &indio_dev->channels[i]); j++; } =20 --=20 2.43.0 From nobody Mon May 25 04:35:10 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 676783A16BD for ; Mon, 18 May 2026 22:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141805; cv=none; b=pv2ZV6l724vKRktonK6oyJ9KbBmIHqP8KDHvMxppWpE0RT1n6enY0bcWBxbkjxyUFd6jDHNCwmG/fCrkbBxHlVx/g0a/0EpkkoJBFTKO62uzihntGvWq6oK+Jt2M2iYnqUD8/oZuFA3azZ6n0TuuerqFog9tdQWx+TkmpyVAq9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779141805; c=relaxed/simple; bh=QREVGmbO0flASHR7B9jWuwtBmy40wR+vMZDh34awweo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c5ydRvjFfuoO9jaBbLyIcOPoVEc3EE8F0UoU1ajoi1vq4gDmjPcGkvdC7kjLH7dXhGpuabPCJZbHWM7N+Gcp5dYGc7IVX52ayM78s+yd83shWj35NW7tnDDZn3IVY5s0Qa6vkB+vDAlqRlykVFz9FXBmiVEH9GxxBlU1V59jLg0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lJT8Yipb; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lJT8Yipb" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-835386ff122so2979156b3a.3 for ; Mon, 18 May 2026 15:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779141803; x=1779746603; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t31rL2+BJeheFfwXTUWp86Cw2iNCjJotlcNbQb/7e1s=; b=lJT8YipbsF3NCPTOYgorb4cTDbWGT6VT2g3KWj8mZZj3AFyjpyv62+ZWdJENV3tPRm UaweD01brMtA1OoY+UW2Akvs5GliG+kKTDVM78zj/ZBc6GRqRepZXrpqeTsNcCa5lbVy JAJh5t+PPYO3fio1yqs6y+p9x/TtBQQBth2b472wZKlLSGlZmw5L3HQueA4gKmCWH59F W7vSZrLNeBEuQBsmCqoaok0Swv8cydc7BL3dq8UatjZg3keqaE2Z2Z/urByUFNKyNE7Y KZYVwG5P4XZ8ElB3DJ1RT1fYwyTycgWD6NKkxI1YeokvdYNimMFP8GbbKSbIDMJreb+R VNmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779141803; x=1779746603; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t31rL2+BJeheFfwXTUWp86Cw2iNCjJotlcNbQb/7e1s=; b=PTF7aTI+k7klz8RwR0FPYzBALSuq9DruF0nM+76ihq+U7pq7V1NyRgvasdVL6deK3O dLPfzZqoEvb4tDTiAL8p2PqyQ75LODa6HGJGvMOj6uiJ9S1jOdTMIunj/2UG+606vT9Y PEUYTRdSxnaGkwQwvq65maNo2UBB4TEZy6j1C6sTIIbRC9XqdxOffBFe+5AvQru3zMTV jg/gIRu/0EAeoTI0qIA6iRIbG95u++jfVqpCAkkgy9MxOn6zy8ZVolCO5DNoV7CDaK1T +4Ef2kWWJwJgDKGCDqbT3TiQsiTWsa+6/x6WKKm/GCxXZedzTn/4oTpYwCNZKSk8XF2x 7WAg== X-Forwarded-Encrypted: i=1; AFNElJ9zkZk+yKMwyyhm4gYGsOJMFKeXf7qzmV28R2s6J/RYyuw/y20X+PsRE9IDYzQZdUIaIJV58w35vzZky4Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzaEJwHcMeY2E8lcj5LRptvZrOYJRpXScVP09e6xZ1boyWEbFLB 7+K7V7nHiZJY1R0QsKWi1otpUKfj1oozXNMp04/8MZ3HPGzB7FFgBg4t X-Gm-Gg: Acq92OFtHdEEHhLYQrDCeQITSaMm3hzevWkPzwbO3mDkDnAi8yBGMa2g3NKRSnBbozy bDialHxREJYh7llPLgkRyJMphEcu9O3Oqfl+XBl1FlUds3N2Wv+ZDHS/cCRkDv/04NF2nVvcYZ+ V2g+6n3lbqwyYkVTbgIES/SJvwdfmat0/d301k1CfZJ62LXQaDdj2IW8yn/KH1UEX9MOuCks6g6 ONeuWPOZuUi+HjjPt+mz7IMxDmHd4oyafjQodn9Ire+9Co5H3/5kHVOM0tjmLW0M2vwH26B3oxx MlXBbCBCSVbKSYBpPtIYl6qM941rX5T7638XMtNGq4Dwqbjg/J5ZWI3jadMhL8vYhu7xRxDA/wc rLAPK2/N/40W4bYC/G2nAiL/VDFxHcnl58Y8se5XOcKc/GUXIsn5FRKNSCz47Cq6j6wJFMHibr9 Y5/ZQtAhPyVRx0rMiXX1arFvDzE6TcojY3IHYwbIclbL3kZCW0KDKGENeXUUDXdmNOQCG/CUibm p9JwrRcTM0aQrKGgmZI7Wsb3ZjF95bVsUFzNjpacLbQLGN79NqgIiGkkFYn X-Received: by 2002:a05:6a00:c93:b0:81f:3fa0:8c38 with SMTP id d2e1a72fcca58-83f33b4d8a6mr17293228b3a.20.1779141802541; Mon, 18 May 2026 15:03:22 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1977b128sm15772960b3a.22.2026.05.18.15.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:03:22 -0700 (PDT) From: Piyush Patle To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Andy Shevchenko , Conor Dooley , Krzysztof Kozlowski , Rob Herring Subject: [PATCH v9 11/11] iio: adc: hx711: add support for HX710B Date: Tue, 19 May 2026 03:32:27 +0530 Message-ID: <20260518220228.63322-12-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518220228.63322-1-piyushpatle228@gmail.com> References: <20260518220228.63322-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for the AVIA HX710B ADC, which shares the HX711 GPIO interface but uses trailing PD_SCK pulses to select the active mode. Model the HX710B with variant-specific channel tables and IIO info, track the active channel across conversions, and use the fixed gain value when computing scale. Also update the adjacent Kconfig text, file header, and module description so the driver text matches the newly supported variant. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- Changes from v8: Channel layout redesign (Jonathan Cameron): HX710B modes 1 and 3 both read the same physical differential input (only the sample rate differs: 10 vs 40 SPS). Exposing them as two separate IIO channels was incorrect. They are now collapsed into a single channel (in_voltage0-voltage1) with IIO_CHAN_INFO_SAMP_FREQ; userspace reads/writes sampling_frequency to select 10 or 40 SPS. The hx710b_write_raw() and hx710b_read_avail() callbacks are added to hx710b_iio_info to support this. The channel spec no longer uses .address to carry the trailing pulse count. A new hx710b_trailing_pulses() helper derives the count from hx711_data.samp_freq (1 for 10 SPS, 3 for 40 SPS) and the channel type (2 for the supply monitor, which is always 40 SPS). The IIO_DECLARE_BUFFER_WITH_TS() slot count is reduced from 3 to 2 to reflect that both HX711 and HX710B now have at most 2 physical channels. channel_set ordering fix (Sashiko Suzuki): hx711_set_hx710b_channel() previously updated channel_set after hx711_wait_for_ready(), meaning a timeout would leave the field out of sync with the hardware. The hardware mode is committed once hx711_read() sends the trailing pulses, so channel_set is now updated immediately after hx711_read() returns successfully, before the ready-wait. Trigger error handling (Jonathan Cameron): hx711_trigger() was silently casting negative error codes from hx711_reset_read() to u32 and pushing them to the buffer. The handler now checks the return value, logs the error with dev_err_ratelimited(), and skips the push via goto out_unlock. drivers/iio/adc/Kconfig | 8 +- drivers/iio/adc/hx711.c | 240 ++++++++++++++++++++++++++++++++++------ 2 files changed, 212 insertions(+), 36 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index a9dedbb8eb46..38ba8cae13f1 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -791,13 +791,15 @@ config HI8435 called hi8435. =20 config HX711 - tristate "AVIA HX711 ADC for weight cells" + tristate "AVIA HX711 and compatible ADCs" depends on GPIOLIB select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - If you say yes here you get support for AVIA HX711 ADC which is used - for weigh cells + If you say Y here you get support for the following AVIA ADCs: + - HX710B + - HX711 + which are used for bridge sensors such as weigh cells. =20 This driver uses two GPIOs, one acts as the clock and controls the channel selection and gain, the other one is used for the measurement diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 183568196d52..d5c977b4669b 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * HX711: analog to digital converter for weight sensor module + * HX711 and compatible ADCs driver for weigh sensor modules * * Copyright (c) 2016 Andreas Klinger */ @@ -15,6 +15,8 @@ #include #include #include +#include + #include #include #include @@ -84,12 +86,16 @@ static int hx711_get_scale_to_gain(const int *gain_scal= e, int scale) * @channels: channel specification array * @num_channels: number of entries in @channels * @iio_info: IIO info ops for this variant + * @fixed_gain_val: fixed PGA gain (used when @has_fixed_gain is true) + * @has_fixed_gain: true if the variant has a fixed ADC gain */ struct hx711_chip_info { const char *name; const struct iio_chan_spec *channels __counted_by_ptr(num_channels); unsigned int num_channels; const struct iio_info *iio_info; + unsigned int fixed_gain_val; + bool has_fixed_gain; }; =20 struct hx711_data { @@ -99,16 +105,12 @@ struct hx711_data { int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ int gain_scale[HX711_GAIN_MAX]; + int channel_set; /* HX710B active channel */ + unsigned int samp_freq; /* HX710B differential channel sample rate */ const struct hx711_chip_info *chip_info; struct mutex lock; - /* - * triggered buffer - * 2x32-bit channel + 64-bit naturally aligned timestamp - */ - struct { - u32 channel[2]; - aligned_s64 timestamp; - } buffer; + /* 2x32-bit channels + 64-bit naturally aligned timestamp */ + IIO_DECLARE_BUFFER_WITH_TS(u32, buffer, 2); /* * delay after a rising edge on SCK until the data is ready DOUT * this is dependent on the hx711 where the datasheet tells a @@ -207,6 +209,7 @@ static int hx711_wait_for_ready(struct hx711_data *hx71= 1_data) =20 static int hx711_reset(struct hx711_data *hx711_data) { + const struct hx711_chip_info *info =3D hx711_data->chip_info; int val; =20 val =3D hx711_wait_for_ready(hx711_data); @@ -227,8 +230,11 @@ static int hx711_reset(struct hx711_data *hx711_data) =20 val =3D hx711_wait_for_ready(hx711_data); =20 - /* after a reset the gain is 128 */ - hx711_data->gain_set =3D HX711_RESET_GAIN; + if (info->has_fixed_gain) + hx711_data->channel_set =3D 0; + else + /* after a reset the gain is 128 */ + hx711_data->gain_set =3D HX711_RESET_GAIN; } =20 return val; @@ -284,9 +290,51 @@ static int hx711_set_hx711_channel(struct hx711_data *= hx711_data, return 0; } =20 +/* + * Return the trailing pulse count for an HX710B channel (Table 3 in + * the datasheet). The supply-monitor channel always uses 2 trailing + * pulses; the differential channel uses 1 (10 SPS) or 3 (40 SPS). + */ +static int hx710b_trailing_pulses(const struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + if (!chan->differential) + return 2; + return hx711_data->samp_freq =3D=3D 10 ? 1 : 3; +} + +/* + * Switch the HX710B to the requested channel for the next conversion. + * channel_set tracks the trailing pulse count that was last sent to the + * chip; it is updated immediately after hx711_read() commits the new + * mode in hardware, before waiting for the chip to be ready again. + */ +static int hx711_set_hx710b_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + int trailing_pulses =3D hx710b_trailing_pulses(hx711_data, chan); + int ret; + + if (hx711_data->channel_set =3D=3D trailing_pulses) + return 0; + + ret =3D hx711_read(hx711_data, trailing_pulses); + if (ret < 0) + return ret; + + hx711_data->channel_set =3D trailing_pulses; + + ret =3D hx711_wait_for_ready(hx711_data); + if (ret) + return ret; + + return 0; +} + static int hx711_reset_read(struct hx711_data *hx711_data, const struct iio_chan_spec *chan) { + const struct hx711_chip_info *info =3D hx711_data->chip_info; int trailing_pulses; int ret; =20 @@ -299,9 +347,16 @@ static int hx711_reset_read(struct hx711_data *hx711_d= ata, return -EIO; } =20 - ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); - if (ret < 0) - return ret; + if (info->has_fixed_gain) { + ret =3D hx711_set_hx710b_channel(hx711_data, chan); + if (ret < 0) + return ret; + trailing_pulses =3D hx710b_trailing_pulses(hx711_data, chan); + } else { + ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); + if (ret < 0) + return ret; + } =20 return hx711_read(hx711_data, trailing_pulses); } @@ -323,6 +378,9 @@ static int hx711_read_raw(struct iio_dev *indio_dev, if (*val < 0) return *val; return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val =3D hx711_data->samp_freq; + return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val =3D 0; mutex_lock(&hx711_data->lock); @@ -400,20 +458,26 @@ static irqreturn_t hx711_trigger(int irq, void *p) struct iio_dev *indio_dev =3D pf->indio_dev; struct hx711_data *hx711_data =3D iio_priv(indio_dev); int i, j =3D 0; + int ret; =20 mutex_lock(&hx711_data->lock); =20 - memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer)); + memset(hx711_data->buffer, 0, sizeof(hx711_data->buffer)); =20 iio_for_each_active_channel(indio_dev, i) { - hx711_data->buffer.channel[j] =3D - hx711_reset_read(hx711_data, &indio_dev->channels[i]); - j++; + ret =3D hx711_reset_read(hx711_data, &indio_dev->channels[i]); + if (ret < 0) { + dev_err_ratelimited(hx711_data->dev, + "read failed: %d\n", ret); + goto out_unlock; + } + hx711_data->buffer[j++] =3D ret; } =20 - iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer, - pf->timestamp); + iio_push_to_buffers_with_timestamp(indio_dev, hx711_data->buffer, + pf->timestamp); =20 +out_unlock: mutex_unlock(&hx711_data->lock); =20 iio_trigger_notify_done(indio_dev->trig); @@ -463,6 +527,50 @@ static const struct iio_info hx711_iio_info =3D { .attrs =3D &hx711_attribute_group, }; =20 +static const int hx710b_samp_freq_avail[] =3D { 10, 40 }; + +static int hx710b_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + *vals =3D hx710b_samp_freq_avail; + *type =3D IIO_VAL_INT; + *length =3D ARRAY_SIZE(hx710b_samp_freq_avail); + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static int hx710b_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct hx711_data *hx711_data =3D iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + if (val !=3D 10 && val !=3D 40) + return -EINVAL; + mutex_lock(&hx711_data->lock); + hx711_data->samp_freq =3D val; + hx711_data->channel_set =3D 0; + mutex_unlock(&hx711_data->lock); + return 0; + default: + return -EINVAL; + } +} + +static const struct iio_info hx710b_iio_info =3D { + .read_raw =3D hx711_read_raw, + .write_raw =3D hx710b_write_raw, + .read_avail =3D hx710b_read_avail, +}; + static const struct iio_chan_spec hx711_chan_spec[] =3D { { .type =3D IIO_VOLTAGE, @@ -495,6 +603,51 @@ static const struct iio_chan_spec hx711_chan_spec[] = =3D { IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 +/* + * HX710B channels (Table 3 in datasheet). + * 25 pulses (1 trailing): differential input, 10 SPS + * 26 pulses (2 trailing): DVDD-AVDD supply monitor, 40 SPS + * 27 pulses (3 trailing): differential input, 40 SPS + * Channel 0 exposes both differential rates via IIO_CHAN_INFO_SAMP_FREQ. + * Channel 2 is used for the supply monitor to avoid aliasing the + * channel2 terminal of the differential pair. + */ +static const struct iio_chan_spec hx710b_chan_spec[] =3D { + { + .type =3D IIO_VOLTAGE, + .differential =3D 1, + .channel =3D 0, + .channel2 =3D 1, + .indexed =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), + .info_mask_separate_available =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + { + .type =3D IIO_VOLTAGE, + .channel =3D 2, + .indexed =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 1, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(2), +}; + static const struct hx711_chip_info hx711_chip =3D { .name =3D "hx711", .channels =3D hx711_chan_spec, @@ -502,6 +655,15 @@ static const struct hx711_chip_info hx711_chip =3D { .num_channels =3D ARRAY_SIZE(hx711_chan_spec), }; =20 +static const struct hx711_chip_info hx710b_chip =3D { + .name =3D "hx710b", + .channels =3D hx710b_chan_spec, + .iio_info =3D &hx710b_iio_info, + .num_channels =3D ARRAY_SIZE(hx710b_chan_spec), + .fixed_gain_val =3D 128, + .has_fixed_gain =3D true, +}; + static int hx711_probe(struct platform_device *pdev) { const struct hx711_chip_info *chip_info; @@ -544,32 +706,43 @@ static int hx711_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout), "failed to get dout-gpiod\n"); =20 - ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); + if (chip_info->has_fixed_gain) + ret =3D devm_regulator_get_enable_read_voltage(dev, "vref"); + else + ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); if (ret < 0) return ret; =20 /* - * with - * full scale differential input range: AVDD / GAIN + * With + * full scale differential input range: reference / GAIN * full scale output data: 2^24 * we can say: - * AVDD / GAIN =3D 2^24 + * reference / GAIN =3D 2^24 * therefore: - * 1 LSB =3D AVDD / GAIN / 2^24 - * AVDD is in uV, but we need 10^-9 mV + * 1 LSB =3D reference / GAIN / 2^24 + * reference is in uV, but we need 10^-9 mV * approximately to fit into a 32 bit number: - * 1 LSB =3D (AVDD * 100) / GAIN / 1678 [10^-9 mV] + * 1 LSB =3D (reference * 100) / GAIN / 1678 [10^-9 mV] */ =20 /* we need 10^-9 mV */ ret *=3D 100; =20 - for (i =3D 0; i < HX711_GAIN_MAX; i++) - hx711_data->gain_scale[i] =3D - ret / hx711_gain_to_scale[i].gain / 1678; + if (chip_info->has_fixed_gain) { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / chip_info->fixed_gain_val / 1678; + hx711_data->gain_set =3D chip_info->fixed_gain_val; + hx711_data->samp_freq =3D 10; + } else { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / hx711_gain_to_scale[i].gain / 1678; =20 - hx711_data->gain_set =3D 128; - hx711_data->gain_chan_a =3D 128; + hx711_data->gain_set =3D 128; + hx711_data->gain_chan_a =3D 128; + } =20 hx711_data->clock_frequency =3D 400000; ret =3D device_property_read_u32(&pdev->dev, "clock-frequency", @@ -608,6 +781,7 @@ static int hx711_probe(struct platform_device *pdev) } =20 static const struct of_device_id of_hx711_match[] =3D { + { .compatible =3D "avia,hx710b", .data =3D &hx710b_chip }, { .compatible =3D "avia,hx711", .data =3D &hx711_chip }, { } }; @@ -625,7 +799,7 @@ static struct platform_driver hx711_driver =3D { module_platform_driver(hx711_driver); =20 MODULE_AUTHOR("Andreas Klinger "); -MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells"); +MODULE_DESCRIPTION("HX711 and compatible bitbanging ADC driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:hx711-gpio"); =20 --=20 2.43.0