From nobody Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.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 4520F3FFAB1 for ; Mon, 11 May 2026 17:44:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521443; cv=none; b=TZmisMcZsZVJAViIGKv6nbyyYJ688pLOUl81XmjBOKkkB3wKXzm5AB0vUDmkIxOvEFF2AM9AyvwtDUXMcgXg/Rox7Qew987by4n7gpCCoakvOIBZ9/fJ49gzXkKtY0Ha1eB3pY0sotHZnfx8mLjYxDHAx3A987FpCeZFC8k2u+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521443; c=relaxed/simple; bh=fGN8QACq5acyX3/tm53OfWk81sTlEN73wII2m7as1Oo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2+gNoquEiTilSXk7h2X6vuvpDves9Ue7VeRTc3udkiDA44OB2n0tAhLAqwLHnMvPLNG+wG0GJLT0OCaQxnwE0odQw1JwdJWsGEMkZLsiXo2sxlzwR8SWjzevaAbhTrytaSE/R0jdHdxXmCaC5n9o5yqGPNQvgVsb4PNjQFY49M= 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=HOmB2kfY; arc=none smtp.client-ip=209.85.214.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="HOmB2kfY" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2b9fcf7c91bso45645685ad.0 for ; Mon, 11 May 2026 10:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521441; x=1779126241; 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=Yf9rYDctPN9NDbaPR2RYs1zVFeB2pT+PMnoNRzcUIUM=; b=HOmB2kfY+aJKm+zAEs2E0bkKsHaWEtpH4mMPS/+/W3VTKEjQxqKNq9wmKqJXbglFEx +AaxZuc0t+PI7KN2iJkqRx3rq6YPciOI+Mk5VE9zfJlY9EmYarjN0UpJJgRcxkOxj1JX Uq78eqU0ihNCLHMV/nHDGoTyXfgrq2gKRX5S3F5pvem22rxDLavy7ENqW7AEQFZQghfg LpDR2Q/j3VdzjTJwI+XwNB9X2DcEeynxC+YitafF1iCNrmWpaBRsqHsXUWA0dBLOqh5g 6sXGLXj31F+RKlzx/IYRk3vR0RgJZu9nE28jjeY6aUk2h6YMY3MjcrHNWmC5aWe3oKxq G5oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521441; x=1779126241; 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=Yf9rYDctPN9NDbaPR2RYs1zVFeB2pT+PMnoNRzcUIUM=; b=RgpvzTSwJz0VzXHjVT6XGz4w3dkMtXKyhlaxuQSCAbXSwCyxbzoOvXXV8hOd++qwE7 nqDFqjqcrQOFSamsm1n8ZIIXAtnEYxQQ1VT5H52IwEishGOvTVLsIilHSKS2QxZ2QUwb aa8aOXE9A4PmH21MNM2wB4SJOHpRe7p7mZN4nQQTxQ9zQyCyJIAL41sD9UzlnuOn1/ZQ F/xH0I8wQnbKVdC6gcSPA6IMe+Aam95UpEASYW5Cl4uHWw2IJSxMan1Ekc5SAAVZvml1 GvGVP4K50Zzlb9HYqdz6FcG0nT43uZGy3Bdf/Mt1eFh/LCz6OSKr11Li68ure3QqrP8q 9cKw== X-Forwarded-Encrypted: i=1; AFNElJ84q/UlJRV8aJtNI9p4/MpYHX1e2GjZTZy9U2WFbKSh4N8NG5q9AesTFqkssvio6wQ/uNvKrQNv/ic5w5k=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0l3Pv7YKkxKOeDtL/NbL/twov65pItjkAIJaUS3OdjDrgW1MO 1ReM5Dajbc0GoCV32W8IzUtn9LfBKh1BCEuBU4h1BvyvjtQps3xASjYS X-Gm-Gg: Acq92OF0xf5f26K/RRTZF8h4o2pWB6en8Hcj2X3Hm2pCxqlhzzpnLu2bvB5KfOHMZvA 0dWf2487/Cz15xA5//tOOIIY5xyPfi8z3PyPVyM2cLFDxczvlVeXDyCCq+ysTdZll3XqmyaopDX FreXwLcF8GIQQZqCU+zMMvxj7ZVq89MhnaubsZy+HdI3YycHyNTBI4T2fDGY96QxQdtH+pEwKcR LmQyLHbcYaYnEnu6VHjak1FCV0P2rV7VVJMflloXkyarQoMhm67gC6N343ekuPRXjSBTx82rykJ 6iGBgW8RzqPn5qktcAeaLcudHNuKP+JYSjnoZXchVPCMorhea8HAhboHqirKBjcrOCxmMo3H5Ir Bj9Jy9M7FsMRU1Yn6ItBpHKxxVr2VQdwHdegz0FEfB45DW6+ipVv4EYdCEwsC+DYRHWbHXSnc8Z Fpy0+E9bKMbH6gxZe4IszVsw9NVbjA+ut57Uuj/2QfsxdCgPpcJSTqUsRE7yrP8nYoqibXGUKjI yR8J+p3TBiUEZGG1iRrZYj5Bp4t3HqAKgQfvWsrBJbGJ1lxCnLqz7U1OjMcVVRczKE27Rw= X-Received: by 2002:a17:902:e986:b0:2ba:df8c:11d3 with SMTP id d9443c01a7336-2badf8c1b77mr138761745ad.32.1778521440783; Mon, 11 May 2026 10:44:00 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:00 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Mon, 11 May 2026 23:13:26 +0530 Message-ID: <20260511174342.123820-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 --- .../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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.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 E84884657C8 for ; Mon, 11 May 2026 17:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521474; cv=none; b=l+tlh3ECPg27bpbPyLATFAAbPSi6NS1c0cUtBs02KJhHxRY46MCB5VN0URlfms4xUhkA2YwBM7MIHEdiLRnb7LbCK0C+JS9wuFGW2tXxcr3SShF9Ai1/4nLWCprfEzrU5xwxmnfvDTq0W0Zh1+NvBCgA5l8wDQlFBSPeTTAoOOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521474; c=relaxed/simple; bh=IVD+qBGZZ/GjO6g2hTpEXXLZnv5N5xqfsYWehpQZHzg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jbkGxwCU24OlIEfLVSKP3E4U62It6vvcagVmYJPcmqs4YBfK6xWPYlP9uFcoNDY2JKvoyJ9wVGW7i8NRwBcwb6kOO4uew/yEeUX0OsYn20mLX4BTRU2G2+nwIeqENbRyrHHLVUKVlT78t9ZtXS0cgHZqAWLgEFjY6F4+PaeqYFI= 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=J/PrB2Q6; arc=none smtp.client-ip=209.85.214.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="J/PrB2Q6" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2ba6485d219so29628795ad.3 for ; Mon, 11 May 2026 10:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521472; x=1779126272; 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=h/3wTFv2d2fAYJFYqZwFfZcPNj/IS/kHh6I2keoXaaw=; b=J/PrB2Q66jKKeMpvA5OO5OctCURTFS9gcCjig1iMjVjVk/ZT3fc+0RPgrdPhMpI3XT kUlaH1MEuhhttPkNL3C9hU7ACxm7mk17LkRcYsSng1fcjjBB97POFBx08Lq/IIXLbKsE pw+U5w6onZS5r7/GtXFYg7voMxVCcVxfIBztZ9Cy+n3wLfgtWfH24GENQdXp+8nmuJ3K /5f9HPNbRa5lyrcA8BVaafRKMjL3Y2RPys3LIQpA4MfXH5lEsSd4ogmMToD5YRRiitVP XeY9G2CJxj5ENpadt8eMU/gE3PfBsD9kynA23JG0eaQB3M2Y8EBVw30qBVbiGvehGqrL KiAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521472; x=1779126272; 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=h/3wTFv2d2fAYJFYqZwFfZcPNj/IS/kHh6I2keoXaaw=; b=Ea8xkoTqFS9jec1JCoL/wQLVVLsxpq6EHRs02Lzqr6SQ6K4MIeM4jMBj4gpfxpLXxO zMAPpitUQVKmfrH7ZlPI2Bq/DE948G3Q2CeNPmFlmXSW/JJthhWILbZkI2Z9cWXsVCoc Ow/FZRas9NK0xJOnE5dMQ/u6gABSrbq+fikWhuhGdfR755BNxwwdhC3MHSWTeRhsOkAQ 9cb6VbhR6wJbM3EUs/vn7dZ9wt8U04QWVd7kmNiIHRzUpbP92TiVaLXXvfL82UuDHupn z5Kb0RphCw7ZZW3ChuSR+rpLe6YhOmKlLHm3QrT4WZ4u5MOpWoZtUMzgtiwLaouEJn9C 2I8A== X-Forwarded-Encrypted: i=1; AFNElJ/dJHLqccHtymef19fQ6E8NNphOvMMUSMLaBmwuhbNM136QMM/2yyOF6IL1585MtO8ALGyWXvBWydidYms=@vger.kernel.org X-Gm-Message-State: AOJu0YzQM/gXKm37/88FSCAhvswSesXHLiZnZoR/2sck9/6Odn7cYdL1 ck9LHhfNoZy9trN/PTn4gDIZ4ih0B6+0w9jg68jnr/Ep5/+7YIRGEjBk X-Gm-Gg: Acq92OHy6yT9G6+hB1Mfsop9Rjnv8v13aEdjNmKxkB+/nVlOiCCcThU3PeNmiIQ/EUI j1xn7hVgk0XlfJQWazp2SfeicYsb6rQZywlo0ASpfdY0+V6v9Pw2oTf+mOVQtLB3YwZPRTtlRdv +IGR2oQO8ESkBQ5x0Ki9PQ8/FOcQJJ2RBKhAewxGhT5A9P+tGmlQ+01lEOf1/PLpvxfqv1WQkRG i96rly8otA3WKiSE9gN58C8FrjSnqHPVnwUMsI3hrKK0bVvIZAmo+GCmkjc08EkFZhiTrKu/zUh 14U/az9IsUJCcUBN3qLOTr6htnh1BkTJi+ZiI9+A8x8P/kBLPgn3lnjx6Zz9BOIgPinbeBh3JYD znRtlzpY5XTS4QL/ZRLI2VYQKxGdw41IK0Ko3+c7aEV1NU1b92OPTw6XPsUiHWOivLDBZ1a1ju1 lCt8MYtRBBa0loRXZIATwtnixbfB2lHcr5+jY4zGDc8m/N8jp3cyiJfg9Zn0t3EgDfxAnDCVarP ATT0Uuj3TFCs1wrMWerb9mXRuH7zFF16Rdft+IT/ZZodUb1vruOgpBPMvh2 X-Received: by 2002:a17:902:f78a:b0:2b2:4cd2:e16c with SMTP id d9443c01a7336-2ba798c165fmr245635655ad.20.1778521471926; Mon, 11 May 2026 10:44:31 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:31 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Mon, 11 May 2026 23:13:27 +0530 Message-ID: <20260511174342.123820-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 --- 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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 02008466B4C for ; Mon, 11 May 2026 17:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521480; cv=none; b=tTr68E4njuiW6xuPvB1+4qiWt+Mr0RoYo1GMPih9AfIuAoK6NgtmCOxQ5jWP+iMF/KEkn91ut1hZqCawC605VSoaEYqCCdwLvvM+kbi4+evSAEqvYx+rKTewRLbzKYNKk2kzFmxeeTc/arKiZzMoDMEWa6UYL+syGUeva1heVVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521480; c=relaxed/simple; bh=E6aqh8+T12bRYg/I7oKlm+pFeDSPhmjn3uy2gMkP4v8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ElZjdQquED1Dkk4dDp/ZijUZbeohgUWXWqr5YVVoE9/UCTlPQqwEhyvg15YlR+fLnQ8IX1antrUWjUuvN4Jeob9wv9VrJq20M+JHp1QrwoMTwwk9tXyqFcwbwI5tqvudRO0+dgVO9N2eP2xGKKrtcSbvei0NXMTkRM9LFsGUMTA= 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=BXlQQ0gI; arc=none smtp.client-ip=209.85.214.180 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="BXlQQ0gI" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2ba928852a5so30572535ad.1 for ; Mon, 11 May 2026 10:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521478; x=1779126278; 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=W+cPMvGUMQLb7n51EIv7e2LMS6MgRiFBSfjF2HeBPNI=; b=BXlQQ0gImDdlq7oBfZ5XKwWaRdN3KOrPjVqdiP2IoFf3Ckz2C5/Qhb1VdZqPeFNR63 JhUI74jl9T6VQwBcENLHc/+tGG47E1LHaNwSB11YIH3pHCM/nsqv6nHlAy8ftNnZxzC8 QScUPLnRAe+/Q76rgpJUeQzwTY+1icNLn5dOiBz3yrjhvEe7PrfsRzv/VyCIXmeVTBM7 HR7YYduq2J1/U2QcqgQruLgoTKuKvlH8NL27qXnXuntG48BPsAUJfr3esxYiBMzsxj/e r6IuRnxT56cvoG/wtgcWB6yJglK6ogaX3NjZkkNfRYHYx3CGdiTTcmhxNgyz8hCr2Q81 MMFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521478; x=1779126278; 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=W+cPMvGUMQLb7n51EIv7e2LMS6MgRiFBSfjF2HeBPNI=; b=LqZqH5R9lp+GVAlZZfUKIwY90ZbLoIt3roOQdCJlecMyx7CO8C6sDlJvduPsbn24M0 JXk7FrUTkgvoJw+mIFOQwnxlnBc8FgCpjf1U3Isx4A4/1/n7LkNKfX9bfkcmSP08wkzW /cyDtVtvyp1/sHjO5SLO5CYeo9etzLMK0kH6Kuv/q+PS0Z+uINp1Bx51PYD2JU2iPe/e GOOn3J6RWB44EO7pVF549/gbMQ+FxBnxXAwIQd/RqNPkXB+gab3mPHw9cukXqeML3SOh xlu39U7NI3RtrCmGNMga9j6fm7wNUKsOMfe21nTJoXohnNi8l+3dnH36pPVXuKHvDbbO 8MwQ== X-Forwarded-Encrypted: i=1; AFNElJ9q9yBB3HfFyqIUj8C7p3DgGDHd3YpgsUr6gZSoTKsCvCKzcdeE4fg7EWRy+B1kIf+GFigJeYA9/Raxg6o=@vger.kernel.org X-Gm-Message-State: AOJu0YzxOQuqCMktEZug4w5feTD7DlN5UwsCx3TFPrxM8ruaZsCcBufY TQ7FL6eYVXOTR768IIKVq6mUzZXX6/aNgeleYGYORrZe/ECI2LlZeNv4 X-Gm-Gg: Acq92OHNi+NYVBwVBuELrXddzEDPnr+9Id0t4TE4m8ENlAcNGOETnzTVL0ZPBSgJhGx 0dTf0/XbZkEF9XvfRoZ6Lrku3MKcktPjrD68wKTmx2imcIBQvoZn812d6Ebtj8hTy8q7ArqKCVU 3s535U8ufmIoCzAh51WQ0y+rTrZ/7tudXCx1oT6nvF6rqFjSvKRR0QZeMOJ34ajigVfdk8Mt03D KL2jWb0LClJQ3pJBDLHX3qwZhZc3iVBwusmOffDCUU12zjIM+rBVf4G1Qe58GBDBdbCvzZY2kFk txx8CM3QPfOR6HAGWXTru2XjQWUSmCdzWUsUli8xT0p+cfqB4WNKFYRwWzgiF9GDfThLUQaSWzj 2F3zPNsFUIXDPC1SYRZ4dhKm8tRzt9Fj4sFemiWezV2nYV67Uly6gxo7N2tl+g21WcCLiuW/QoL kbqZ6H24VoMq47HBB+PgJgl2NJ5WBih5gyAyGw9eltxXGAuvDO9pFP9gR1d7D4kCoVWBJwmnKRS kPk6QbYbMuVB9VeNB/E9uY0Uh7aJCeuwHOAgMnLiTNXIJbZ2K0no4YRq03z X-Received: by 2002:a17:903:283:b0:2b2:4b4e:e4d2 with SMTP id d9443c01a7336-2bc7a9c7762mr106560255ad.15.1778521478295; Mon, 11 May 2026 10:44: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:37 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Mon, 11 May 2026 23:13:28 +0530 Message-ID: <20260511174342.123820-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 --- 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 Sat Jun 13 00:38:11 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 334DC466B7D for ; Mon, 11 May 2026 17:44:47 +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=1778521488; cv=none; b=TRjFBiQpYvPYni1UdTPCYLzoM5rfGHyFu/LCQ5IgzLf6tyErbZkK+tl5wdXZOXVsQn/DOiXf+oOrVknkJtW09sKR2oIO6nvBi7tYBa9sedungKgMEVLS+El3O5QcZKNNMxk3wpy3xlzdcqdoikUhixyB5RnPjQnDqqz4anIq0PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521488; c=relaxed/simple; bh=O6n8bbB8NeQW1Fqvhmlkdl4YSa1LzkkvTTlDYBWDtM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L2OJwX4TGAQx7AF6AKj8shSfqK7TkvTLxPcPuZoHxW8GRzpTgTGOe/MykmkaxUEAn1dW8n3kKHp5VX6hjwOUHZ2oRLgajX7PYC7mvqIteGRlnUpMkRbePZ0V5Ni3eiAxrjT2EnO2NwzyoTgJi1F+voQvEDyAQ58E1yJ/xWFPRlU= 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=NdnWIGnn; 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="NdnWIGnn" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c8027e876fcso1835624a12.1 for ; Mon, 11 May 2026 10:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521486; x=1779126286; 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=SU5v2vJdNUYCjJPIJ4muUT9VTCLXyhHjccJmI7U6Y+0=; b=NdnWIGnn2awYiQyN6LI4ygwGSjnIZ0da88v0vO/SnhMXzB39vTr578rIrtu3+VvJNi QTMiYOTvCgsCV+VWhJVXRNms4YkHGor3/bTPdhNwIEH7QAp5zRfjcmKBPzuMVM4dbn5X K9QZS3q4JMpHcv3O7PtHNSOmjhRJTWbobZayys/SRtI9y6M4DkT0UpEePAYqHi/k3VpP i18H4u6STp6iP3eiy8tomcZ1NRe8e24B5sC//BhYad2rwLOHMBJ9+17RqqYzEpmLrQv5 9I94sd+uCjbJp6SPFI3tvMYFROWV7spoF9gDGVH+fYEfLccA2MMBqlpAkrSoq95IZpSg IdSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521486; x=1779126286; 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=SU5v2vJdNUYCjJPIJ4muUT9VTCLXyhHjccJmI7U6Y+0=; b=qFGaOTv0lOdadDtF90+7RrVb5MmhI5p3d515GZ61gR6SILZs0fhUa9mIPewdv96au3 yygtMhV+KbH9pHSTnt20fOIzUFBxXRwKvGm6LasbsHl5Is3KH1GeIYfTcAI+oFWunBhm IELQZGupdpVI8wqQFiLS3xAzWOugroIcwh2eRjYQ414PJWXnhLg151nsD/2tYNnGtusN 1I40BUsw61JueJ9ykm8/iCKguxKOEWU5UKe00dXMJqwY5x02DjWGr7xts5TTZBy2gGV0 6qvS1KNB9zK6CzYBwBGcbBNG3tjfctxAcKIukeA/bblg/BLQT6sMegneqEEOkW3cj8O3 rBdA== X-Forwarded-Encrypted: i=1; AFNElJ/oPSnC0Gi9I6I+gJhW+OJFMrrMoE3YNYe546i+0vAINJ8gblcYmO0aZGi+eI5KDt0IqNwHvtWTbrfV8OQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxAIq20b1lLCBIlNfuQO9mGMt15PmetHcVmi/xF2hiNtFRCsiO8 s67iJP7pOED7KGjym81Mg7/ywtJ57uW6VyDkqcAqthacZLpFJwwu62xs X-Gm-Gg: Acq92OGp0Gz2ZBASfk0zg25VczF4Gtw5qcMNS6uL7IeUqOnX2G8sLLa0LGuMmaSdwtQ ZT7AHLtj+KRD1orkvfImZO4+L/ykyqgxFTiWitdtP/KUQZRFCsYBQx82Mt4ERxCjF+lzJWsBDio 13NdivNfSGoTG0OioOlYMKXMzexM+ylc7Oagx/UUTRL36qrmqN5Sfbb5K+wYECG+SiHVXbrmNVY 2qHFEPhiayQYh6Tgr/OYe0TZvIVGlzQTISiONs+G/3DNo3/KUkxOUgVjn+kBgaUTfimBsM5SfVo lD/zd7BOsxa+oluNo2Lc1Mk8sMEITUA9CzGrH0q3Z4VFiMdXeQ5DMaUhGwIlktv/PLS3NIC/7FV bVdVBmVM+LUhK+H1Afi/k65e0c3hlZ3GSY2wpf0RKTj1jwDGkyWAkDL+88DsVIY6cIrNAeOVey2 IVixTgXnBumDHfJvubtDEpZas/sD8IKVZDXRcW/QtuXEgZ0DqSkeE6xW41KwxNRoXfivP+7gQL2 TVm1xPUlhoea+uEatYNKhAkKHeXsAGXPU7+m0NT3I8eM9rSQ7avInClLVmj X-Received: by 2002:a17:903:1aae:b0:2b0:60db:7927 with SMTP id d9443c01a7336-2ba795bdee7mr262936595ad.28.1778521486537; Mon, 11 May 2026 10:44:46 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:46 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Mon, 11 May 2026 23:13:29 +0530 Message-ID: <20260511174342.123820-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 Acked-by: Conor Dooley --- .../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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.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 C54DD46AF1E for ; Mon, 11 May 2026 17:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521494; cv=none; b=uCeGbQV+rhuzKUTuF77XFZ90yiJEGAhucWn596CbqHy13I/07nsoSlNjSNYfNsKBVqhLEvYtIDvUeamkiODRUeN1u16uO9FCI5B+dK4PcIej4K+i21YBeLAZs+R450HU0/ZSwiS4NKvnDudsGwlfQLsmXGsFIUsGWzGSUE1M3NQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521494; c=relaxed/simple; bh=jqPYoYhLKYYlSYtUJdzENTM/X/PaYeN8NKoJ7tNg6Wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iwO/1RaXhZWJkac9+O9m6CDSsRRquzjClRyzpr1krjN7SeoawQ0QSfHQjmH1tCw++QBM8Hjdb7xfTr8k4+Kr8fyCqIwGr678QvuePAkAuX0qoOvWzetcJIMSnWh1csSX0iCSrjfq8RtsIhD0Wf+ZTM5GVTwgJvNN9a98yA9vfLk= 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=f66b8AoJ; arc=none smtp.client-ip=209.85.214.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="f66b8AoJ" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2baef9f5ecdso25547505ad.1 for ; Mon, 11 May 2026 10:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521492; x=1779126292; 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=wkXrBYxTI0izj6VrJvaEKI7ARZ6dKBgJhCCnnbAo+Vg=; b=f66b8AoJx7tb87aKdW+8k5iWW8HH75LCZTJoyff8cZ88msJWgDU+Ifv00Tf21wCSiu NBukjrY/JG360f0+Ad/MJ5TQOBvem9YIPtNlboVj4tXTaeHtznsvviWnW42TodGol28z bfDHxj6q+EykLfWP1mGFOg8KdadvIMpanmQr6dqaMyJMIFg/qDFkAB7BPtJHeeqGOdSD zNyuUuAssh++7E5K8mcXUhQAvWoEtlvCzjOeoq6ei768quFww73sZ9gl9gwgFc3RnXIw zsUU1gWW8m0nQr8Iw5gEgNPJikukqkufnk2ZVtY74hZa0YhRmr2HYywxIxGu1UJMwtly lDEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521492; x=1779126292; 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=wkXrBYxTI0izj6VrJvaEKI7ARZ6dKBgJhCCnnbAo+Vg=; b=dGtfUELJYMj2kZlkOLONNWLce5FH4Gho71VpVxoFNxt0jNmvt/be2elM1hpQk9zje5 Bixo1bfGOMrSD4f/OU3Hf/NVUTODiCMm1G42Q7ikth1RoAqZRfVZFM45NSN+2dTqUhBr Bb0wpAj5qjqkgsDFtyN2STL9m5/ojcpxFn+aSwlix8iqaaVHF2z/mYYjWZwMQhVcQ5U2 3iQFmy0IxE0ah+5gNhvPpPp9/QkKKwUdDdCKux8BL4Id8hqJ4MJeSGNG/OuibsOJBbNi OcomcBEPPFsqU+CKVXxTS6p0iYyiM0fqBaXZj7WVQrK29YTJO1D+UTuDAiAqPRQxP55R 33NA== X-Forwarded-Encrypted: i=1; AFNElJ9hKduWhYoovT80GvkArI/BfY4kqEWhiwr3SNzNZaJsZJ7OO1CiGK3ZjAlZdMZENYx4BXx2F5m4aKMBbtw=@vger.kernel.org X-Gm-Message-State: AOJu0YxCg9k1C02b1nt+BmxE7uz8FgMcLweu5xygMcDrclY22OtI7sMw hZy5R/MSzfnPBhg254T3aaHWKYrvp6B041JUkgJeWErQj4CIJXwG5Dqf X-Gm-Gg: Acq92OFZrh5FZMvJcKtiT2sZOcInlm8pRtak8H5aPf8pvBZeun8q3lbrGojcyY00DRW D8MgKHIK+WDtMtjhMKinIC4W0OPU820Up0V+YKSIBHh/ppqYs3h9t7JnQjAldyYe9gRvykZr8Uc kR4pAqQCpJdQl009DiPixh9mHuC4TjOcN5MwiG+tGybnEOKe929ebbmc/6tKUVNH9yUBr4DGT10 ku5smq+bKcmIfQPSDOWcT9Jjp1zP0bqPB0kN7Pot1lje8kSK1/Vwsy49Kuha5CPFB4i7TIujs6X o0WppncTd3u0m6K8Yxh4LokWS3yycPsNAz+X49FBiCEeeCr3/fdt9qX6LqEfy4HQ8q2nvzCmP8T K1NoEOJmsFT2gIxRg8B4HK/J5xKuA4eIxRmzBP9yWxfco+//iA3xl0NKEw1PAF2do/Egz84OWzl hX1AVhbiQEEHKoLe36JH8nOMNv5JpmwL7hlkVe/Yh9cjP6nn57JR2ZrcvHe8o8muyvGAQ+6mfoF O9nTZWcf1GQ7DAXjwgEaFBDxGedYLYvIFKZ/8cgXD2SCYnRZIBAsXcqiKUn X-Received: by 2002:a17:902:e74a:b0:2b2:9d60:5eaf with SMTP id d9443c01a7336-2bc7a97bd76mr117818805ad.6.1778521492108; Mon, 11 May 2026 10:44:52 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:51 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Mon, 11 May 2026 23:13:30 +0530 Message-ID: <20260511174342.123820-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 | 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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 51B6646AF00 for ; Mon, 11 May 2026 17:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521499; cv=none; b=YLBDOxfpFv1pofcp09TcWG/dD8QF/cbCFrnE4+/oiUerwOgdeKqqcS3Muq603P/USEcVXqX9neRCzCu8dXCwOXuxaQdEQtjOHKUInPH17ZBogOXm2bQyvv3kjFWDi5ctZjmQ1nEWpDm3jnyNZVsumW2kESUQ6yOzc2zQvm3hoS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521499; c=relaxed/simple; bh=GP/zXsIk7W/qQ+UNS2wJhazgPEjZIr5oEO/HNA2gsAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FhaFTLsRHB4YfTkR9u4AsAzZgS2IPEnf+RdJPHho3giG/tYDTlHOwahA4NqXsUHFQxvtOOm5i94gLKKxpul9jNsxxNywCKmKY+eWgDyCpwaHZiNnt9ISe6MqtE5CVajU/LyMVI7m6XfnCIAPfcOW6ofYReqn4XBwXX4UnqKIO9I= 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=hjAGoCLJ; arc=none smtp.client-ip=209.85.214.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="hjAGoCLJ" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2b9ec9443c2so30025425ad.1 for ; Mon, 11 May 2026 10:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521498; x=1779126298; 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=2d3GApoepHVx+uh3La4WWn+PmYLbQZlFvom3bYXI8VQ=; b=hjAGoCLJuEf2aGGeWU62QC2wysc3X0Sf0rehXA+tqdSXxob0PwvksRpRy7yY1UBl3l UGXhl4V6CqIpAku8z20Mo0GQFK2VLUZON8uqa8y+vzbKA2wUGGEBd16Xr1hgIEtNuo0F xPBqaNePt8Ml0mx7jqzca7kgKmxbQks0+JXF6S3RQJWnkgjkWxOi0HySk1yJR3dBOjOS XBo7tn2aKorqYTB7tMXAGh1+A9b63zq3Zw6Zl4H+5gakYjWWu+7LJIwMcQvzP0Vwsy4O TJk+WNRipPEt2rSa0ldj8ySDdNaYtwlLZmdo0KXe1wn2xUcOTXSKL84DHuG4OPnG7HmS 5ZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521498; x=1779126298; 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=2d3GApoepHVx+uh3La4WWn+PmYLbQZlFvom3bYXI8VQ=; b=csPqI6binhOTCmFbmVG1C146gyHQS6xHvxTj+LDfNqSIuRm8c9/972gXRZ4ThkZEHW 7YxKFL0eRfKHEaauaUC0qIDoaZz+auJ/Yzy7nnciPZzKNDSQ33K9xCUG1xSan5/WwoDg NMVwWrdYRVmlpEUbIGgvr6PqBg2SangNCrTetukiywX48CGWz20hGqDy9ngj38kHPzlr Ct1Rsnv/boJiUzFw7qGU5xzHk6nl8BLWk7I2MUbhc+d0kCwEvPgWT/ckNpm4PHEymp8D 55Y6Uih5X341GnuegaCz7LvgeRs69CmSFfa0XZTx904m1G7uOEjWirbLhPU+/3MY///M 64Tw== X-Forwarded-Encrypted: i=1; AFNElJ8YnRZPsWsnhWp8PezBd3fmimlMNr7m8Ftt7k6Hm8WuAKy51eIo74CrztpRvBXGzpknzIpnwFWMu54RAjs=@vger.kernel.org X-Gm-Message-State: AOJu0YyjPIyxzPOqH3IJRuJuPvTJ0Hf0O0eENivx6iK2xHug+bGYP/Vq z2hPbB+pLj07CmXZR8D34jo+pXS1XoVq3Ut1UDi+xVkApbvF42qjwhvu X-Gm-Gg: Acq92OF5mnUnn5b6+kUeYGQmqWI14C1v+qXwWrnVI+bNwbwqNFR82lj4g/vjG90qOR9 f/TScQdZ/inj3GA21tl2+wYJib86ezvxl/mlr5ziXnGwe/2Bf6CxHHOJ9+QmzlVgerY3UD2fIAV di9KrF1dmXlSnqUTVSLVZGyW88HkXRTMayWm7GhTsLHdZqnbX5rGyCtAomxE3t193OhbY4PGWM5 YeSlrmKchuExuf8g6bQxmObXvZL1jy7QK49yeOlmLMJItZf3QLN1f6trpF0IP60xrAvBG3qRLZE tQOUSncOyx9S+MspyKSFEVZLqU2WNM0oEB5e6/vORYm3f6+kLQfqAgdSOzDoC9jg4md5vpWvGir ssLmjtU0lFd+SY92T8wnujiIuF3OaA0Ywc1hUONs1ifhBGcOyJQND2OMGFciFs0LQZcx8vWAQRN A8duHAJqs/RbztuPJ7zfG4iwlBcjZwDgUUH4F42hmsFOFZ3mpkMxweuoIkTIQyLTVcr12sF6leE wRz63ziRl9ABckRzvWQkcVHb7a0eKcPoJw77PK5axrtLVEkpLQgXslC1Ezq X-Received: by 2002:a17:903:388c:b0:2ba:6601:8e3d with SMTP id d9443c01a7336-2bcfcc3d69bmr4310255ad.9.1778521497694; Mon, 11 May 2026 10:44: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:44:57 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Mon, 11 May 2026 23:13:31 +0530 Message-ID: <20260511174342.123820-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 3D8F2472798 for ; Mon, 11 May 2026 17:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521505; cv=none; b=WQ1QwrJ8QJLntJhLTfeNiLwdeFwT/MR6931LTJsSr64csHLVpV2mxKo5SyW9oFNpMqVbiY9IcQhaF4/SF+uHu2OAgnO/BDgN+u19XL9AuNDQ8+NNqBf81VYvNEQ3ju8JiSE1U3+e6o7XC/vgfl0rPdx9lNpleSNjHZUM5xBfzQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521505; c=relaxed/simple; bh=aTUwaw1cZjKNO7pd1qP0S4T7HG4+2wRyJbUWydgN08M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GKbBT3R8RkXIX9jhialW1XC4v9lcN12xE3l3qUr8xwbPWOfqXdRR7MS9CRNO/4Efj21uScFjQ83Xui+6eiHvj510RtJmweEaFMoW4b+TVZY0MLLnE+239e01Fk07Nl4XAJqLmKf9BXdpyKxTt8NqLISerzVzL4gitKz5PuZx1mM= 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=iugoT4zO; arc=none smtp.client-ip=209.85.214.180 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="iugoT4zO" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2b4583f0a1aso29684105ad.3 for ; Mon, 11 May 2026 10:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521503; x=1779126303; 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=J4zRyyXIwuf/G23ISEa4BernDl6SyQJXsQmJd0MnDOM=; b=iugoT4zOwhqoOslTvEWq6jSQPZdUlKnjUWLn9zojPyzSJM2BNwOEP0W2MTmzeGayzr qPt32qxJLKwU/pal7vstzTQBbnnPcDGqne8n9L83xHWl+535q+Xedj99DQdApNHTCB1/ 127+JD+ottbZmY+NvNYbjBM3y4XMkXZMOT4L7doO0ea8+NI/DjNYCFQ7PIpabgifRHpb GyzS66UbupAcBu5OuK/AKiR+yHOf0DEXk7L6ARN0IkC46iaO93LX0GbJM3Cn3w3cf43v zHkCEF6QUW/72hm4irBWn+zGU7hYZTH4W2WU/s3bwusC15cG4dWTfYvYOsO/ytMHjlr1 BSiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521503; x=1779126303; 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=J4zRyyXIwuf/G23ISEa4BernDl6SyQJXsQmJd0MnDOM=; b=dmmaeRDztq8Z/cLpJ8Q20teOKbU3HvLGqJvJE4qjh76lbm0OoujrIvJTqmCbmahmFq 58SG6MjJ3EErkAPoNFi5MHq/LDMOKZ/ScGKnd+RrWYjppSyGsHRAk3uxJ3OVOPYO6Hrk TXSvsGmVFXZaiEXgYat3pJ4sC+y1Noj2H2yH3Ioq6YhE1s+zoObgsB0LGnPyYlb/xuuk HrmxBB5mvHmN043ucymdKVu1yAJ9mR8ryAp8mL2YZcji2iFS3dAm1qYNgB5abw2ojTyO 1urgfPlamkcVqSN+fhQc7VRHNDCnEw5UTd+hbV9A7Ku/oCcJ7Aa8H1b45I1A+PIo5FA/ zzqw== X-Forwarded-Encrypted: i=1; AFNElJ+ZcvIyj5EP2uJeKBoqGC4nJvQoAOmjCpbPE45Q6b+jG1DEoN4EBnRX04d/N0mt2bx++Lz2Nafx65igJYQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwhodOSWoe3lKZ/QJsQKhk2rOVKiSMMx3KW1LKhXC0xRywIWiHc fvwHSYZZHvhR0x8VEog/jvohNpeE8Sb93Y2cAiLVibUYzQpXFNRjJvVw X-Gm-Gg: Acq92OGwtx/fiNE5td+f8PoZB+QzT50TEtbr4hrXzWtd1gZ2+/o80IqwliTNj/FWoIh XceGbUKArkRP1wFoORU+n8bmZiq5bZOa4ji7+InUhgreRFGYU0YYyk06IU/tFYmI3rrltKGen6h Y3jNJDmQ0sPv/qoktF/jFqZMN64AefZohMBWulcG0yqZ5ynWe66WEcCbGWNHsWhh56kLufAWZnQ ztNGGOHYuY+MQkGHqo9ge888UCoFVdP3Ug+HvVjgM5U81dwGUrn+Ggl5xigp9H/McyJkgTlsKXI xxcJfSs5Oht7kbzbjGtaSbVcr3w8+bqqy2ZEI8PwT9Ig62fgKbvryoTE97YWBTogITkr7khOP9Z EI836+DNgHQlF/NjzrGySWLVzGbs7wHxra7dHQFtZEacekmSBTS18stajHPJiSwk7oLWlSg1YPq TbT5nfrdS4omdJvDuHP8mJ3B5xIZcBUsx1QoQJTt6vNoovJFxyHpgUIpDwjV2+h3kOMpC64oZT7 p8SI1rOeEyeAxpYEQWmfbSxb0Yh3diydd1yYOF8Bm/HR35WLBEll7+FHAW4hwYokcoaJTc= X-Received: by 2002:a17:902:c946:b0:2ba:d97b:4baa with SMTP id d9443c01a7336-2bc7aa202dbmr97909805ad.20.1778521503394; Mon, 11 May 2026 10:45: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:45:02 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Mon, 11 May 2026 23:13:32 +0530 Message-ID: <20260511174342.123820-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 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 Sat Jun 13 00:38:11 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 03B2D47279F for ; Mon, 11 May 2026 17:45:09 +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=1778521511; cv=none; b=WKQmm0bdwGthuKB73IL3nCH9QgHYPXZm/bMELu/JjNuPcr3YmaClUeiWyKoVy53/1IcF7h7oGRR6c95X2op4DEWQhwEaGJtKc3Pc+uhMvc/VheeKS5ksEHhmUPqB7lSi5EsLAEXGgre+0LN/8+Sq+rcJ4OP1p3QHIDvFpA70rhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521511; c=relaxed/simple; bh=+rRs+S/GLbvYjpkwKDsmz1ERbvZm35SJtB9f3RxI0O0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rURneJNg4/w5gD3Iq+bujh89V0YLBdurLZ8wnqNORnTn4PQ+8jtw08ep4tL/zoPWQL8N0UzgVx4QfHYJitLpO8KjZtFeG7h/JdaoHv0dK0SYsA3RvyTNa44DalCT6BJb7GYlodbkMX8SsHnezs9MhW843uC84HFqeCCu7IXsqjY= 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=JBZC1dMI; 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="JBZC1dMI" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c80167f56cdso1797589a12.3 for ; Mon, 11 May 2026 10:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521509; x=1779126309; 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=YhqG9aI2ukn/g8i1UCfEdn6XwpCGaYuhsFZEF1np09M=; b=JBZC1dMI+6OsA++7jm5Y7d+5/DAvKY59w/oHQ9Rs1Nl7qLj95zl73CYUZOSuozKemh HM0gYwHDbJIiZ8P9XbD20502u1kDPB/zm/uOnnyH6/RkviuSBZpm8nZ8cbahTaCoR6xK nnVmdREKfcnRhLLi0fyMRHyuvhs1/OE2pSmySF4slsfA2GuVo5xe6oMqrQrXC+5IlcbO XM5eBrtb30fhfOzOKswm80icbBWZ0CbTByuxWghyt+FHu+D1Iqsn/tcwffdYF/5SFlpn 7H/RagVwRHTWCG4bb3hinMxzIjx8mIqfOLd0rsDGfnvUlCRCpp+jZLKPJ+SwAivxLBOG uirg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521509; x=1779126309; 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=YhqG9aI2ukn/g8i1UCfEdn6XwpCGaYuhsFZEF1np09M=; b=ep/AuZ3/z12dbrTQP2GWR0YVkVfrQYgBkttVDBbZXu0KaoQHkWytmg0BDq4FSoJIKA iWQrJMpzrb3/dkOOuL98+Vy08d1sY4uJ3pKCWyuzbeVhAQkOVz7LLx1UbNPcq2rFsRQO 2LbSOgxoVw+fEcbrE/HjeGwC55LqJyq+gUCVtMcXl2kS7L+LfRM/dyafdpKk/G1ztkhP RwDK2McxWTpIEetJ5ueQY23qIRUcJBtL87KZ20G+AYX4xP2dlEpqmgvHGYIiDKHqhO7V +CnMHH3bG3iOj5hRMD8iG0ARZp1KXzLPdPe8UkQG9exrmRM+76dd9D2MNVNyK3eaMo0m 4BXw== X-Forwarded-Encrypted: i=1; AFNElJ8aQ8IsWB2lvY7RRvxAmRF+R5m3IR3SP83llkCQnuDcuiIFVVgcQ1mKISEninUnS+C9olokv7co/fZs9wA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9n+eevFbnru0WxLJRKaHKpqujuhk5XNUsH8IkW7/bGSd3Aad4 kn8gUyIoWjY0TYwaZMWnr6+qpuHq4sYWo3v/i87wYOM6RdQYlaAuPh/B X-Gm-Gg: Acq92OHJivFNPcSjS3i8YbnJJRzT9Rd5Iqsvt1nJYWHmYkqv0HBsY/3T+BlPGsFMHnU FTsOZuZdZqdirgZDfsZP3J+YnHTp893fe3/4Is5NxdvErjm++yNFV/BF8LDq2jEHIB0TUYoGhH2 n1tikLY2L0+IghMOE+E5TEWPcg7pL89oSkXW7rlMcRhw0h2XuzJfMGIb9v6hJ+qnNd3He1S9hJx lDFGHSBVHZtHlDu0uhS1BOUb3T9+iyEmSNV/ZAnElEDS6gzQdqO3MAHnkKGt05CHlR6lVAT49kE LYorHpAOjqzG85/MuPOA15SKCOWsfbggOGaUxat6ix7pL9nHMryDmRxsV3FhrsmYpUT82wD2CZj NvrloK1kwLVnfg53AOyM1YdnPbMNH4IEK3CEV0YPoyK1XC3bQdalNagMDR+PAxZXvB97A+A98SL yQbess6gM/QaOgAQlX3AdbK4rSE7dT5eep26VZ7ydrxgNy8SxbkkJfLnOTDrCa0hnq/IvSEnCYB jZF4mKLXpamxmZW8Ig4xJl3+ZQ8GduToDweINtNGILBTuvXyaDejHamOTMm X-Received: by 2002:a17:903:3bcc:b0:2ba:4e84:976 with SMTP id d9443c01a7336-2ba78f45b67mr249352365ad.13.1778521509323; Mon, 11 May 2026 10:45: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:45:08 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Date: Mon, 11 May 2026 23:13:33 +0530 Message-ID: <20260511174342.123820-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 | 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 Sat Jun 13 00:38:11 2026 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.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 EAB69477E28 for ; Mon, 11 May 2026 17:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521517; cv=none; b=On5a9J25b59/d8twFrbIT5IMwFZQTzldACUEDN6bGtZLfEnK2MQWpmLAtFQvRF8jBADVLUysQpofS0kcLJ5DfszHVPa7zhXy4l0pvDnTy/ompzLlILV23YJPJIo1Ro8mNib2OO43LAehHrzmHXrwVO1Ofou2ZLGmwvRls4Zdp4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521517; c=relaxed/simple; bh=fC6+iF3wZIOJ9jkDKq6JyJEIBQEMNM9kicOyuc7ikR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RH+zvWun1Rvcg7yMmUXrOBhaXgaMhO/PyMt7lt1YcToq4oKmc767xw5vKHpz+Iiw+x5eTTzF3aM+tneYG53jmSFgoBdcVGwE0h/D1c3cn35cgH6o7J7AwjLXoK4yz2Zadk8LPATtZHTfbvh0GxynWP3dDHIAzN4HGxZ2/SPqEFE= 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=lKy1Ookj; arc=none smtp.client-ip=209.85.215.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="lKy1Ookj" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c8027e876fcso1835833a12.1 for ; Mon, 11 May 2026 10:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521515; x=1779126315; 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=UXBbj7mUNYlbg4rkKVQUy4THqQa8ssCmEHhDW08Rios=; b=lKy1Ookj0ytwjxknS9RLNUTP2b8a3jvMOa+T5gSV8t6jqcLLMmsLHBb9nMKgMDmAqc VbZYjcnozGjxtUWm/zKSkU4T/w3DRVzuFoK5gpCb3QOo1tjbZYBkKmmWIg5GPXRwZSYT xlmRJ5ovDcmQnhHS4/5F76p8ypN0jyRfSO7N001kmtRTMoXuX2UokJta4gtzhZmCF/xK DjIRiPBy6v3fDvRcshAr2I4MgEOWSYqWW0PS0QKQSQVeVFS04P0TH2bU7CJRK4HiFxjx qbrBSu0oOjdNl3IFQ5oYutpR+LKHXDQEtbrcFHnrhW8sZtl3UdmiVEYuAcTebFUrSTaA OK5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521515; x=1779126315; 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=UXBbj7mUNYlbg4rkKVQUy4THqQa8ssCmEHhDW08Rios=; b=BkbmQ8U13zt81rYKl8Y2/BBnan5cBcFkN+AN4OVVUr8c1DH7W+GbPrhVYqb9AbQ3pY kBG4Uk4bxgUXociuR3iAEDnouauSPJcrIVfB8MX0V3jdCmgk7zvkJRn8UVN5S/13S3H/ fnFsGh1Mat8Sh5Z8POfDyNg+CWOanc/tcnvtEXaO7vccROB3itoCoVHqEdhtCwFF7q85 IA32cek5zgfbp983KhesBW/WE9/LKMGjetlhumqt7IDd5fo7ZTsJfLhknB3Mv5BKdp0w 63xec/jn27rppyhmNr4wdRT9M2AmiNk7P9SH6fhN5TINeVsDsB5JLNrFOgobF1R5MCwU 8ooA== X-Forwarded-Encrypted: i=1; AFNElJ+4M5nKLWIgO6mIkrGaR1g/B9V7apF8aEzEsAOeMveAX1EBN63BnaglXrlXa2YBtBt9n+nN4S095Zb+gkg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6trDrT3T7d6iILVTxZHSDzsdcRRYXTWfiSQ1pSxkTWg1eNwU3 5YPxLUhkk0133AAM8LXkljNqb2aIj4xVlqNvSRB0Rg3G4UoxBX4WDspY X-Gm-Gg: Acq92OH/x5M7GVi7e2jrvm/jGjxavNoydND/tFsL9h/VU/9VTbTxNGh33YgE6D0+vsq cEZd28AWVBctVBArmxgCSN+nvbnRnk2KUIu+nLbnQTQHKzPqZel+MuO5vJa8uHs75hEwimyAHN0 eDmkYnclK+OmKApjFTXHdszBvlTTmjDY8wbeDdmlNIOVjhBlBNaVWFTdqi7WlzSbbA1S67F11ff kgwSXQktLya4SycxzYBn0vqpKKvtOYn2jXJ0RIf5Ttpvb9RDKIfq1PuCIS7lQfdgqO8vU2b1Fmw tAB7d7lNcAVUInDEdtyxVkCm+pZxINuCKPZ2wH1VKhxLZkqXpNoZBBfGkiTa04atyRNSgJGvZGS BLBHoJxIo8/Hz105qyMmH8Kjuwsa+LPZuNRZvGp7uWxQ20bUUtsa3UiD1VuJF+TUCwRZ7qXNMP9 wXSrYKNc0pJGQUbswIVSOYU5jVY6LrOyY322H+mNjJwxOWiq4509xQWMhQOL64B9MKFDtu/FDl3 AhrfK2rPJ1wf7v6t13KhZMA0rNsVrr2z2ve2BLm95NtBMq5khtocHeroiY0IpHopALb6fY= X-Received: by 2002:a17:903:2ed0:b0:2bc:b80f:677e with SMTP id d9443c01a7336-2bcb80f698bmr73240535ad.25.1778521515128; Mon, 11 May 2026 10:45: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:45:14 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 09/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Mon, 11 May 2026 23:13:34 +0530 Message-ID: <20260511174342.123820-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 | 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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 8B4AB47884D for ; Mon, 11 May 2026 17:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521524; cv=none; b=jvtRJppqplTpIMnKG38djOiX/hghuzHwDuGUyQQUbVQ/DQUCrONifwvCdrpRcoWrFxru7OOzcL8ZgWHqCuGAlXnozgQL52idn3bQDYFND7Ym97VXp6nWcEbjzLfmzu2MS04XAmGufvTgwaT4o9opinHoVD8K4juqHtEtBDE6DXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521524; c=relaxed/simple; bh=5k+SnEgwLcoE/m9oWbMPiYN8XaRjygHFU88BagKW3cQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZmLkqP/iIqBB1fzxWwC8SdIyULTtfcWp15a25jGOEFjFhDijlsSc0+LsqM6mu2tWuMQejKhFknb/OSAfwTqik32Vmnotw1r9s62jALnXG4kWFfVIGogtGHeS8VwEj2QD+7VboENatBmit7CMV6UA+wucp2kAT0cFdxuDSwOKkLM= 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=Gfu4YBdU; arc=none smtp.client-ip=209.85.214.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="Gfu4YBdU" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2ba4a1a0325so32832435ad.0 for ; Mon, 11 May 2026 10:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521521; x=1779126321; 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=beKvBN1aF04rHKZBL8DcVQubUk4t9ZmlxiCzX/vBMwk=; b=Gfu4YBdUNYV0IYPX8YornMdAkct1IB9M3kDNcc4CFcurHnR7AOQQL4dFGft9kh0fO2 Rx/Q30ziLvXjqm3vhftlpgtvXN707tuv8G1xT0hduWPVmjQ9xGD3639Sy1eOsGwhCO6a qoLsJyios/eFUxWCmqI1rXss5EINME8Ht7G9f56uHfzih5SQ9jPGG/K+BOF7X5kNZPBA ZpWandFN9jb1oizWSee6ZS70/dcVBUzBYQkQamTZrFk7hkmGJ14jkHgeN9yl+pCOs8uc DOd/0hrN9QTz4HiSxkBnmikZI3yARQwR26ITeYhw9ubIqCNTtl8hqLqmgAXUkGyd62+Z tsAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521521; x=1779126321; 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=beKvBN1aF04rHKZBL8DcVQubUk4t9ZmlxiCzX/vBMwk=; b=j4JFG8VdfmXgZSVmAzlaMQfFbiOFZGpPs84IVTkPpA/voxQRpWvXswQ2Bm12t2vU0N 8SxeQUobc37Wj47nIPc98eOQB/THHL9BThpeYvj7kXVpCgBZ7ibK4yfFTacwFcXi0Ni8 mNBUHpJ2D45HHu8WfeNtEdmBr5LOMUxaGbBEq9b7MYrm+WuTBoVJTklCCGgvctFDu0fJ 6xGLNmtmajvt0FPffwWGoo3VdtIWX17Z3Z6GUb7ltsVLnBe7i/OB3VIKgA0E+RNGL8lm HEQJDPzUy9AJRmymZYP7Qd7QOTH2K8IUtDszxwyLEowGMav+YPzXQ8EIfM4UThnTr8Er kpag== X-Forwarded-Encrypted: i=1; AFNElJ8F+EUUuWCcLOGWljgivhSjj29mtNanhv0H7hsVM2OmE1EIPBgodcWfBh5BCFjHx1sJBrZY3wV71iXQ06Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwYU9S7fQUSNhAvyjEw1ZBHtU9h9VlCj7Y6QuKuQCpHdQlaWtMG /wGYkOo9aryouDVJR3PpDOAAccPYaOqTiT4CcYTzfDiSU0bwK9MIF7QJtt4hVw== X-Gm-Gg: Acq92OF7WoDcl0Td0Uyv6+9hNAUlLmTDs5hOmbXYFkL9MD8fbhQgaNhXxewZ3skcFO1 YFtw0T4NpJG55VyIsrVV2Igen1fyjJTbOqJ15ua3RZqSSpKonfReMj9SisGusY7IA/Zbapfp9zF 2bvyaWISl3/GFjYa8/ThKxPnVKZs28TfAbqeVKO/zzs0Pfsid7C2XN6sre3CQxdsOsfz1PBcM0t lexhbpPsxtpGr9KIOr5qYXIDPCAAv3nGETAvEk+3lv4UO6O67xV1nXFTfc7mzRvGzk89EEVMHkN ow7cv527vZ9aS4xgFJ7qMCHiaJyoI4P1ENI0TTeDHTLn7l+ns/Snhx3uBj8bvB3nFIk+ccYAef5 wpMrOeIW59iYKPzYZwzukm5+RqjMetCK/AmiGjv3I8ktH7DSLM9lRrBR4RCmJ1cfRqLkQd+Xq3m zi+J4fiBvuCAu5D0lIx7eqXAKfty0Y7kMADb3X+JtXWXWYQ7XgYKZ8cmz3oHcYXBWdVEW9qQSr3 S0rHtCaBkG8HAX7qm1Hx5vtkdl58ktWe3ojNff0Cp72nTokx2Oi4O62Mcto X-Received: by 2002:a17:902:d2c9:b0:2b2:4d36:7aa with SMTP id d9443c01a7336-2bc7ac4ed26mr117712555ad.35.1778521520774; Mon, 11 May 2026 10:45:20 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:45:20 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Mon, 11 May 2026 23:13:35 +0530 Message-ID: <20260511174342.123820-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 | 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 Sat Jun 13 00:38:11 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 63EDC477E2E for ; Mon, 11 May 2026 17:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521529; cv=none; b=j8A/wA8SUSnv/7iJkb45ASeCbOuCi6tCdUEminVkqmccmbGUs9ldSXkss6ABkJ+CfKJyUWeuSaD/mDu4Xi21lsj29sWG+5Jbyff+ZmYraLl8Sy3afebBbSkz4UeKjWwTN6bXzerZPBghV3YfF8TrQUhh+53+movzlVS//40v6vE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778521529; c=relaxed/simple; bh=zqVTtYWb0+swrTGYbWxQXlgUdiISDtlU33r5BVnXTMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Li6mLVBITwMwykQPs+qR08BKIy2KySktOhmnZKvFyD26gvfwcjWJ6dJr4wpZFnue1vnNucuabumCZ9H1gbCjdgFYfmX37gRHJq7VX94z1R/eWDxsrpsv59NSlgSWFdrSn25jKu/9GcKHeY+loOPFxlQsQFHgm8+Q+RxkqZprtVw= 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=oqHebjyg; arc=none smtp.client-ip=209.85.214.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="oqHebjyg" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2b9ec9443c2so30028295ad.1 for ; Mon, 11 May 2026 10:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778521527; x=1779126327; 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=IzftT75wkhUWLYqTnzIpdZtkzhmLETv7GJcpetSaav4=; b=oqHebjygi+m6jrpWx2Q4Y90ikgWYHwCOnPw8aukQ8V32aT8RxSWBc+sv7fCuejtJfx iP4ZyuMQfW3YQnEr5Ox06I/OBhRYMC/yFc3pJjl7Oka6UzZAZdHz79VsMV1/RPiwnya3 2Tdniv0jHB9vbceKaKYr1+h9Zh+RzxjcwKAvp6v8wJ2amhntsDffzKh3UD0MuYyEeVZM aMD+HHXSsAjSifAqj2Qz+sNM/RB10H1MeBzgPr7nc7oVwx/+ZunvR6vbWH6nUNZQ7JPI 5q38iht9b2w+UFym/yFCy50RVPpv0p7yloUytKEpsvdkKmDiKN0HwO7TezzjKD2p8eis hKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778521527; x=1779126327; 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=IzftT75wkhUWLYqTnzIpdZtkzhmLETv7GJcpetSaav4=; b=A/HDfp9+UCVr0LyKEKBUDJ9DJpwnYxco9hJg2GcD3YnkC9ZfyYbk0nn2OmMFITeBu3 cxx7qMbSOt16lMfy2BMnpO9j861hS+Ns89AXqYUbjr6dNejTJ5uFMCo8jfAe9n7k0rpB UlXNKUuBpOz8zIURbLyppKnZGHgIH0PH5KhvTFowAMi0NAZKJ+ieoGOLQ77xPG42bTjK vWYHtX5kS9qfZCRj+wQAwueMqqSt5Z+ZgS+nbrmsY0m0kYR0iy9JZpBIS9vWIsLrT4tA 1+ovsR8v364tut51W2TT6QVZvfV1ZJv+OzOOezG56tQ9ZyMbbGrYxA6oLCLc3XLCFo0u EHfQ== X-Forwarded-Encrypted: i=1; AFNElJ+b50m1ZxgOlhjG/0XtuCpfk6jhY6Wwfnj4MjsAHGRrPOh8q1ycVHVbh0Enp0TXBmYREYh8ha+VzhTTUs4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6elhj46qO91Nlm7slF92eVxzZ9gWmwq5NRDVwhB322SP7sTZd 3wK6slOIBZlT/QdSon32xfDdwTz4T27HoT8VzcUMFrqcctDShZQYk0Ux X-Gm-Gg: Acq92OH0H7Hx5EiRlajfQ6QxtYhuKNUR89myuNAU3Y4kd1ds3ToemwUZ5Wgw+8QsQCI 68syx8aVQofpbjRp57VYiD4IRHcyoN6JnpNg+AjBtcjpVZ3bosOL45wiEzCGBkuxo3CHy93bl3D PiCU/x75/Y2T2KwmAogYRq6bRu59rglzdaQTEm23xhQjHLXAUCDv6pfeN55nUynq97wyl9FDAFS 1omJLkyKycXBg2iewNm27QupeFsefAnrwKX/b48tBmzuXlBiVsIc/Frv7+ahJhJMMZPOm7AA4X3 aZEwuidvHYILX7XJq5/mBQBUeMzcHeoR+zglOm9PWNIFsOQXKA8E2hmVESsVkG5CcaRb8VcBuRc +93mzx3mSXQzyp+tb7qWMwqOSWcgqTZh9DKRObAW9L/EeVCKzL1zIN5Erz7bhnX09WIUIQwknlK EKoBCJBmHW66vrtdISDJkIDd9F0WT3P3HKmKfwdwj9RMic5dQktZX3Tlik2k5RMJ/F7XtmD4kxR ed04b+MZO/jxe0MRCvvrzszYI0LmAbWm47LbHfrZmH+a6/N9tGo8CYu98El X-Received: by 2002:a17:903:13c7:b0:2bc:8e7d:3dce with SMTP id d9443c01a7336-2bcfd4ade9emr3925165ad.27.1778521526541; Mon, 11 May 2026 10:45: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 d9443c01a7336-2baf1e365a1sm106838425ad.44.2026.05.11.10.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:45:25 -0700 (PDT) From: Piyush Patle To: jic23@kernel.org Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 v8 11/11] iio: adc: hx711: add support for HX710B Date: Mon, 11 May 2026 23:13:36 +0530 Message-ID: <20260511174342.123820-12-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511174342.123820-1-piyushpatle228@gmail.com> References: <20260511174342.123820-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 | 187 +++++++++++++++++++++++++++++++++------- 2 files changed, 161 insertions(+), 34 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..dc4090e4faeb 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,11 @@ 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 - */ - struct { - u32 channel[2]; - aligned_s64 timestamp; - } buffer; + /* up to 3x32-bit channels + 64-bit naturally aligned timestamp */ + IIO_DECLARE_BUFFER_WITH_TS(u32, buffer, 3); /* * 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 +208,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 +229,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 +289,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 @@ -299,9 +331,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); } @@ -403,16 +442,16 @@ static irqreturn_t hx711_trigger(int irq, void *p) =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_data->buffer[j] =3D hx711_reset_read(hx711_data, &indio_dev->channels[i]); j++; } =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 mutex_unlock(&hx711_data->lock); =20 @@ -463,6 +502,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, @@ -495,6 +538,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, @@ -502,6 +607,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 +658,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", @@ -608,6 +732,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 +750,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