From nobody Sun Jun 14 04:10:29 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 18C9E3AEF22 for ; Sun, 3 May 2026 12:10:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810212; cv=none; b=Z+h7Cu/q+nKRvOQpsgTe+o6E+s2ioWAsL9lIr6elFrhalY0TimRs1KG4yFyxXHVVRebPwP+2n9CO7T1HviwSS3X+SzdvpKmWpV5pAG28bB6WO3JaSm9tvKijtoQ3g5ecRbY8a/yIepSzo5lDbZ6MZOqU510lslLbPIO+ZY6lG3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810212; c=relaxed/simple; bh=YzJ8RosHX05iVdAZ2STTIxyp1FpJncO7Lahr+HQeVvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nE/1wWyIRPBegYiWtrN7b7Ajktck+i8Y4HdhG2Xrsodvi4Nn2md50ABPExIbXY4Pg17gVeT4e2pvFbjmAW007isYLJfLJiV/NDsCK3xB0I4die393ls6DnSdSmhprxcOw1HPXAZyHwFnfXIHY1hGw19z6gVsXHHKqCPD+oX8EmY= 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=MvDW7+kv; arc=none smtp.client-ip=209.85.215.176 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="MvDW7+kv" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c8027e876fcso74735a12.1 for ; Sun, 03 May 2026 05:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810209; x=1778415009; 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=0sJO8jnVqdesIsdCxc3bQ/uGr2AUdTF8/iD//ahP/KE=; b=MvDW7+kv/+2iWgcBQCZYvyM0ys2Q1/2G4/elB7Tfspjnw3xvmt1rn6/TasaaloDBia nwavCzR9mx5u4XqMXSH+ThUfFYrzc7XwkTAq+cm8+MK6ozuvN1P/DzZrxpQ6vLplAAeQ NJ+MNnms1rLRk5GfzNvUuRucDYM30J5l3paonr9CZD9NsBDyxM/akWK+q4trlIydfxGF +cz1lPXatZfb/vkFjDvrC+P/GG5OGnDK16f+H61GEvn/Zv3iIrfE93huG8HvDQ/dPThX qpZWyVM6eyWcY57ZF6EDDeQHQ4hnhIyy2+cdKcbuVXLQHTUHg5MRnk8Er/ONVSRtAhjz +lqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810209; x=1778415009; 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=0sJO8jnVqdesIsdCxc3bQ/uGr2AUdTF8/iD//ahP/KE=; b=O3lR2l/D8jKfoweXl4FR00CeIEdnIa3cc+6BbNLNq5rx0w5CxG9v70EAIX2k6x4DWZ J2jzW+84y41KbsVblI9QZaYNd5apwDq7959BZSa5t02AxH/ikUV56C6PDOgfGcPuEMDW U1yWI58FEMKY8z4ktvbVGKourLxXtO9SeumhzMC8/DWPyCQihCCjPvQL4wwkfgUU4xhE PiFEt/oIEgUPRnqKaY1x2g4tUMZwo1+X8Ds+NbBNyxcpV5FZiPsUVr3aJruwQaXkvtDo 9Sjjii5sHoySzpbPdtmMywtbPFrtvYYj1/FWkP7ZVT6yjn00ln7HiwAju1ot9DrExSAK YprA== X-Forwarded-Encrypted: i=1; AFNElJ/Zwqzls2rNxYudrTAYo042lVFmeu4cYd6xq7W5I9U+7znhQ3F6qnMRR7lwMEG4z1IVbYJKm9ISgNpezBY=@vger.kernel.org X-Gm-Message-State: AOJu0YypxdzWI8TF4jkl3P5uftNcv7d/m/cbIG85lSDsQCqqkZQzjMeC 3TwfBgVb781zugF/4B9ndo4m40TOdmzeA1KsSs7QDwey3K8r1Q8ci17w X-Gm-Gg: AeBDiet+V69QMINA5U3P9HdwGUWHdLuZyT/x2Hb6CB8YwCGWunExCPqIKYu8aK+Bfdi jfg9s8hz66Jcbt6Dus/hhKKRktLL78cTBv/G2Yq/VhjsMbLvmWifRgJz3OWDbcQZydiCIHDAMEp MvmRWGAK7jF+h+hjGbUGI6L54nM4b0DCm3p+KeDJ/+Fe4oj61LBcv+dYyHBN+vS/dWnatQumN+/ nZ221gaTfhuzEbgHEazlYfjfyEEHSk7SppSbH6hoe/DSlq0l0zDOKG2kjAmCS9WaL+WFlkCITR3 nuV8jdESyGU+GvfTH3kixAa2pUt8+vgdq0wVmJ2mdBK5QRny/qJNjhXPNZlri42fYJ0yz1eEqIU kmvC6WdWdWOVu+gV8n/j9uvegNK0s3AlQBqXkrsi7anHB2Cgh0LA4cBXzMMnP/x9LJqeKnpyYb4 TXUt9gIHkLhOqsKtlNkm90HcFTkZXG0gK/48lVyaT1aqXO9o2DnSLtpFes06RMHdlF1rebWtV8B EJUMGqt3hK6hdQj6b2BVcBc5FdJgn3/0o6Cuz0Njt/xyjFU3HvCTy6K/c4ROJeBwcl7sVU= X-Received: by 2002:a05:6a00:302a:b0:82f:316:31f6 with SMTP id d2e1a72fcca58-8352d202921mr5662327b3a.26.1777810209269; Sun, 03 May 2026 05:10:09 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:08 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Sun, 3 May 2026 17:39:30 +0530 Message-ID: <20260503120949.80292-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- .../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 Sun Jun 14 04:10:29 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 B0D4F3AD50B for ; Sun, 3 May 2026 12:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810216; cv=none; b=o37yIrGVcGsp2zZEUIre6nvry2/tC7ehmGMX9q2x2kqIX39MKcQIJ1lirNEK0ImQSUmeI3n7e09u2bJ46vgO+PMRsVfzXHB79KmnoRAS7WPAgdDFtswlsefak6Q8L0+MFWALbOL5fbk65XB8DlBGQ1AuetKIRrCe9nruBJ85UvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810216; c=relaxed/simple; bh=WCLmJv0TuyoCPe5fY1tMyic3ZulSQKRkwgkbREGxp4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIUS1Ry37wQiYdMmDLUHXBdZJqo1PperD8f+p6KyBduzdNZYT9tu3oDfxUrvmH5kQSSBTPt/1fytOjPa+QpOUQFU0SV/jDZ55P5YItQ0EjKZNjj6dYi204jSnO9cFcNnDzYibTkf4ySwV/k009qahVEkEq/3rsPM6UuEVH9+Kbw= 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=goU6gLEK; arc=none smtp.client-ip=209.85.215.176 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="goU6gLEK" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c802803ac17so81494a12.1 for ; Sun, 03 May 2026 05:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810215; x=1778415015; 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=qA9kbxgmrtt9myna//5BeoIpHJyNBXuDKkpos5wjQ7w=; b=goU6gLEKw+OhWiBpaHHbLaR90SBD/ImsYoWf9tMeSq1KgRpM2THJYPvQizCe9xaDWb YItWx+Da9UH8PF8sOldo9Rarx0Om1tg0BSa8mHWY7v0qtIQYUvkCN5oiKq8DzGd2jRqM 4PjV5ZOmv8Nbm4gdjqY7l9EkgWH+gMV7hN/dZeKfYnrQ8AJjwwJaswGBAKgfdcaINpcE 0RF2PzVDpKKk1E+cEERDieNiISKEXmNRhqsaPOOaN4IaN20heJGwYpquUGFgf4s4SZsP b8CiL0wEkmB9399smPdyB0V0jjpT2LOiUG09l4srhzkraemuWj/M9z4Z99CJb2fX6Lg6 H34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810215; x=1778415015; 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=qA9kbxgmrtt9myna//5BeoIpHJyNBXuDKkpos5wjQ7w=; b=NAnL0fgBKgsYg5HUuKJTgMu1KcFEdoDT5O2Vp8qqgrMr4cjW5PrDeOV5Ebu/9nYQ8n 0+rP7uzmKMPvDaUpo5f20XoZuGVP+hxKTyk7xr1Gs3R+p3Ek/q6iXePJs7Iuj0blOtJZ TBDtUKeyWwpwiocIYjzOboKai+wvWGQhko4mlvviqHavnJvbhNkq/2e/60qWBpQJJHwb hWio2nA3IdurVRa+osf3VpRaLjDByO1VeEC86yWi7GHyyo3bnixRNOlZNRZZnQ3ksVkM ok6YqsgKd/GxdjLO3jX41uHj4ckgJytvMVadulYSQaSoDphmq6SWaVnb3vA/+0m8fj2z iYjw== X-Forwarded-Encrypted: i=1; AFNElJ9yNu5D15g/c6R2OU81PdmmAnr3IsROqFR8Z73vsu7VQmPi3jOlKdjrX37+nqd905CFkS3SbqkRFwqeZA8=@vger.kernel.org X-Gm-Message-State: AOJu0YyiLrM5oEBtPyMlgwSFbDSloiXwZ7Dq9zqSrKQSk7QkC46rr78+ TuVRkFslqZKg60eDeAuLMRtJ+AcS+IRdZ+ViOIlgOF8jpoVfC2NcI9d8 X-Gm-Gg: AeBDietLoSlQCHu1DzHz+nlOxZBkDgKp3hKF2R+dNRpD6zwoprMIVZcKs2m31GLlDZe EkekpmN/hzBbRAmttXFpYa7RxZajlMOur/StGfNHPhZDSbvr8KtCB1DzJH/akLgA46QIrHpDXIa 8SEVRG/UeJtLe4cveZeFt41rck4uyAuoeyaeJIsH8kOhJstZoXyLh0sWRXp5iUMmKmqAWNAI/V1 tHp4tKa+SDSLdS5jpfYVWZqnLMDMyrGchy5okO5mRCWbuXjPBaIinW8pKyWQ7mjmCU9hl8vFki+ oNqWC77LENXftOV+590z3svym8g3EgESe2Bo2+2DFH6y+eNGXEDcO2jb9vUfNIp2+Pk2MlxNyAy jyGpXMmLGJBRCT68Tl/G0MJ9N9Vcs/7X7GuMp9IMfmctj08UGxTnO9+F67IukfaceMy+o7FbJFm b50v1ROSfZA7pCDNymJaZhsaFX1qAOZWkbvuLov7EcxfUCp9D8k/+RIwKSHoiOlvVqmXYGYz/F/ I5HwzidGuY/1OW1HPaNMSXKoif0oxpiqTvSJmSaJz9pe/i2RmTafh0jZd7AOxSCp2V63z+FMPPt 2+mk6A== X-Received: by 2002:a05:6a20:7290:b0:39b:d937:8020 with SMTP id adf61e73a8af0-3a7f1c52686mr5876488637.42.1777810215055; Sun, 03 May 2026 05:10:15 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:14 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Sun, 3 May 2026 17:39:31 +0530 Message-ID: <20260503120949.80292-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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. Keep this separate from the HX710B support so the existing HX711 binding extension stands on its own. No functional change for existing users. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- 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 Sun Jun 14 04:10:29 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 976A73AD524 for ; Sun, 3 May 2026 12:10:21 +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=1777810222; cv=none; b=fIlBoUZK1/6aaEFHyUmP93iOYDqw54mSGg07+bzLHoZ/hoSGpdZSsaDIPHM8Ldtz6dJYM8NQG4GjH08gxCN1+DO6MKbrIsrWNngfAh7SY0QW8v8eavJoJd+T0W8U6zCyNgsjIapWl0K6mip9D8gQ45l5cIgr/3Gi+zYZnzu8H8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810222; c=relaxed/simple; bh=97BloAxFVtTOzajOIz4gcpCzymw3iMe7qiRHhs6YZ8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kyl+vw+MI2dty/1IuSb53vIx1QT9HU+h0kmmGQ7T8oPJPpejx35+3SAavYzGwQSiMFlr3c2rstI/4HIP4dvUWiADHdwaDdrBuPw2zIyGfX9PjTQbdJcnySEhNpWzJxDcpLeQFvpbL7veiMS++krmWLMM/zCPUNbeN1o+HPJLzuw= 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=WXvTKVFs; 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="WXvTKVFs" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-835c98b659eso155094b3a.0 for ; Sun, 03 May 2026 05:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810221; x=1778415021; 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=Rwuq32avt18rSkWA7/JT7CKrN0qUNBlcSTis+msHENE=; b=WXvTKVFskklq1Cz6MMoxC9vBQGd99XZxHYuplyd6qkYKVZEjx4NNCr3nOZpRJMHBZ7 lw3tKIgqy/9f0GFd4TwRVwj18BvosGk8Uk6xkkyUOAVQ14gz818PzfRKvq7PQqFA3E6w Lisc/+l2p8CfZ6AH6ANBMxgF3jh7XbcZ738BGvQgGhbcsBY5kZKOa89/hafksBiJA3Pl HYVCpHfbypxIjbgvvX8HvG9x2FrJVSfE17fRLLVySz+QZ0mECXEQHQ3tNOOe02yoLw2k cbJzWiNSNeEmAKLV3Z4K1Hwq8exzOgS7thYAVpKgsZo1bykCR1SJKT/xv+g+SOJxSajy i5zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810221; x=1778415021; 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=Rwuq32avt18rSkWA7/JT7CKrN0qUNBlcSTis+msHENE=; b=DNIjqyUQgGRL53gKXO1X9NMWipWD5+OvI3K3s/9Y/mkJYFfNCje//+itlYii7/HZG2 B5lDUYkjmzeJi5Zxn9Be+R+IiRYf1rkOwhKapIaXozec18pPH+LMtBo4jmJr8pkmnuAz gszV+t2tjwtSu20ZVG6O6iF8rj/JfW+1Cl7kTRH1PFUPynd9JKaM4cNDbjiAHX3pXT7l XCCCcJnrpKn7EKy7ALmnSvdujaqnOUPNSr5ycmxLJnKMZB7yZSGGfWcac10ebioEUpCE 1zFTLuUPKrzdnurNzyAOc9e47oM9fBn48J6iLayDkcxFI+jxZKWDw+xy/B7yX+v4CJlp wm2g== X-Forwarded-Encrypted: i=1; AFNElJ+0xRg28lpYHA2C/+D+g6ST7mzvJPCHT+G8nPwcRxRWG518gtoR6kOcqo9I8zjApNwepACCE2juIJWlXyo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9IzoUxJR6XCT3747rD1GYKPbv29bterQKt7OOlBeOPhxAENoH 65Abbn0gaTich8HFR8jLQ1lx75HFJcJb58b9iDJu0fQZ0OeyU0Qfjtpx X-Gm-Gg: AeBDietqw0B/8VBQ/i+QLFUQ1iQYS+O1Oelw/D87lNCm1IZsyYLkvxjxtRNkntlBXAN bYsydXFkdA61V5WVSSsbeAKS71b0cfPCcvZZ10paHo+7DWX9fghoh+t8sWgP7SpPmIdUZWFWKZo xs8Rff3gHZweBPptxC7NQ/U7W3TqJ5zHh08mVYwVBD1k4Se7ezNeP6Rf0D9I4k2JwMdTwwmGkCd 6/vc50ndpgZPPnVercBdR7flhcMwVRsUcbSlJif00O5MMdGryUFOp2ZKNtkCrvQMJzaEDdJ7mBb ur8yp0vIB4nrbqwDhHxPAO6znxAElKncbHOmBksFNRJzaarqj3uc2u/3Tr1Pplon71RZwJHy4Ck p/wuWhtXnLmDZZge6MtkQ0RuLYhCaaKp5vIlIkpTZ9fG4cnydswuZ68D6xtSqdCHJF5yzUbdZTX DPZASmXPLj1slVLnijWd5Q10/Qwe1uc9n7//1VFncaSEOwcECN1ZttcTJAxJJrNhbV19QJz9yIF neFcWyZgwLuSmRSuTs3yKGpR1qpQtqgZ5piS4RksHQQj/K+Gpbxx3tyu4SQgE/rNz/zZPc= X-Received: by 2002:a05:6a00:1ad0:b0:82c:9c90:54cf with SMTP id d2e1a72fcca58-8352d2d75c8mr5419894b3a.43.1777810221020; Sun, 03 May 2026 05:10:21 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:20 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Sun, 3 May 2026 17:39:32 +0530 Message-ID: <20260503120949.80292-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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. No functional change for existing users. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- 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 Sun Jun 14 04:10:29 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.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 5D820346A19 for ; Sun, 3 May 2026 12:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810228; cv=none; b=k5GtzR4edBR/PGCskCqInjIM4V/hEKru65WvYT8xzLj7/tYdGZrbuPOo+QD6AVxMexPMy/ZooF+m6RqmzwboASGImGd08tB3jGVS9siQw1NBv6KvLvZvN/oEAcOl9skiE8WZgJpyU6EaehtsBsMKnxu3UdMm7h/6C6BdnIf57kY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810228; c=relaxed/simple; bh=W7FJ/zbVP+//+ufafVTu0ETiLzypoHQU29K7UG+1ll8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4I/AoB/v1AMwKikFN7Qj+Orbg86LAUohFUeNphV1RoAhUGUYMubKRrjq9qqxmxzAaY+nH71/pBGWTnhHjbAbg6nlQBc0HssDpi4xVTzKu9zL+8hErVf84JVxy5jwB3mtZ6RIEBzYJK4/lVFPuB44ie1n/vytMok0mT5jw5ar9g= 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=Oz/GGA5e; arc=none smtp.client-ip=209.85.215.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="Oz/GGA5e" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c8173b2af32so108476a12.0 for ; Sun, 03 May 2026 05:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810227; x=1778415027; 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=HC3omfUEQuc+0UzHsrBzp98xO7QT7jZEFHNrIReAJzA=; b=Oz/GGA5e+hxY0i6vIzpTxiPJahw1J7QKMVcclvydIheAxh5b3obRRc8G97z7ahmSm6 DkzoblfSBJVykU5/fh4yPmjjqkldaMeqYQnNncHatps/rjDFb13OvHtqMMC1L9mX0MRx bMJWzy4fO22qMrl33ZsPB3FqGml+Htjfw80yvICtW4uqFAxUWT3Gh1K96+AwX/Ba8sth pN6cSajd04ySwpaWvxMFXY6NGw94AFdWzLu42mVhWhi2H6QEuBlKoIv68B0803UeSReF I4glftUUHMWma6xB83obQPMXzjhuRVJUQ1Ent3uMWUJYdrR4TEKLrO5keOYjWqa819fY sX4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810227; x=1778415027; 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=HC3omfUEQuc+0UzHsrBzp98xO7QT7jZEFHNrIReAJzA=; b=ncC9zoZ+Y0ZtjhXv/0kf8SB3oA97NpT4snfktiWk/PdtRIEq+YZZq+sCSPvZxQlSWr tSl0abgr7C1YrmtWzp+ywfm6sEZVV0gIie6delR/L7C/MhXZvWVi0AY124i4JRfMvRyf qobJZUNU3VZXGbEupc7KKyZC17VAA5eHaU8pBOI9oSS5mVXYy2tLeH4Q3r64fr8poFC7 fu0t7hHgtUuTlsI1BL+FaZebVCJsHexiF3Pq8MYwNw+rPt0v9roopclPptX9mnGpD5DN hzXLlXzA4vUIA8MYOC3ou9hr4LPy6I7rAfNSYfq/2fyrox3UYxhBqXrsHDbq+/o63EFZ wSPQ== X-Forwarded-Encrypted: i=1; AFNElJ/EGeogxiJNtb44f3NPoJDtMxCCX2/T0VahhL9icNeZ5zaSjiMEQN9g39La9UQgL238bwzVIuBDJnQBgak=@vger.kernel.org X-Gm-Message-State: AOJu0YyA5K+thrliQiif7Is8c8Rn/k8Ny3nIoUsT4hk2yC6R/meNAVRe uKlr0E368e30jl9jj3GiLCZQWhktO5aXKkrGRnpEBdQsvAiYQ2PZULWv X-Gm-Gg: AeBDieuMOMNxdHkFUpcK2Sh+kfTU7F+mQLSY+pCOz823hn5iyksBfEHDwvqGI7u+zvc e16icud9r0wwIkuRn3sAX5dWsT1prWecC/wIt+WBXdBqCZFg4K8nc9NsiPVnmdTetMXDz0QSLH6 8H89nWrxFAGxgfFKhClSj4pccCOYVbhhfQjNbtxFaWupdmAM3h30RSZbIMoA2jrMd0idz/R7SWc raQ5u6JXJgdkcc4OXMU36SsF/ZwYlnj3CyBEEPb7wrDjh6XWmQ72ibfzcBqCGm+OPtfwTiT0Ror WZmSthgtwic+i43wT81iOPyn9FsFSLsrbc60CIeO0PXvXoyHRghA5sWcnQV84ZXmSuOEQIfJhtG msdigmZtKU1RXnstG19aiJcoG2cWmzHsLGb0c9S8vNn11FVLiWk9mKfCTO9ztj2lIsyliwLNmQ8 7W/A+Ea4x2aFlvl98KiaGhv7WRgibm1VucMxa3UTEXzY5vnhe4UwCLb1MRhHlHqJAVsb7BKGSDf n33CbdoSXO5HOd3fsTiVOZW5rq7i3JRaDEIlA22uN0MIfIB2YA9feECl7+wGQSZ6WWVciU= X-Received: by 2002:a05:6a20:9147:b0:366:19e9:f43 with SMTP id adf61e73a8af0-3a7f1a7f72fmr5900257637.6.1777810226751; Sun, 03 May 2026 05:10:26 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:25 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Sun, 3 May 2026 17:39:33 +0530 Message-ID: <20260503120949.80292-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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. Keep the existing HX711-only binding extensions in earlier patches so this change is limited to the new variant. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko --- .../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 Sun Jun 14 04:10:29 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 AB8F3282F2E for ; Sun, 3 May 2026 12:10:32 +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=1777810234; cv=none; b=V2yV5oC3WlOLUNhl7bzItTyrCcye7mllEPdOqgvhkGEFMvdndjMowlpHNvsuI/ZClJCsPFr+KN+7JIJe6O+xudkW74jJ2kDxxgLbypLZvp9BpQnCSBHCt5LCMqjRFngx0LjThhkWdf+kQI1ZZdwyHgijDjezlC1yvOFDRPWxXOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810234; c=relaxed/simple; bh=ylW8n+3nBTxndY7wyyCr9T4MnyutJEvsTrv0G8YfuD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e0JrdHzRNqwQLpXQ4y04dCzV9NhiTucDYhzlINdGxNuMrS0x0j7dEkeu1AoE2N9wsswCwTfcoSRE4PDZK8dFZ7LgFp1wu3Vy9QKDx9obzW9vZZpPCnAG87gS20dogwnpOCPZtp6W+OGFBR65v+Iwi6pyk+tkn+m0spIILJiXFPE= 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=LhFYEkao; 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="LhFYEkao" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-82d0b68837aso1665697b3a.2 for ; Sun, 03 May 2026 05:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810232; x=1778415032; 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=2otTEOsDaP52zBAfyZpVIM43mGdZ41h/RQWV0sgQWtU=; b=LhFYEkaoYSg4u/kkZ5B9Mkhv31N2OrXGBiAmk9pqmxyfU4zAL4Ftv+hfKBAu2jZahs wPPNTwZBu/6USO3REqC28WSIc1+W2JNCPV/eYk7m3LyP9WtblzwMhBUUMBZm0Wxv21JA WXTpp7lKpLqKRUHz8Xb7NolSV6O72VRMhfoxjy4I4rrMw5rTfywgDH7wKrn7Z1vDYYh1 v6vpHctOgoq/MChfCnFkcrjqGEYKEjT7A11GuPZBS6M1WiLq7wRQrIorrPXzyXULNiIa pbA98urq3jzPO6Z7lg9/i0ec/5DFgm2QbXh/0oxw0DFTpQyy+XBvn/y6clbMqxPFRCrn LAfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810232; x=1778415032; 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=2otTEOsDaP52zBAfyZpVIM43mGdZ41h/RQWV0sgQWtU=; b=OkJK6lgm10/A32BwsKsYn7QA82VwmEkwNaz06hM9vPABs5rZfZmgrzgbGdhGAI4A/Y y9HHs+2GZ/p5fICX7as3WNAdKYoXTE9TxVdrONVz7SGPQG3Q6p5ME8KEu4L9YyCDYBHU wKgHe81Fi3F689D8kEoWb41DQh+akycDgmCgyXwHSWc4cClrrxDENrBacA7sGdoZKj8/ r1Z9eccA5OVLN1dCF1hx+mODdNwMd0uFaxpvOgK6RJwIlxZp4expspaezbG0Z8bpj4Ys aqq0kLsXbuMNDV7HDscS8bCUYp0f6ZR6ynIKQv2eqXfLgHGKNS5oVhVBQnBBnFzvTJjn m1Ng== X-Forwarded-Encrypted: i=1; AFNElJ8vy+EKjm/TfoNI891ka86sLX/l7rup8Zz3SKCWEDZ8Cawj/V0/efP8yoZRRk4CvDeR+2Kf5Pmwhjm21ww=@vger.kernel.org X-Gm-Message-State: AOJu0YzZFsbznDPiY8v5H3Y3KopdTJkbfsUlQ1OEcnCFmyoHDPeQSd7z 0H3QGtS4gf8FxvrFwnMn7Y0gKLByxQrLmufwUHp9vIvcqn9mRiomPe+e X-Gm-Gg: AeBDiesEivwOq97Gph7lgrSRGfY0dXf4sDDQJJ7qqPa2P7LY0FD9vzNCFn8p+pxVXfI aVwETBdFCSd7m0uRPVIbSvv8Qlhjzb93QWfcXI31QncWBk9JuJFxzHDY2HdBLTeA+WDX8XoQSnF 1HQxp29Z5eIhRIn2ldStsc0FJY14AqeYLo7MXPYC+8FUxijYJbOTqj3g3cvu8iL2t/pV8sych30 WhsPbhhlgkVGljWHSiT7o74/6hmHNEf5uUC72yWrqSmJxqwZvF139/2rSdz7QqW5h2nzDJ+o+pq puLRleLjM/wXAnraJuDoZmknc/MiTaOtC2Db1fJMJdTPiORXuRzC1BhoOSYJBjQfhhr4n8baiCI aJobtjzmRe1fJ1a5Z5kFqysIGE2mkOtn/2yEwPMTmI2YkWe94TN55BxqeIBux58IlNjOkpb9xrI apNtTLRF5ZFyzIsDY4psg7TZHniAZ4pDd1MPfw3t02GsreJ3aQh/s8ydnl/g69nE+JKTZ4YYtFz 51UmoD+uhnTPYOwookLH6mqHWm3EQG871/GDsmRPFprTRRGL9MCuIk3mQ/rfzsBdV/R4OXznQfi ceL24A== X-Received: by 2002:a05:6a00:3c8b:b0:82f:9aa:d63d with SMTP id d2e1a72fcca58-8352d345a8emr5731659b3a.49.1777810232089; Sun, 03 May 2026 05:10:32 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:31 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Sun, 3 May 2026 17:39:34 +0530 Message-ID: <20260503120949.80292-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- drivers/iio/adc/hx711.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 1db8b68a8f64..8485e18c949d 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; @@ -574,4 +575,3 @@ MODULE_AUTHOR("Andreas Klinger "); MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:hx711-gpio"); - --=20 2.43.0 From nobody Sun Jun 14 04:10:29 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 D469B3AEF46 for ; Sun, 3 May 2026 12:10:38 +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=1777810240; cv=none; b=KGqToIpyWTLvA1jSTuwhsfFIAP0vmnZM/+dBYWxP1DVXyp18x2eEbN5ESsHeMOXRwvShGl024cRwItoWVCzb2qk7CDGMNTbq79y3FPFM/2D9MUUBghjzrdRc9ywlZydBl+YpzslTbYYcC1xUAjkWsm8VcGvlVShzViIRkokyIiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810240; c=relaxed/simple; bh=P64uRrZ7ZmO3sOlQxIgx97yRzn4q043tWEzhnD3RF+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=otdMUasjR2lzjnu+3vV6Qf0oCU/LCck3VH2SJupgVVsVN/OcLxgn1w5CZfkKmCTYOGiMs0w5fyErXMEP8yJQbBokluyboeQsSVGRC153tn1UvK0Ua+pZkSqfgbACnvSFhabAsAFso3E2cSFwdW2Wm8ThC39dy3Smjb+4pXCyyp0= 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=LskTw1vr; 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="LskTw1vr" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-82f9fdfc965so1369196b3a.1 for ; Sun, 03 May 2026 05:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810238; x=1778415038; 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=RMaRNLqWzuSGKC5pBOc/ZA5KEyrFd0iuihOG00TOr+w=; b=LskTw1vrJIgEW9aVD92gG0C41aTxoX6P6SD8Fonoua7nig/yKQ60KjE0Qokk3SFCiZ n4xncuFjdkvopiSaN5rO+xQH1VtnObsczTOKBobXvCBnNppiZhMVJf/sRVsK9vuPCblV hIuQiJOLXsqxXUKNpCrbtiNSGtCnTLhp1MJUZtc1jEQlEGrZ7gYDSOzGBqAk+DMt2jlJ xnfvR6T4MWBVfAu39WTaquuQh4UU0d1JaTnN1JhT5peArDHcawCHiIP/+9R08sD+KDNb ZJvZl8AU72VLtkT9u7YJ6l/Wa+FyweFaDI8GkRc2xIAZTFcX4yaiFMWbVQTo1mSD+egf cbXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810238; x=1778415038; 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=RMaRNLqWzuSGKC5pBOc/ZA5KEyrFd0iuihOG00TOr+w=; b=D5wrCjnXH0FPbcc81lywFrJEZxGRQDoPUBCAQZXge9IfGlWRBxqMfJvXxeQbOsL63y ACCSkePOzVsUYSKBf4lNuQYidy1Ar2/Tyz+AJM0Kuo6G8OPZprPEpQjD3950v4Q3Da8t fPTwssRmV4Tr/j5nYjSgj5YOBClUJM/sPLMZKFP+Wf2eDW2/pS4oFxEbIy4lSXDdSkyL IqKg7G5uqDze+eXp//wPy8lvHUCcX423ghdXYcAVZKMu+Ih62dZu2x/KHI1B2fo+mIrD 4eSeEaRrGMraSVptV4Ige/ELqQ+8JmyWTnCBUOUcgqKEyOpvyf1ynf6IRfOFmts6w9u5 VbCQ== X-Forwarded-Encrypted: i=1; AFNElJ8R2DQQ+zQqjBuYsigH+8JOrVqy8usqBzU7S6yEVyq92tLLtqvVVQzwSFWqNKn+IvPBVu6kEagua2s7Fcg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw03MtuqI3Pvp8euwCTBfuLX+e5ZaiWRMzOqj+o9fvroS+sRStw ktyrbL7Rvu3bxRcotfFJvz97HtR0TPL2BF08GWGHWpAiJn0QaubmlWAJ X-Gm-Gg: AeBDieubafqGLMzpkV+73Sos7PX8P7Qh/zYJYuB8dXdnlftHVgs7N17kFfLn0Yt4IOK q3+Zi3xIo8dugrCGyOPm/ePB1v8EmOK8peI7xBQyn+cmypKis5Vsw/lmgOSLvEQ5usFCtcJrwBu 7e99R3INeqz+wvtPqBHZTDfwy3RaGGQ19vVEm3M2EVYhXjfHCbnv/iO+An0b5TsKu74beorw0Rt EnRxr9rr+RtsGuU1lP+yWPQupH3N4o+GB72dL6t9tCJxlba03zKIWFCiGqGiy0mcKFAKS0hlZ2l nq3xq8oBEf4v6CVnBfUZLWmoS5Enu5M5vOZRsGp18DbnWzxDScUDb68jz9h8M2edXllFQ+N/8Bv MRo0ge1WWVYZx+XBU/82m01+U6LMnpMFhH725KeWSxbkeEF0ABa/q4M63aEkT0vtj1DSk8d4r5v lBD/ht6M+1j/NzcLCh4MfSLZxwA0p25rkxe0/NLE5iGicp/lxldw3mLtzGHn1FSgUA3ZA+lCs18 Zng+IWntcGZO1M/6b/T4qGYInBSKBQkN0nlf8Wfi9W5c1Y+12Z+iXiXrOhtJTOSGE+By2Q= X-Received: by 2002:aa7:8f91:0:b0:835:3949:3c29 with SMTP id d2e1a72fcca58-83539494429mr2685123b3a.23.1777810238087; Sun, 03 May 2026 05:10:38 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:36 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Sun, 3 May 2026 17:39:35 +0530 Message-ID: <20260503120949.80292-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- 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 8485e18c949d..534b73fcaab8 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 + * @iio_info: IIO info ops for this variant + * @num_channels: number of entries in @channels + */ +struct hx711_chip_info { + const char *name; + const struct iio_chan_spec *channels; + const struct iio_info *iio_info; + unsigned int num_channels; +}; + 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 Sun Jun 14 04:10:29 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 D72D73AD524 for ; Sun, 3 May 2026 12:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810246; cv=none; b=eeAa7UyZtl7TDaaFbkco3yCJbm6AzUwGT24aTIeOFniSBQOeZ3/HPIkU7ETUh+jnjJxAmRYAscJhwR+jGHdVM4GdM6hrelZOQwYM4sqPM3YpmozooiCEIosYloePzFId3kDnDtba98eqU9Mojkvh9EP/tMxaOGq3Yf2YkEYMtNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810246; c=relaxed/simple; bh=5i023lPUKhimKsYF9M78AvT6vY5pZfCNtFZKwv6bJVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WGprr3l02pNbRLG1XTs8WgEcq0qdef1yBEEbpCtcXfEw7buuacicsAP7NCFTsj6wdiMH4zvJSXHG+sgvS4eFrYOvpDjVZGIdMvxXOKgLeQISiWGvwAqFdiLM5NEe8P7JATGZ7dEaOnF3svBYhRRK8E/s5tTbqdVhICwt8SeS1Ng= 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=XBNxEyo+; arc=none smtp.client-ip=209.85.210.176 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="XBNxEyo+" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8354461da74so166802b3a.1 for ; Sun, 03 May 2026 05:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810244; x=1778415044; 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=/eXI08ZZvBOZRhVvTrMA+ciVmwUlugzbu9mfoWqF/18=; b=XBNxEyo+3IHLC+MKHKhJx65Tltwsdi3YiabT1lR3GqPBfGV7Zq88BrTtGTEXKO6hnF IvohGbUnuWApjrAlJdC6sDi9n/O+JDZO30yRdfw773EXHSjzu67T1hkZgbvWg2Ksh2kH cJfBljznW6WZwkDYR6OPCriZut8VDfnodrSzf+0CXUdiz7Opo9x1NFpB4q5/OMx1mk7Q IEm2NxvwkwHINnFQSayhDB73W9+lMj3nqw/WuLt5Fw7T1Z8oLWeImwuC/oI93C9ggsWb 34URMaz3VlJ53aeA9I+rBq93lr4QvHrSUe+P8l36N3YJlilVMv5eteV0QmsCILEmEEkY 7H8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810244; x=1778415044; 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=/eXI08ZZvBOZRhVvTrMA+ciVmwUlugzbu9mfoWqF/18=; b=Sj5cjYkLf/vWBdv10a/u4WR7RiQ4xQAvWeCAU6WXBtZWk0xHNvVyZ+8b9g3ZQgrT/j olsNh0LHNf5WGBFmoCo0wYf3oczKp0htXLkbQiWwgDixPoZLncU5ledeORSyVfImi+U4 NeCTL+f4iuvSCHiHIzU9uAcV6th4JXOtiNtklkU9ZvCPwF8b71HZHJJlCN3qCgfBqQZX BK+82ti/mP7YylZzSKVE2zf6KSB+u70iJZUfFqPNy/xD/LQBZclXwfGsL8k8GzKIeJYx 2jioaN5hBRiwFzKrXtf+cQh1gzWRLCGPPLZNwWvd6gkDtbjsSjtYJdFUN4FWgzqKImQQ lzKg== X-Forwarded-Encrypted: i=1; AFNElJ/9F9VTP05hRmjJX/zH5xI7At6IaJQrQ0z+BfAxAbOB7NBdE5jPt7NFfrAebW5R6QtBB2JvK1wlWb1MJpc=@vger.kernel.org X-Gm-Message-State: AOJu0YxtDmr9CQVbUuF7jjqUfOJQOo5FDMzP4nA5S+ZEJBVtOTGP7pVP teseH47xoZCAv01eX8BC044Nzn+ZmGTOBwmdEHFmkRIf9cJriEmNcN6P X-Gm-Gg: AeBDiesCulUNlRamks+HYgVlyTL2At11TY9C56lGe36fFQsmg2P8m6RMY8+GMFq9bQf zZtpxvfKvv4EDGYyuR7kwWuby8byUqVPxSfTIDeyJ9O58ZJaCB8j2l7lfbLdnVuST3D39M1atyN TMpcRPeDrJt4Y81RUpzmxXlj0Xed9tenmjHhra/EOCBWcF2HacMln+0Ir579XQzcL2f3kQ6Mdlq H32DsEcq/XCPwQ3MVflcmwbwtBEJ3omEPsBWQ34zO8mrVTV1/Z1hbOQyDFoa3/D288YknAIzxfG Bdy67EYGPuRvgP1vMfR7zmUuzMUby1HzWpKsiHXToPSrFVinAuvGplK8WKhW42APL9+HODrkEg6 dCXp54R80Np8aXjErZjnJhURGfLwHC4Rg4Xz20PpNb4d1NjtKdxvkVi84zTCmjq0SppW40pnLwT xQwxqnuUi3+xOU/9N+mxOAE4fh0KK+o6gk2Pypk5ttSKqKTzUAPYzwDRtHPtBpCTJUBueRLwqJB jG/3tGED4lN12+StPsg/IXICM5Bu4MVUuDYzE1U1V20zSPIUNf02Jgoea45ZVmQL+jNeQezqlPH CmgRLA== X-Received: by 2002:a05:6a00:2d8b:b0:82f:776f:a78d with SMTP id d2e1a72fcca58-8352d1a68admr5782544b3a.19.1777810244142; Sun, 03 May 2026 05:10: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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:43 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Sun, 3 May 2026 17:39:36 +0530 Message-ID: <20260503120949.80292-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- 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 534b73fcaab8..637114635867 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 Sun Jun 14 04:10:29 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 214D53AEF22 for ; Sun, 3 May 2026 12:10:51 +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=1777810252; cv=none; b=a4yYfnsmDPnJrsQf1WLSdbukylcImyux8uBgVVlSJcrD+h06L65h6oAcITuaUOFd0wQqPdZqll47f1wzOd2vZ2Hfud250HpH7JdoZGcK+iOgRHRtVf8pVMg1ndRXWHgDGscN22cqXadljDJ5D+XvFU782UecuT/YHq38mZqo0yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810252; c=relaxed/simple; bh=OvByowY5AkD+6XxbWpU7e3CK9GMCI7JhmFpONYFhBxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uAOe1bgho9JKCZmh8h+H36ofVGRk6HDyDpmk+Hz2/u2Lv3YePQcC6/nbmxWkhg+uO+IfUxxXc/UgYwR8cjbfMzcrbzNCEspoOHRQ8LhuTvVrGoi1ujh9+8FTzfTFyqueZTUNNgrKMbdsObnBruSMlwTnQZdWqVWWoNZQ7UkZ5z0= 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=tNprjW3K; 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="tNprjW3K" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82f9fdfc965so1369233b3a.1 for ; Sun, 03 May 2026 05:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810250; x=1778415050; 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=uZXP+KkBGD3rO/JBi4lfVCJXw9tpw0NHQd9gpIHkSxI=; b=tNprjW3KZ21ZYjAEKBrmlAtYf1NUcn85zyCIuc9s1T/SHBaG1+aZnkXTg/jPSk8aa1 BFTrOWFG8UvNDq2Pfg6Nbkrclgdv5ktonsDnkelpjmdviKflnFbzIGdyuIrsFXbcfb3D 5FisoKMsvm146Q9xyqQXoxNMODpLNKH1a/Wq9Cz6Mns0tB9iiKAx0AOR4CDg+Lh21u7g K9DD4+ZMcNZHVwQlkEOzPs01lKW+ddhBgTnADsDAC2kEbVExfCtFTAnDwfDcfk6UcRT/ W07H1xRTA823L7UNlJFlmX7U0ZZkzAe8pXOACzt8NUNAst45oI5sGADJa0/V4Vk1w+lC cwOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810250; x=1778415050; 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=uZXP+KkBGD3rO/JBi4lfVCJXw9tpw0NHQd9gpIHkSxI=; b=huw6gAeZjxkmB/lRldc2yB0Tm3n74ryq1ZvavXOzDcAml4Hm/XP7jxBm+kbbhZ39zN X003+UL5xWIXxxe36Fk8XaFH/9KcmEKKbskEJkBuzYreslegCavl0iQGbrGXYSljIrdm QEA8+1eNBtGLvXYz7uwb5uIpyvOAeH6JsNax+gg3QuhpbWsVWpcfNP46pPcOwSB7UNLt frqYLacAX2ZVl5hzmsgq4zdQYziLHfmf/nzmnfLFA187tsmXIJh5vk4J5B1mA8hfApQ5 dIzSlciOtuY/4NihvLqOI3gGQ5sNfCFb11QlkjlxHMwF8G4YcPz9z2KLPYuvx9fXTGVZ bexw== X-Forwarded-Encrypted: i=1; AFNElJ8Fhf8uF3lQHdrgyb3uBkn+6674py/+YRtkdz/mepDqbYMdGsiJ2gyCz4XjBB/MEq4jNcTKqpB7KzNiC60=@vger.kernel.org X-Gm-Message-State: AOJu0YxkOBFL/+ZhZpR/6FkbZqF/jRniNAYBd6EansRcRtd7v2gt5F2I wnw6s1iFn1is+8NwJCip5GpWbEgF9BnvvIfgR/3X1V48xCG2M3n7T5K/ X-Gm-Gg: AeBDietWIkIwIu5Ao1Nd30uc3zB9nt5vob9hRbCRVs+FPROIFCvkfTUFG81YhrTg2aK DY0PYMldMyA9m4qWBrPI9Bc3hGxFke9vFM/Kf2cLKw2NtymkphyLudq2d+wCxDUdPaTHFWn6iNL Tn2gje+g4TeKHJRjMuaUE4r99KUME/zDvJjcwshWyC3425lVrtbBdXR+Cpbc0cpS5zxnYl/rg0o yWMgTMkVmjytaRIGKx/+cQpat5RO/QFeGEn0AMmdH76ia2ExaTbCokDsL93c1pppwZ1F/4+CGGV 2Spfj3b0s4IBhTyHRVbyLDmxjuVJFZVbtEU3g7sE+5ufpl6eIAr0fZCkJxtxnSFLIGzKZmnZWnZ 1vlFW1sSfjhRmQ9fvl5FclY+KYYX2eXzs8n0KJ9mdVchutQkmwphwuMdEr4jz4SAvHU87H4MHLJ mU4lEB3x44NYbKXthSpj6h9UGzDasXdBIA+NuFdmwF99ZPEydKTiiubYdJ5rEzCfAAqQt4gPeGP 0lO8oF6iokOl+P1vMPQmOOymYaVL0ABzTGKW9zuEIyF4GqurIelDokPY4mWUhJnQOgtizo= X-Received: by 2002:a05:6a00:4b4f:b0:833:2398:cde2 with SMTP id d2e1a72fcca58-8352d29aa43mr5125855b3a.43.1777810250423; Sun, 03 May 2026 05:10:50 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:49 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Date: Sun, 3 May 2026 17:39:37 +0530 Message-ID: <20260503120949.80292-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- drivers/iio/adc/hx711.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 637114635867..b2de8db285b2 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -159,7 +159,9 @@ static int hx711_read(struct hx711_data *hx711_data, in= t trailing_pulses) { int i, ret; int value =3D 0; - int val =3D gpiod_get_value(hx711_data->gpiod_dout); + int val; + + val =3D gpiod_get_value(hx711_data->gpiod_dout); =20 /* we double check if it's really down */ if (val) @@ -204,7 +206,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 Sun Jun 14 04:10:29 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 735263AEF46 for ; Sun, 3 May 2026 12:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810258; cv=none; b=F6bLnosxaWGzmohIxBPRQX4Tg0SewKLlo/iFmqTTjuHOUybKoUmZ1fzlfP2JgiZ4apXwl08ydRxhaBOiJEV7PUb97KjU2W6FcQHuFUBD5boZRCmJXZN7V3PqjrDrr3sGkxeQQO94qGkYz65cTD7BO4LQCOcU+qUNYf25e7xP3sQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810258; c=relaxed/simple; bh=fUCNzLF6hh2hm98jxnInINrsJoaAkfZjloF5s1Y/pQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FNNehEJwI+YtjU3LwPYyi5br22bdcw7u6KFq1SDgytPVUcbKN+zSAI6fDzCgRXbYuMC+oQUVnjT67BNAW+oGGS/n7rdspOvWeiLE2bNNuMf0lBPccAfn312YIrudjGOsIFEdVnyboO/dDFsLnUs8T062WW7/kgGi3F+chkpVcqE= 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=YmjGObDy; arc=none smtp.client-ip=209.85.210.181 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="YmjGObDy" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8296d553142so2158985b3a.3 for ; Sun, 03 May 2026 05:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810257; x=1778415057; 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=waD4kNs+jxUcqAUe2S1xeZGYlwFNHw9AH2tNe0Qph1s=; b=YmjGObDygcaFEDSpIYEkvtsny8r+1trqmgsUGqo6czWsfaHM0oiduZH/OvDXNt7tXd +AFvAoye8ckGtXy2JGtl1hIZ/m+gUIwMUtFswLAqHQTMaZjSBkUqfyv41NQ6wMM4ACJ4 7dY3EYrXcZ8mIszpHfjBs0MMtryQ0Gd7BVrT8dzMLGxvFvqsEHamwAh5yofjtJIdkOrz QDG57iQvYUKcIedFBFhj7j8UNdMZzdp1mOLC5z+XtobeEEG0WfvHGU+TYuNv+dwUgvHV wIilC6a4IpflQY2zgdMIuqdhLYlPcPbZKHrdBntZ5IICTHkH4lg8Dba7T+DC8aOiLv8C RvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810257; x=1778415057; 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=waD4kNs+jxUcqAUe2S1xeZGYlwFNHw9AH2tNe0Qph1s=; b=It0lXrQNdrgETh9hvJh7SbQVMbrtWaVm4WhfEcC/IZY7VIZTTL3PZPY5/hwXbbiTc0 itncWfM0aQJkoOMIpRwrKjtoyzWQDZIR5iwAgZqa+n40UvrSaF5k6ErTAc7T8ZrkYghy olbF6HqXb8PP1oQq5d20BiggmAven1eJqtM1c8FzxaGeNg0aCtkRpIEu5stGFwW6GiUP B6UAGLYget7TlESzwx7yFb5XUi3T5OpgWg6oY6lzwpT2AjIFSm9bOspF2C13KRTPc9Nm IE+XpWcuEjiDZiVNQ05Dj00FFLCUy+Q8Cut9YfnyxTFIc48d+CrGnGrNzYmlAXioAjiN Rekw== X-Forwarded-Encrypted: i=1; AFNElJ+1VwheCgABmD4uB4JijiqMq6LXXDGB8QJXdKq5Fg0SPae6QjEmYtzf8SO80xy/UqotCq/BMVGCVDTCYtc=@vger.kernel.org X-Gm-Message-State: AOJu0YxlxoCp/9tHnPGOhtfSBj3bx39M+FzoLt9P1+X8itluTZ44TKfC tgHlVCU4nzNUk8HoGH8oBHyLG8yRoM5GHZnGBy56bJfTEbNYzU0OSAZG X-Gm-Gg: AeBDieu3R8D0SvPrePE83/0VB0pt3jEbAhYSZGlzVeOm8wSf04kCau2ABBrjadP8meD YuYbiSgBz1oCBFYUfaaqMpTH/TYw+vYbOTFeLd1TIOPfEXHZuQrHW9iNmIV3NvflJarb4QbjWhS N1vRwzIauRDJVCgHuNlozZV+Y5nr9MPHy2i8qI2QQcEzkWiytC/vM0l1pb2VzjvAQkEpQ2sShCM sCCp2qFmB1g4WfVWRqGOCQ5R5Aq1CbdxywefPr2f54iK7yEUBS9nrjLMn61PiUIpJDOgGmqVPfJ 500aJQ5Wg8uKrbv0jmQvDaV3st/kI2YELOku8/HRuCstqzH5FZaWQCLD3gkc4d6VG8EYwWacYcx 7En8lFKnH+JxWee6M3/fIzguh+XvtLZ6ZidyVmqwdJPA1TggfFUAy8rH3hamQOaJRSdi/gxscNW R3A1n7CIzgq4RGutrqXDuPgvyCO+88GTABe1exMJh0/iYUpxZS0mgfojvdfJqJK6WTinh1U/YC0 nAVXtDI3d0PLEYqpC/S5gVu+EAh7xY8swMJLwEnJUrtr/zTIDub/mrRPxSSBKWBAg4SnkA= X-Received: by 2002:a05:6a00:1c8f:b0:81f:ac81:d597 with SMTP id d2e1a72fcca58-8352ce0d953mr5364067b3a.0.1777810256823; Sun, 03 May 2026 05:10:56 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:10:56 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 09/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Sun, 3 May 2026 17:39:38 +0530 Message-ID: <20260503120949.80292-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- drivers/iio/adc/hx711.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index b2de8db285b2..98fb617ea32b 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -24,6 +24,7 @@ #include =20 /* gain to pulse and scale conversion */ +#define HX711_DATA_BITS 24 #define HX711_GAIN_MAX 3 #define HX711_RESET_GAIN 128 =20 @@ -157,9 +158,9 @@ 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 val =3D gpiod_get_value(hx711_data->gpiod_dout); =20 @@ -167,7 +168,7 @@ static int hx711_read(struct hx711_data *hx711_data, in= t trailing_pulses) 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) @@ -176,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 Sun Jun 14 04:10:29 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 E133D3AEF22 for ; Sun, 3 May 2026 12:11:03 +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=1777810265; cv=none; b=U4Dd/7nD3Z09jDqbEEmLJf6pXPXoKZcRh9D++wc2Csfui8DeYRsy/GcZr9cSjf5L199VBIVPIFAhwm5rVS7+E0KdgO3UeGYEK9/Newvy9Uc4DrMday1DEgYE/YukX+zj6gBK/AFDt1FdVrnAzsxVJNmSIsyLPcfWxDx22RSavZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810265; c=relaxed/simple; bh=/K/3q3bdgdjW52cOpPc+Q8cdwQV9c4yCPujfH8pkPjw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hFdBonda7A1YTa6kHDbkX/p8Gbav3CB74zZxQEZSFz0jGro9h4CqlfwuL27ORwqkidaqeIUa+Tj1yCQiDOADfG9sbgFuJDVpGWh43Z/s4nlP4RUkKYrk5Vhneqz0FOyZLDi5euc675UZRbjlMZZsh0KvaOhp/dvTuLxe0vIVx8k= 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=oXhGpm6o; 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="oXhGpm6o" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-835386ff122so619350b3a.3 for ; Sun, 03 May 2026 05:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810263; x=1778415063; 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=x5ZGcDGIV6eBL2tESEp+bhDpn4nj603SMEnwICOMNYo=; b=oXhGpm6oXF5feMLzzVeKTwz/EejoG5QHDfIeaGOq3DzDxaM8CtE2T0m8V97MNA8qt+ gG9t2nT+jca5e5zOrwidduDPYo5879hE4Ha9hslh78HzGCKydOFtktwCvn1p1s83esiJ GlAcubNy3y+a212O6En3DZDHWNZM+EWIrx19S0wewoXYPPipFtq6Uaoq3Ua49GGV+Zlj IPJfHtiqhu4lzKf4vzeeymT7NK9WY7VsPsskns4dYxNR7YZmyesKEvmvL5S752RyC0z4 rt47FCeUMYcHABKETZGd/ajMtgsv+M7Sb4JnJrEweqAbRlMiqitxVIwLaMiBFtRGB2E5 cd+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810263; x=1778415063; 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=x5ZGcDGIV6eBL2tESEp+bhDpn4nj603SMEnwICOMNYo=; b=Nqhi7qwAILoEeE9FFyNS7NWoabeGHNsLWTSdbKAhgtmFRn9H/GMEeVlt9Nf40yWu3U TWqHHY8lTSdM6hZdQy1qoSOsJIZkA/zZrsvTGcHmZbnwYeRw4qWQgqSWTb1Tg2EFhthN 3I8Iii/8pOI833zxG/Mv2YOJswUecps0U0KEE/CP4UwlJ5w7M/14ZjjgXCAaZpNh0tvq CQqIL61whAsiBxpabdGQ1KImM6LWGb1/48ciZd6eTD/oD6dg1nfLdaz1QEilpVkULwlG x8UcRxTVJpGbH34IaPx1QgI7Msuogvrqs6fgmUePjPw/ncewfLFgtSUEMJUYosmxrfxd Wcew== X-Forwarded-Encrypted: i=1; AFNElJ9pu6IQt+0Uxu5FJIr7v3IvZQAp1/2+U61XNh2TV8g609gZaaHD8lIWfeWYEvAV1qV7lGWwe8033c2dykc=@vger.kernel.org X-Gm-Message-State: AOJu0YyX4aQfICThzRfH2+25CRkBQ8Jlk5G3Nzs8Lafcy4McjPoMtgOq ZR0qrS9Nsthjwv7PA7pONFqXBFKL/glmdxkU3/RtX8HlvCaZuY6ob/QM X-Gm-Gg: AeBDieuLMthDNHUQkJcwp4vzeyOqPXQZT/yvGIl9r0ojBS97EiJccVkeWg3LUoJMjna tmeIjjI1hzkNFZedq4svy7vmrAYcIQUZRfQfd5FCYvKac6Y3/zs9qDCeKmVI1x260A5OfackFHv o/Tl94wHQevIp25+cahbKAAC3VAoStHECb00qsgslkn2OH+GCL7Ozmzc3e1SCLtQOwbNEBnFpfN LnwjcZyY5/6GTg+BOOJ0K5gpiQ7U721qN6yj12Fdj6x7SLhWmwpF0I10C8lTAx9FKAQ9f9HDDW8 im+zAkfmOJwB6LE8JuEd5RKgtQ601d8aOFznuXW9EHH9OVCY8uJmWizO21xu3Qe3ZjAABXIzp58 sUujSXdNFLvb3ysAlniuJJ050COYGNwLA/TxJEC8NhvzVekF+uxGFRJZ7RqTZSprXYieQGkzoC3 sFF+/+HbvGXMgIMlsPRxjXrPvec5JZnN3nJ8lgbX/iJ7vAmApPyUpWWTAEmFgbaNgSI9QuIVQCU gAZlM3D8Vrwf5sC3L0ctgfpGIpjqIWRn6V+fg9jlH1YOP74WRg1CLp6IlGWK/PIsngV2cE= X-Received: by 2002:a05:6a00:ab89:b0:82f:b5:8044 with SMTP id d2e1a72fcca58-8352d01357dmr6334200b3a.6.1777810263201; Sun, 03 May 2026 05:11:03 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:11:02 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Sun, 3 May 2026 17:39:39 +0530 Message-ID: <20260503120949.80292-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- drivers/iio/adc/hx711.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 98fb617ea32b..2229df17f350 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -269,7 +269,22 @@ 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 +298,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 +315,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 +405,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 Sun Jun 14 04:10:29 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 E642D3AE6FA for ; Sun, 3 May 2026 12:11:12 +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=1777810274; cv=none; b=HqSTQki4dOPrh/8PFmnlBw5/QSrmpDdWSOjEAIb0MmSStlkBJck22BhygfPaYErcvrPJTejRwlgmY5D62mLpGY5YOVCmdbl1pS2+VuZQY1Yeobwa2n5/4/wNx6MyCHkcRG2/skb3moCRz+1mEvfZ0KHpDht1rhMu2lAfbFd1Gqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810274; c=relaxed/simple; bh=N82Yi/e7uUe+pLWe5IjlXgxLwWAl3x++VD8GG3fQv1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r+LZ0Ps9iLm4qUcI88i3gWVjOx5XnCSzXqRpToGksje1L0KAYui+cFwzczab1gpp3HOQcwmT1wcfYZbIxVb9T6cYV4kNZHM+EnGSisBb7l1jfyzozlJsdgTGn4nFd7JHwX47hOej1/1vgDyg8VKItPC2O/fewh9EfXSc25pf/jM= 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=YLOE603a; 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="YLOE603a" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8353c9f24d2so346820b3a.3 for ; Sun, 03 May 2026 05:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777810272; x=1778415072; 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=Y8dA9hQTpudJ+CMWQF2MubPcmNSnd9Pje7EvUY+7Oyo=; b=YLOE603aj/a+EmhIPzK9q8w/+Jrwb1B5UpYeRh0FYZhIP7I9U7yor4+au8VqXSt/85 t0jqYqn6mJ+M3HCXyDPAv2sS3ydG5N4JkZHF6z7BJTqkZdVyM1YJEHqTWjeoJdutq1Rd Qy6pscBJOURhbrejsyc021ZlYRIxpelgSIzgo16Bsl/a3KL8otajdy3HPL2RWs0WHQbe k1gUs74jlZ8kXlKEB7ZcHHleyIbKhzinXyeWlCx8daeG/V09FclcRQOMRWDImG7EWrMT PfKqFLZYh8XbCGv8IQNgChBKQWcHwzVdm6VXRQQJ6ZhiLsE8MbVbY3nEvewKx3xTviac Y8Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777810272; x=1778415072; 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=Y8dA9hQTpudJ+CMWQF2MubPcmNSnd9Pje7EvUY+7Oyo=; b=LspprKj5k7Y4/loKL7rY3dO5jYYq7XlTzsOEn7N/eR8MrqV78Tz3IW+lmCiUGpXJ1m mLmr52wjUJPno81Ia0laNWTc5RrIQbT0MQ/uH7/VgczKpVVQWSIamR06Uek7SFd2XQhD G3rhXs+gIz3IVBGsfMT53k1/DvWZTvwRmLgA4pKqIXrADomC8coZeZiwXRQD2yym0yms HK1l4Uc6Boicef1Apj4jS5ZkOeAmbmR8fX0PWa2vgSrRf7QDWIrqpuHgBL0xyotHPY/d ykbuGB8/1jq28DOv1dO+H0wpIAQWVxiJtWbm3o2vBXDeoTLT1YoMfsploBITAAkv2VXc OLMg== X-Forwarded-Encrypted: i=1; AFNElJ8rKy+G5DXJ0nEBDSmGdioeK7ZWoUnwuVUlr/lHqBE85GnHbXfWd42LQ0v2yp56TMdVRAEg4IkXT3nbScg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7znGXMd7vPTq6G0fszFVmVORvpxUTQqlchDIZwLmZsKWfiL/B SbZ1Zzd2zNhrbov3fqlgSEgG8EKb/GF8xV0nCqv1ZgfxpSvpYfwFVFI9 X-Gm-Gg: AeBDiesH/9FMNDsUG83vffkt//asEbekfiTJPc9z9TIJQ8LZ06YMQUWIZphOYvVwILW IjvOxWDddg4I4/y6JmRlfWn/lLFtc3ukVPfDzJhTzMWHCW3sUU2r/51N7BhpiyD7aVSXzRFLols HncaX/qG20+2PWsCN06HvzxxZTg91pr1TcvV/nmxUzoPJEqZTrnjT4Fxa/fqr1uAP95Cg86EJFs zEXnUXmGDnsWKyYkf5J/6I0dGcmNdQimxVV2XjKO3cs/PVApHADYJIo/jsvRQOAZOyATPYfTm5t ZHhkcGdGASGDSmH6rOA5Fydn6x66WsQPUIo6bqsN3t8TiGgr3LRGYKdXaR7/7UAk+Zw6kwdQoGo TqvU+tjMWl+iPTnXqCXppn877qd+oSFP7W/Hijm0kwzPI1Mcska7eWaIii4WNnd8DIks07loCvV Fx8XV2Z0huzvPXxxPvGOlfzpW/SSrwsLEaHACSGEXorJdA82+ge9vRCVSXcSNhnm1oSFSsxc6oR qtGCs2lTU/4l0vnG7u/2YpJ6t3enyqOFNDzVauW2JtAzzat8T14+6Z3HTHMO8CrhuFIgEQ= X-Received: by 2002:a05:6a00:80e:b0:82f:b519:a5d0 with SMTP id d2e1a72fcca58-8352d24d68emr5786337b3a.39.1777810272216; Sun, 03 May 2026 05:11:12 -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-8357c4f4530sm1474364b3a.9.2026.05.03.05.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 05:11:11 -0700 (PDT) From: Piyush Patle To: Andreas Klinger , Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 11/11] iio: adc: hx711: add support for HX710B Date: Sun, 3 May 2026 17:39:40 +0530 Message-ID: <20260503120949.80292-12-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260503120949.80292-1-piyushpatle228@gmail.com> References: <20260503120949.80292-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 --- drivers/iio/adc/Kconfig | 8 +- drivers/iio/adc/hx711.c | 173 +++++++++++++++++++++++++++++++++++----- 2 files changed, 157 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 60038ae8dfc4..09a1b29fbd9c 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -784,13 +784,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 2229df17f350..521244bd6a7b 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,7 @@ #include #include #include +#include #include #include #include @@ -83,12 +84,16 @@ static int hx711_get_scale_to_gain(const int *gain_scal= e, int scale) * @channels: channel specification array * @iio_info: IIO info ops for this variant * @num_channels: number of entries in @channels + * @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; const struct iio_info *iio_info; unsigned int num_channels; + unsigned int fixed_gain_val; + bool has_fixed_gain; }; =20 struct hx711_data { @@ -98,14 +103,16 @@ 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 */ const struct hx711_chip_info *chip_info; struct mutex lock; /* * triggered buffer - * 2x32-bit channel + 64-bit naturally aligned timestamp + * up to 3x32-bit channels + pad + 64-bit naturally aligned timestamp */ struct { - u32 channel[2]; + u32 channel[3]; + u32 pad; aligned_s64 timestamp; } buffer; /* @@ -207,6 +214,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 +235,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; @@ -283,9 +294,36 @@ static int hx711_set_hx711_channel(struct hx711_data *= hx711_data, return 0; } =20 +/* + * Switch the HX710B to the requested channel for the next conversion. + * chan->address holds the trailing pulse count (Table 3 in datasheet). + * channel_set is updated only after both reads succeed. + */ +static int hx711_set_hx710b_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + int ret; + + if (hx711_data->channel_set =3D=3D chan->channel) + return 0; + + ret =3D hx711_read(hx711_data, chan->address); + if (ret < 0) + return ret; + + ret =3D hx711_wait_for_ready(hx711_data); + if (ret) + return ret; + + hx711_data->channel_set =3D chan->channel; + + 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 @@ -298,9 +336,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 chan->address; + } 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); } @@ -462,6 +507,10 @@ static const struct iio_info hx711_iio_info =3D { .attrs =3D &hx711_attribute_group, }; =20 +static const struct iio_info hx710b_iio_info =3D { + .read_raw =3D hx711_read_raw, +}; + static const struct iio_chan_spec hx711_chan_spec[] =3D { { .type =3D IIO_VOLTAGE, @@ -494,6 +543,68 @@ 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 -> channel 0 + * 26 pulses (2 trailing): DVDD-AVDD supply monitor, 40 SPS -> channel 2 + * 27 pulses (3 trailing): differential input, 40 SPS -> channel 3 + * .address stores the trailing pulse count for hx711_set_hx710b_channel(). + * Channel 2 is used for the supply monitor to avoid aliasing the + * channel2 terminal of the first 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, + .address =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .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, + .address =3D 2, + .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, + }, + }, + { + .type =3D IIO_VOLTAGE, + .differential =3D 1, + .channel =3D 3, + .channel2 =3D 4, + .indexed =3D 1, + .address =3D 3, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 2, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + static const struct hx711_chip_info hx711_chip =3D { .name =3D "hx711", .channels =3D hx711_chan_spec, @@ -501,6 +612,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; @@ -543,32 +663,42 @@ 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; + } 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", @@ -607,6 +737,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 }, { } }; @@ -624,6 +755,6 @@ 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 2.43.0