From nobody Sat Jun 13 04:48:55 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 8408031F9BB for ; Sun, 10 May 2026 19:50:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442610; cv=none; b=d5BkY/o4tCEc9RNb3kEz0bhI3Z3l8y5jnfp9N66lCHMQTEdeoLGAYyNKCrI+a7QbKYI3XNQX64InULvZ/AhKpk7xybDIKTVy6nXamzfF+ztNLBIqwW35RnYIaojiSwk33SzmpS9ipFgJeKoXlRQSJjKCOryYSD5yAZyyv1Z3qdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442610; c=relaxed/simple; bh=/YGBE3dVcPNO1qgArbYgXysyeVCHChMgg34LhnuVa8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Stlhgobd6d/h43Hn/l7tO8/Y/SUtKiq99GMrNzoKz5pEs6BtNq397M499W0776Vdze3Mut6XZwRoeWOmnBVKbL8pMBE7+8PYEX5PV8P+amUdcx3t+D3JavMf9NgWok934XMt5Li84VfhE/4tSFoEJ3fhvKcGg0VJg0F0s5TgmHM= 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=cE10PFKJ; arc=none smtp.client-ip=209.85.214.172 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="cE10PFKJ" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2baca78cfaaso24482655ad.1 for ; Sun, 10 May 2026 12:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442608; x=1779047408; 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=oAPu8zY7K1umMx/3iFtBmWGzNRf6nimLEMSjnAOfuo4=; b=cE10PFKJtL+wyXlzm/8SYUyO228sF3CGJokFNiOYRBP6DYo3I+IkLa91a0/XKjRB4i y2+CckkIhJLeG8HqYqmKYs0cCZym0eECOejIFa/6bQRo1cdx8sYIycDjv5AdBNJ6Dxdq X3TheJXA5bVjMOV9kjO2iEw/8ow8E0ZAWJFg9CXOlE6ScYboJbSa6nx1sJU78mC803Ml xqwU/wersHserGf8PaTDx9p0B63qc4196AsZGn1GKaJjBDbdJlUVtbzUdOZMFEhXCoCm 8rS18IniwHY0oCUrNjVDojqocA5y+rnOIMH8AG3dqNPplU8AO+JvWeL31SJWqzKRoFR8 /3ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442608; x=1779047408; 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=oAPu8zY7K1umMx/3iFtBmWGzNRf6nimLEMSjnAOfuo4=; b=mynek/GQT8QP2nFryOj/Lznwzm1VledMyvtj9MhrXf7z4Dys3NQO9P1SWGgi/iQbDu rJXFJOALSylt1K9bwkVqiImL6n3xlxlNrqwjjAxmsP59POE6gb6VsoR3xD3kaO+OF9av xJACJPjfz7FN40B0PJztK7qfUDxi+B2HACbVbvF6fsxg5la/e/+hrZGcv8ht8+FGt1DT fr0UMdLuNMQa9UWgAdIV8a+DHwfFve/p1sqN+2FNxgMuWhhqLMJyws3sa7wiWEeq9pU9 hvqvoMLx+EtdtaQWos7IcS2urMAhmLJcJCZFKxGfz6qtHgdH32gbAoEF3uqGrMMY9wjR E4+w== X-Forwarded-Encrypted: i=1; AFNElJ86h38kwJfAaDEELYg+QNc/l1CLAezUwMmPQULKIrR3sSIog0DNpLeNS35lqb4DLtjiXAPoPF04xOUpWJc=@vger.kernel.org X-Gm-Message-State: AOJu0YzamJ+AxTIqYgazqPhVn8y1HRx922tWZbNi8f76JNGgLNNJW1B2 CfZ5plffTRBywKTTlUr3H9+O0PMEgiuv3QwSKKDiy1k5f/2jnm5WoNzf X-Gm-Gg: Acq92OEr8/xwcjE7vcAVxQC4iNCY76laR73X4C79CByoktEnggtsSmvxk/wrffyhcfR GM2vOmJKcPFbjSneq/FGdivt3y6hX69bzRRQ+M4uHIXG55enp+gQdSTirb98hvCUvmnvK6diNaC Hr8RPmt1HZWxOF3oisXoB+aOGWwGAoho6uRX/8cKJ5Ytj9nyzKLQcwSFa6ZpXLvOidwMIenfkEt eDJYk0Y2UykXvV0AiXk+U7ds9kAxGIAlbRQwDOE3BSfuxNv28+BsjOu7O01vwI67lT2m89Ddhvy 3WV+yFNRZWOxFPUTdQXwWrkxRmP100mOVAEjBHSp5q+XinV1E79MltweGcnkjiH/mlNIFKg373x J3PRJzrFBNES9SIw1/tbno1YW7a867hqU0CVnZ+zxLoreeAsIBJOWYd40/CUsRqW80pACFY1wcG r1SVhnPvf/OUc4WTB1OQEqqhTxOResxB4pBMF5mb5m9N7R/Rt2ngWEoehLwO6A0v/mRGbPsClQ2 0TByVA5UAeh50zEZbd8FH6z3ntR/vwixx1/ETx9VOBBhZ2doQaQ4DnJFokJ X-Received: by 2002:a17:902:d48a:b0:2bc:7d4d:3520 with SMTP id d9443c01a7336-2bc7d4d4085mr76196105ad.40.1778442607979; Sun, 10 May 2026 12:50:07 -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-2baf1e358b2sm77065095ad.54.2026.05.10.12.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:50:07 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Mon, 11 May 2026 01:19:23 +0530 Message-ID: <20260510194947.31997-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 04:48:55 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 40598322A2E for ; Sun, 10 May 2026 19:50:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442618; cv=none; b=SSu2s4uOW9WfAIvgSrFYxrN8hQzh8FiUUf7iO7Md2xYftTdA2P0j4d9mIwrb/vgsVaDwydrnaEbym2KGdT8JyDxDJgoq4Y9XYo4d3yq4p5quXLJ4hmpOiE6ZindZy8hAbFneqFiT3wUWhEgH0lH3k/sJnwzprfvYI0+FbvPWxdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442618; c=relaxed/simple; bh=9STMCiEcQygyJc7CSDMCOsAD6GSfrDVZtYpT9m5OWMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oB3ofc2FA520wfAgiX87+kL1421k/nHQGPOSAWEbKuPgl/HDX12BQh0HnI+7pb6bV1JAcNggoDDsGaVFhJFRNl4/1GCBUJE2/iT8tX1dlOQWmTjoXou3PbfYt/SU5td3oCdn1mbGws/tOzev4QIRBNgMRUCMANiEO9+Z1pbCP14= 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=gwgMelQY; arc=none smtp.client-ip=209.85.216.51 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="gwgMelQY" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-366375c4076so1483858a91.3 for ; Sun, 10 May 2026 12:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442616; x=1779047416; 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=nOolxxVKA/S7akHh6l/gIw1iUq8tQWrXL9QU7Cp8/+I=; b=gwgMelQYOvQ0IKjZqOeDVvswaayFkfPeOi0MqT5F/Y94l9MxyrsWS1gV8dclc50djk qmku3o1onthNujTSF1KLu8ZHGj8wnvwEh4aVos27rpG4wZCDXrA86K+L3E4HhLU1C9kp BmD7216UCTW1IbrpMcO94YFqE/uiYvGklWXUoZmnjKNGM0MNTR41G94aehMgSbz0CIeE vlj/RY5oHb763PmNSauBhgE8aL+LgMuiGbXHVyy/7SRFCjME5Mvh8heLJQcnngidZUlU Ag0Mgg02BcrATUikEGhxmXNKOi+xRdv19u253G12NniD4Ho9ABb0bKfUku8JlAMr87ko RaiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442616; x=1779047416; 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=nOolxxVKA/S7akHh6l/gIw1iUq8tQWrXL9QU7Cp8/+I=; b=pcrzWnGMvPsw4LRJqpSW115YFEml9qQaw6D3QhHHYYPTpDrZIYgt3SM3oItFxHj0TQ m0h2tcb6tJkPSwz7QnwbuReVZg3nRpOCPj1/7/jR8Bwku3TOgTLv5BLtIEcORfZJuDyd Ip/3Luc3vsuh2we0F0oxKmU8oqpuFlb/yFIGC9LOxkOZo2qw/5pgRF6o5I5UWfp767Ej rg+119NUdAkyKpD8nGYmvC8MJHIfmau8phURT0WK5tYR6ne2dOKqFekldkJn6XOW5Fwa BuraOVXkBacaroRexLAD5aIQPFGtIQ/i1yrM/+lZKiIFLOyfXe9SRQEnRMPNJ/3wxHr7 GQ8g== X-Forwarded-Encrypted: i=1; AFNElJ/MDSfH2ai6HaygyxW3xcuMGvpef48HqBKZUDeGYSPyTrIRhP8+Q6tZkbvv7Ay8L6hUzTTAfRvutaTgGM8=@vger.kernel.org X-Gm-Message-State: AOJu0YyPmdy2KZELlYGntTQHhGO7ejOsXRVlu92B9vvyoxhKRr1saaRv hfmBPHvFknRAA8JDIeYqGJl6nB0Bsr12GEnfTmpDr/+uJVzYePAfXq7i X-Gm-Gg: Acq92OF3GGKW/112zFiRlq7p8VjKxmsNxBZT4e9YZNo3XEpOgVpxK+TCRm7nddFpr/4 VcJ7qEia4t2hhY5rS2pt23melEKSFOW/bPWCFTtQQg9iBDT1LX/cXLrGkWaxyHctNQS7hQTkOVo PcN2ez4SLWUI1v4yCpr9Hpu+Ee0FSSNHwQLV2k9c+QdRkjUgoAg+/lAQqlTu/vUGmhNGNdYhNSU glUDulToyWEZ19osDillnutcrtg69PecfsAHisBsLwhhnwMnDPzwSU/GQHGee3PPLRiQMNTzYXD zTHjYS5WZPpL1QFEhrm/ED9suCwJoZOT1pGhPGJkybk4R/XvrVOXSTonvXgKVRcezYUhuGpkgR/ 9+MdyFuCea2lP1ovyzNtrunYYIfvIYJA2m4+5murDQBGVXnH2wCHbFTWMC3onLUhAPSJu6QbY5q h3qhHoHlNEsxjs7zKkFT37FWPP30Rx52lgW2c8QgO8FAm/dam/2nDNgOvrnLv61dhRtb3ecKZhc SpuQZ8KNDhWGgwMRMiLrxBWXi0uTKUQRPlVqNLWorRWqay2yuIWBNQmymvhidh4dHGrwb4= X-Received: by 2002:a17:902:e747:b0:2ae:5629:ac55 with SMTP id d9443c01a7336-2bc7aa20488mr72912765ad.21.1778442615602; Sun, 10 May 2026 12:50: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-2baf1e358b2sm77065095ad.54.2026.05.10.12.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:50:15 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Mon, 11 May 2026 01:19:24 +0530 Message-ID: <20260510194947.31997-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 04:48:55 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A61932BF24 for ; Sun, 10 May 2026 19:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442655; cv=none; b=GJkq24nFtFQsc+Vx8S5OWdgkfnfuSwZfSfQZkaBDoBBSjBHmnEIQle0c/51fGf/Mrm8/+XM61jQMN7uIcEyNLuiVOlibdyk3y8nUA+g5rPeuOyqpjeBYSQsuMFiUUVAw68HzElpTeJY5hdvDnmxtVraNsSLID8RsS73sbcIMZGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442655; c=relaxed/simple; bh=we1AKANq/NREsS4tweY9WCb0aVw3YLaZgCYIUAl/3R8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CvbBKDq9kCBh9VP+KPrgUs7JQPvjAiMiyXvtRjw5+8lzf2CBq+0ppEibuXL9aA+UIxWea9np4oMIfDUa8cF2LewIZ9CPpImEIBnV9/Vbh5RXUFd4mQICOnjmV5X7Xlp+gM2VRjhs9i2bHGoKlERdDrzFbZSZzdOW38dAFnwPfoA= 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=pMbOCS6e; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pMbOCS6e" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2bab82d75fdso19097105ad.2 for ; Sun, 10 May 2026 12:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442654; x=1779047454; 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=FC6iaLaMepNHbep9t8aKdIuhjAiXuoDAQZC7jBmjFtc=; b=pMbOCS6eUUQ60mrUQO344U7qWZ1rDBxtw68sOellFHwSOk+7yDnsRJy6fXe635UGsS PuQ7J4GPbEoEvQr1OdZwtivQBM7NFbXsr8tdsaAjR4O+yMt/Bo4XvYCDdZfCt40145uM BsVpf/CTMRXTmujGw2BxbSYmG7lVqWhZMiDNJsy0gUdn0TD9mrH9mhP+XligeoKxG2mF JKNUh6T+3RXlYgTKhZ1HKrh6owaFKV3Lkt2nd47q9mTGJfEy5yHfx/1+k/Wz82wcXP3h HhscFHhaf276qvAYyOb+y9RfnYaMprR+XUUUbzLgUjMSiUGcWAfI1KuqgdBjD7NF08B/ MjKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442654; x=1779047454; 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=FC6iaLaMepNHbep9t8aKdIuhjAiXuoDAQZC7jBmjFtc=; b=f6CHQ4zRnALI7uD841YCk3BzuxWNwt3TX8jCW8OF0r/r8TqsXEns2TkC6FFLt/Vx+f rSMmJUhP6K11SP5FLClw+hTGyvNA8MRI9iQQ1Q9cn4ZrtwGqkIn39l/Lpl8K0gZRRduD BHIObIz2H1pz+jR7a+es1ETPSfctn/9QBMjjjKKAOQzale77DZ7nm3oVLm/Y+1ypdPDm PYz7wrKWCYpsbEUk1IAhZsKWxFHEh7aXB/SUjnl2QM/3vi+oBwYYikwmYA/FOD3Vb6Po z1asIeE+AS2MnJg7tsutskbgZ6pgi1+eYQviNsP54wREe+RFl7Ge8C7phY2X5JoQhJli 6dpg== X-Forwarded-Encrypted: i=1; AFNElJ+3fWqw6HxUy5cU2+W3NqdKFhdmDvorxKX0e+6nSeQjiS1a4NwKvupCqLlvGVJOWRtSg7quzQH2G6UZfqk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2AdScbrY5NBz+fs/gyP0YZkZ830+YTYDRHNzwcO/6CRid4GAI OtwFi8WHMWrEh+uWrV9I0TmetofCwAoBthQc4qdjvEe192QvBjiGjEDw X-Gm-Gg: Acq92OHQHUzqw/2ZTLCDb8a5U/ws4dxJKXXitPEu6g92o/pwVZ9VLsd9QbANBbF/L9d 1U+k4HF9VwWG45F2QQumRyfQsphq7bFoH5HhzHt8+gP3qU27A4n59aCyNMjjrHwQB63X8CuWX8w CQsuw92222FVo35gLRffa9HF/70ahHaGSDB4ktw+dB6zJv9cT2gLLF/EINd8iegxVj1g16xrzWk od8EQ+qI+RNhGYjAUoML7ejcnNXUcw/LGtOMCjXUx9Q+Nk5w9LoEiSwhtDc5sk2V5A960Z2GLaX Uyt3XbYC6A4XUwGIPki4t+gOT24/XebEljMsIvJwOvGA+RhsPhIRfbL3sbuZIyuXwOD4tEmJpji o90dkU/zS8HLu7Dca4xkJNABAl4CJd/yAvsZAnHflQnx2pVE3jdgbwcrSAAepM9K8PEEYmT9mVe XQuy1FJUu1uytog0y4V9zSirTZxcLNgpJ8HLDWvZ/E8BX/udLU+DVorfnZE95tu9oTpLYkgcqgO pFDfpqQm8H4xZ8C6bQhxe1XsStwg0tVvqb2RMjunJJL4oGu6cnGfTEUNTdj X-Received: by 2002:a17:903:32ca:b0:2ba:1756:aea7 with SMTP id d9443c01a7336-2bc7a990937mr69806415ad.2.1778442653564; Sun, 10 May 2026 12:50:53 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e358b2sm77065095ad.54.2026.05.10.12.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:50:52 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Mon, 11 May 2026 01:19:25 +0530 Message-ID: <20260510194947.31997-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 04:48:55 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 0662732BF5D for ; Sun, 10 May 2026 19:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442678; cv=none; b=cjuLeSy51xDFG8mLhJG5viYnaK6HtbTTTUOelg0d8xxF71ISBsqch89oVBMR+hd0YNkrYwbq/Mng/UjSdy4GEqmbWCryq4tRwupZGWxF6Y8/md7Mv83FDRYN/kb6kdz9oDGVJQosmn5AG2YVTZI/oqXZWw/46xRETQ5n+GghOMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442678; c=relaxed/simple; bh=GhI/YB24tQ0bd38mulPo1xH7tdW0RPfUcJg1RDC3ubM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UOJOP+/og9j2r3tsARt8/Yj8FpHzarbswdvngiW/o7aiNRJXcBgx68+KfDyMNo0aDz9unO939h3Kt+SJ0kYSxRhjzE4dWwD7Mgtkg+x7Jz4IlJDk2ou1AgMqeQGSKfKdWhaZG5iuJpfvcjHogHM1v+XjRsltdeejQ/VCm30JqpM= 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=T03ouMpL; arc=none smtp.client-ip=209.85.214.178 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="T03ouMpL" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2b4650d5f5cso13371415ad.0 for ; Sun, 10 May 2026 12:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442675; x=1779047475; 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=xwuLsZ0O8eS47ZyHe5+r4pXTo9v5POUb/qJgxIJDhZc=; b=T03ouMpLE/AmQxMZDKyuRwzpwk+YIOQ34zTcAEEQRVyHsHwfneg2gXIE/u/1WMX5BB Z2OtBnq8v7X8PlITOUg367AVhKqfCsC5KOf5HOCjayKgrw9loqbB+PW1sfo8fqKOK1Q4 S/9tsgbDUHWv0NZk1r//xIYVmui40u4fE27gGJYSFaLW8dZH4ImRZbfQANqFtn6cq08r 69ZPGQuGtHIaIDZtvAI2KI5TfhjopCM+xaPDGz4V+3mWqg4d8Rfh0lzLOQvEF/Vlt3Bx tUPvgQKZP61mw17oU7ejJlS6/jhXtjskkkuBbFldlOhvMbAVtk+dj+otyf59nljvfTJf OeLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442675; x=1779047475; 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=xwuLsZ0O8eS47ZyHe5+r4pXTo9v5POUb/qJgxIJDhZc=; b=IXVDdVpqj9hV2hercv1zQC4m3tPlxFwhay6OzVNOifgHGqBq/DFvVJtjHeBCV8pLj5 AyvrVYuRUNM4CUUQFeQSv6zXKYxV9SFuixdZlw7PDM+T6ib2FIlLFOfiZI/tD0FqNp8i uwTEwzV4e/HKLWAOSz13Zb4QtwXyawWzXSiEPeTNTZq/3z3m2KihLvrYxo7Zsf7xuPdx /0NvaMSiXx4acpdr59egBO8r4stp/59Hjtw8DRhHevy/bdYqGVOzhdCUj04I+4FcZXgP 0tTpj+D1An21HTcXmC3ZqeODfz1/hqwuBy5z8sRHW6tEJMFlKtwccKJSfQfn3z3M/oBv jzVA== X-Forwarded-Encrypted: i=1; AFNElJ8+vFayu4QzIbGpPvD0IpvaM0Uu2dGd4Lk0l8auIv+XSbKvamHAFTFAoWkpX8n6r7lJFbXBarx6zRxU8ME=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw8ZZrKFYjjNk3jq9tG2ZgG4VOawMsJv5vsRbpo6rDrRUFglqG EeivWER7DM77N/10EmMlomBGumpteeKeMgOYgJ6DYxVp4FsgK+KKJo5l X-Gm-Gg: Acq92OHpSOTsW+eVwoqOP9QHlYyB6ByHZCgwn6cQdbMte+iJzZC+fQXIi2cZzi8k/sz t/W+uV0Em8BKA+ROYaXy2pr+4/5UErlIvkxV78/BynQoNfPfCcONXpR/V9Ey7fAnEXSJ+TJ9lcP Ajg+c+Lm/9AHYVJI95nW7FvLW8g1IlRtBSsO9xfTyRXjMSM4oyFy2sQMWuXBdRJG+k8ZeJUF0Sp GfgDHHY3rC4JFVDBhB3Jatt3Wnxhi06tjVoBK3n9rCZM2X6+4AbSLjtXhDxi6KTPl1F1TG3nGRI JISjFJwDCYLuyp3n742dcyCH5JJ3o+qJNDNOKqzemt1OlQjeT2glFAAG3dwLVSXEGs70Qkav6QX GwN6IeQt0+PNH1waGDB3gr5yuRvbSHN2PHIT5C8tKiO9k+o0CBkWJzWCUC7VQlClsMsgzVybS/t LiNlL4wuLI/4Z1a9TlGb+oAQyYjSIFB9ABum3gmdslXUTxkso9BqyP20Y00yKx0RzSgkKzWd/DZ n9Pf1IQhQp6Q6X78XMbc3qwY6khCvQQAdn32hEQ2NzuCxA+X44zjyZjj4vN X-Received: by 2002:a17:903:4b0d:b0:2ba:3e50:e3f5 with SMTP id d9443c01a7336-2ba79ad0cd6mr231459655ad.30.1778442675319; Sun, 10 May 2026 12:51: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-2baf1e358b2sm77065095ad.54.2026.05.10.12.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:51:14 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Mon, 11 May 2026 01:19:26 +0530 Message-ID: <20260510194947.31997-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 04:48:55 2026 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.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 AF61E2253EE for ; Sun, 10 May 2026 19:51:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442685; cv=none; b=KZS5PFLi6IT9QY65a70bGo9hL2wjJeblHqW3OOen/7By3zSOkiznPfLdfz8WsMoNPEWiZhCOEyiFdA8KnOXgH3U6SnhJI9cc/Lsy5BkEMHeclkpX2IqzNC6K+Z9+pVae+tLE4zK0dyA5rA9YwSGg4OP1s/2HMFA4DzYL+lTo8c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442685; c=relaxed/simple; bh=bhAlegkovFkwJTJxeT71YFHTPPIyYvD35U+P4pge5j4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u3K+IQ+Aww92Ktipy2uuogKzs5Kl64QSeGSi9CPEPasN0GQE2Uu89lckwGG/GIpSUABdeNDmXNziBE+FZOdKSPNPK/8AZqv/6kIH00glwi5e9F5ycrkLF4fLhMKInFN9bu1fHig9UPe+S+s1pw9dZiFDgFoqSh0aTrHL/VgtLOE= 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=QyMcVEcl; arc=none smtp.client-ip=209.85.215.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="QyMcVEcl" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-c7980c060cfso1559667a12.2 for ; Sun, 10 May 2026 12:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442683; x=1779047483; 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=jJwisOEN3ob5Rkf/2eM2QOSlejeWPelQyp39rV+wcvI=; b=QyMcVEclzcTd9Jyio30QOn1K6JfFMFh9DUqejTG8v0iFogp0oLf6CuI4vEdQLS6LRR BO3tbk3t7z2BmyO47JxzQ4CBiSsRWM7zYgrW5tVoMs8xiWGjokt8fza6j1/wqyCIHdpG 3rpj8QPfVukoqBjlWKaeruwG8hRIyELX1nHs8zFZlZW6Lrl1pXBTSKKBlSVqGgtt6KeP EioWENCM2iOWrMXUYQOY+ws/rGwQz/V3BPJS+IIhzsqzcJXxuvSbl2ALH3KWduLO+L9V fwMDLxsLmopZS5YZczaBFcpgF7T9+rMgecd9yCtbymLXbVX8BSIFf03Re1RfwnB0hl8N 95pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442683; x=1779047483; 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=jJwisOEN3ob5Rkf/2eM2QOSlejeWPelQyp39rV+wcvI=; b=BhixSdgM4NVh1yuHftEB2aQFS5d6sTTaFvdQCqbJ46EEC2kQCtwiUCuzqkSbng4uY8 V59cpUvRiA09fofWUdzJnuidCGJEim46AjRefNwiWsBc9Yh1Ix5eSN56byJd7aPNc9IB b6j17EquwIwV0u90Z2CwlAhPV857tEc0578DeSWiWTd47kaa1F/5EvWvf70ymdDY7YQq 0zmTHxoo5pvy8bvA4EdrYhbV9P3Ge9Dmu+BCSj1sQka+61veajFRQgqg1WJpl3t7oyoN qFrxSdHmKKxl96zGRiTsagAbn6aKt0AV45kBgiVKOvh+7JLqaE6cb0cDG41ZvSNRDCep tfow== X-Forwarded-Encrypted: i=1; AFNElJ8pO/N16ojIlLSamePXiHEbiK74AwbcL0FM7kN0Py3XtUZQ4uphgmoBGcyqzTD9X+mMjueebPYRaDOU9Vg=@vger.kernel.org X-Gm-Message-State: AOJu0YzWnAVu1NnP/eCsRAx8ALROfRkfkk4hQJ94nHBebSruCesRPprb 6IiFWcXakgotOob48upoEbJY8ghjyRkeHi/JPqevhyBRIlBTEFVJ7DET X-Gm-Gg: Acq92OGSj2M8dUZ4PmwpZ4rTsKuS27aeGyb5+uUrDoaXJWnSRdkuXbN2DN7MexgUvuy KFBeRBOylugbzRwXpeP2O6jQFBo48giZW8qX94Uz6DAjTL1LP6ptEQ2pritx/A97INtdNAGEM7U MXvUDB7FTOaWcRbYBJRQgZH8N0v6lqeihwyDhMD0a7rb+/w/x94kTtHuzpTHgzzmp+Ixq7olPIL G4sLmJVIczYs3ABw3/eTpbGuJGid0KGXblfoIhEb3TtpqIQrYzK2BsPrOOjTd3DGigcmqrRrwcX 6bafZviw//2aKJlTzcT23T7V9BNp0rgGBCU1WtY5wE33dZZTSwMMFlW4hCsNaCAvQcDtaldM+BD STKV6548DRY51FErRahiDFKyKBHPyQKP9I4ul87nL+5ksEK/DkuBPkUXSKGNKh1kNp+14QCQlCD +Er8SK06SM9yPdhz+g7U3KRJiyJA7k6s92LmbbeFN4wClHbH1WlNc4xIlirSlO0bukZe0IYxO/D 9vyhsZ3kXx5Vptne71WFRM/GRvxIOPSZY812z/k8udd6zIQg/hLiTFYlnEyUg3LYqUhpwA= X-Received: by 2002:a17:903:1ac6:b0:2bc:cb97:8ab7 with SMTP id d9443c01a7336-2bccb978bfemr8417845ad.25.1778442683090; Sun, 10 May 2026 12:51:23 -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-2baf1e358b2sm77065095ad.54.2026.05.10.12.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:51:22 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Mon, 11 May 2026 01:19:27 +0530 Message-ID: <20260510194947.31997-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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..01097e0fb848 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 04:48:55 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 7F69131F9BB for ; Sun, 10 May 2026 19:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442703; cv=none; b=iLSMDzR/GmbK9LJn8UhXmtj5W35mKDDpGszm7V44bZxquzzGfRAL+wL2o3nBG1Eow1FXz6FCA9C28fW5PJaayS350f+gXiFzbumitThB0B9WMM6Yof5AYRpg+YqeMUHeBW/AVb8btgoxClJjg/+wO3CqCbH9QUXd5vnEbU5Y7UE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442703; c=relaxed/simple; bh=RKcYTDaKrc2EbbrCjV+IAUASECpscP1hFKImsuDBjEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fmI8RCXQIbteeIn41mixYQjfolzdZqVZ8rpnxMmWEp+uUcBTzEoQ4tlrtcNbjrzWgyPc8/IFIrioelvPjkmYQsahRJG//N8VzlOKFzqOqbSXnclSmb1GGKJ76xQSzhYC+qpZFBoVqM1+T6l0N7A7wu01K/X01RY8dVUrzXCBm7Y= 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=iIDjOwPz; arc=none smtp.client-ip=209.85.214.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="iIDjOwPz" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2baca4df358so20891835ad.2 for ; Sun, 10 May 2026 12:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442702; x=1779047502; 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=uEX4ePEk9PMDKzntsJeVXZmKgfsdGmW52YeAaYVtzew=; b=iIDjOwPzi6DIUCM23pSJ391a5DXkgCyqPPiGzVmKZL8LmjgMTrAOwd3zFXq15xiKBM G3Hk2mvXat3pnyDOK2yFnOUNlu/JsV/gvdQRc6h4dNnkrSwTlLF9TMSWRHOz5roMg+DQ TT2xlkHhwpquGzlANHLJLjGS6U5wzK+EPxkzS9xxPE9S2ncGGH0A/STnr9lbKnGJQFpC VoemMvEomq8NSdawV4NKuP1o4cy9ejLBrvRuVZViW8g/VuTPNxjJveTPopRdIeaIAphz 908Dks97pIww4eYe48IF2/G4RLeHBXPQ2fzkBXkf5uapCEFquMgZp7O4hhJUeE2pzjCZ +LUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442702; x=1779047502; 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=uEX4ePEk9PMDKzntsJeVXZmKgfsdGmW52YeAaYVtzew=; b=eyUaJKCUj4zZ3l2enrOkVKEA2VM5J/VK9fyaIHIxPN+FW6r8wz/W5s/8BLXsf2QG7y pDwHGehEh53R4HFthTjpibhsbocqiesyqgxyu58vkk1/3142hSZVGoQd6aAgZVxsSeDb 62AsenOJhedk72QgPwWfSby4G1ptFWjROPAsZ1Ya/BhAORvH6SP01PZHinE/+8lPfo/g 11x7rNi2aM9p0BFzEl8XEPsN1Ms95w1q+am49cWtJK6nbzUIygItavN7NBR48RVMbo3L S136wtAZOBF9PRedBx0Qg+WDhjbfG8WRP+HCMOEsWEICTu6HruBgccVx4oP+X7erxQkf c5pg== X-Forwarded-Encrypted: i=1; AFNElJ8zqUjDkERxXFildW2e/i8vDnFh5dD83Lsco6P8XGPUaZp3dmBNTg1WK3WtfprAKfb9BSP8p0jozF2vaMU=@vger.kernel.org X-Gm-Message-State: AOJu0YyMZZ00OFrjHHlCKo4WYa4rnTdgAwLMsnqRyNn8lTp9+1E39Eu4 1dqqfRqPuMwZPUVo/7aKDsCVPPSZtCVOSU03RH37J0pdFoPEoMYFu7Km X-Gm-Gg: Acq92OHjcQuVgxMtZXNFKbAQaORVfSuFjEjWOz0oKhVnnP5E4g7ly3RyGYWMuqk0xH1 zkm9by7nPTNsG2hebfueUL9kYFtoV/Ts+qBeQv0S74u7N2dg6ZygmnhDt4FyaCHVYYw8JyDMoxf VjYljoXUvYovjmAqOWrMFqQrdOge5Wq+XfkC9o7qFaF+cx2bOZuDdJQD1l78N47URvx7W+wVpPP V7JpyQT7scsmLa6LYWt6WeoBse0WM21ZGVs408A2NkTUYXt24mVBENqYwoql3SWltkjoxEG0Cje jyj5Sf1SdDdrlj82v4ObUvC63tyH/qwBDwHxRXOrE1sPgUNehKs2b5Ki3IJS1kf/LHnxmLKguLG YGIccdCU+P09+KhE8O/Mtco2HK8vCKg0gNmO1jpOEjOTMjMsHLBLjfn6xeV/uB5SDasDCIlODE7 fEA0TbqAtRPEsAztTnsafR4tXqPfEHJwm9BQ2/vS1QBiQuCJIQwIzEp3c17XudVScnXhfzvU/0b BqHWzFB6N90sh1ff9e4z2lhRsULr4ihoaF/f/P7hbnCPaT42u8pq7EM4fe2 X-Received: by 2002:a17:903:448d:b0:2ae:803e:6c12 with SMTP id d9443c01a7336-2ba79285d9fmr150394875ad.6.1778442701827; Sun, 10 May 2026 12:51:41 -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-2baf1e358b2sm77065095ad.54.2026.05.10.12.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:51:41 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Mon, 11 May 2026 01:19:28 +0530 Message-ID: <20260510194947.31997-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 01097e0fb848..331d47e1bbc4 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 Sat Jun 13 04:48:55 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.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 A9A3D31F9BB for ; Sun, 10 May 2026 19:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442714; cv=none; b=qP8L8A0CqApXUCrJDrHHpSdxwx5K29+aspMbRcdLCV2TVlYMOhVkpdVkRcWW/xxfVH+5UGf++zy2QvU765jeQNvqRafD4+mYXSeTJk/aiI+a9iO6+8f4f7Gg+TaoVqrCpnBuzheU7e3nwQtFMZK6UjPoDTKs6BDISbGveQjIBd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442714; c=relaxed/simple; bh=cr1rruskqrpDMm8vtb6PFZLYjH/f4H9vvTNeJg/pD6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q50ZnDr3llATGlOM7uoovBoAbgAERm74P//m7UYXwTaXjMJ4ykJ0QeO7/R8DdmaKsLwXmxNShn3UxX8wkSBwzXbyZDJ6GH7UEMC4b0wHiwRBbkJrsZkGNUqThX/ITV7ojRY3tEsPmHCTunewT83j9/Kojuun+nWxKvZI8PCrvLQ= 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=IXZ4dwtu; arc=none smtp.client-ip=209.85.214.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="IXZ4dwtu" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2bcd3ac3307so168655ad.0 for ; Sun, 10 May 2026 12:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442713; x=1779047513; 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=OVRBNZkgMu/b9a/cyt6U9gVtDXz/XCuTMVxHEa5XTmA=; b=IXZ4dwtudzrd2aNTOYi18P4OOjxYS0kx1KQuu61DtuCaa+5OGa4Pqpud4iwIpjsRD1 NhNPLcS7IjWSZ3ZKiMMWtc0uUnUFLunnFCmMe3oLKeubPjHnaN/Uh76w2g/B+uEz7udP iBPxy7gE5CwOUoWRe7GY6PJbW/jXzt68viHlRkuFT9+EtH6ZYbGOn2zUwfbj4kFitL5G wGTuAkeiN+3urvYJkxjtX8muP61ziha3s2JYdgh3qE+YqVbJBvz5ueG2V5Z89kcD1+Zp xYPKjDBwTkjshiAUXN9J+RMjuX4M+cppkE/KZ6yRhxMeZ5DBfN6CMvBSMjGKOPcmtncE E+YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442713; x=1779047513; 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=OVRBNZkgMu/b9a/cyt6U9gVtDXz/XCuTMVxHEa5XTmA=; b=ha6v+Bm/xOsDteYpIXR1FWKG1Njg2CtFtFg5j8otfsNsGAzpGVhYnAZv7PhNm98Qv2 BlFy1UkyjRNOOU5qMfGJdhjglAdipeJ2U3EcPTCYqujQWFcfUeCIFdHEEne0oeVqf70t DXRdOkaMXPHk5R3yuot9exSZ5jWGn/OvvGIgmQocrjN6M6VRv072iWjRVNU0Usd1t0oX XJ0lrdsjUEPp2bqK4dVlCkUg9MF3NCPCIpAnVnmukV9U3iPsQWbu1ZEdd02u2jeUjzK8 SMyjPtyyANDUDVCI3ZCg3qxsRhbc0Fxxuu1f0ZBl39itP4OL7bDqKpRuKPJC03zTWty8 kSxA== X-Forwarded-Encrypted: i=1; AFNElJ+djma98hfpVGqH1iE9MDths2rKA/laiKeSLA3JodaNGLzCa0GkO9ytc6PsZd+ACsJonDsITwc1fP4eyHw=@vger.kernel.org X-Gm-Message-State: AOJu0YzS0Adqx8KVY1dOfAnIQSk6dm09WcpM6GuxBvULAVnA5WN3NBwP UzB7udNKJlRd1Rm7l8aM+6cU2mPVNySt+wsZxhMjYeI5zbplOXbBdc2C X-Gm-Gg: Acq92OHgWSED1Fn8bs8xKZ4GMTYvJywt0kPvkIaK7aPIkHcSH8IwrlsN/KWyeD0VED3 lsrHCMLWRB2qSz1QBp6ewbEbZQ8BNEUzW9dcFTuZ8Q+Fpwz9z++WtuOxUnkggFKab2J/quW/MQZ ziBSCaGncD0ZtVny8osEZvbSCPLGOg2mtaAVGok3749bRG4RdwWWMwJZi2tK8DTNwKW4LyCLubx Yv1ihuZK7vKmy9riNRsCReH6LxuY9BqCLLHxYh6BfyXKUu4018tN0bQho7yNhiwR4vmoOvcs2P/ yZJd1UqL9SXCNrzMUagYG+Gaeo5QLnpikSaLT9yilt2Uc0/oebUtLCbEjDd8kz+HizQyuq9tfzK W+B5XShTxKMPAVPIa2Qs96yAaKn3PRLtJv/sjYAT0a3xl8GMxDc3t8UNqM/I7hW6VcXaXjNJcAc dALfcX1LR0JvwJwaR9CpZptF022uZ8Ev/2vWpAgClLKWoHIDQpIj91nE13O/Sdj7No9JaCiz196 eNIaauAfnTpR1XEpq4oWdIOhQvDo5651qpEIiLPBAVrAvGA4CeRR1SSZ6Ef X-Received: by 2002:a17:903:28c6:b0:2b9:4eaa:7153 with SMTP id d9443c01a7336-2ba79c0b87cmr147797285ad.19.1778442713070; Sun, 10 May 2026 12:51:53 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e358b2sm77065095ad.54.2026.05.10.12.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:51:52 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Mon, 11 May 2026 01:19:29 +0530 Message-ID: <20260510194947.31997-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 331d47e1bbc4..24be690c371b 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 04:48:55 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 AC2FC3290D5 for ; Sun, 10 May 2026 19:52:00 +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=1778442721; cv=none; b=AgPyShqdxQFpY4AvBRznMmx24ILJYSr3Q3soTa7o3XYYrs0fN7bWrbCKi+e8dCtQPzicd9me9MbB3Vm5eK1Dsr9DXpK/pEboRT0Gl1ZL3DybiYHm+Hvy7iMbyvviIraENOnKoPaeVyrLJAM9C/nf8Aj7qHkpoIXt8zWUDTnB1X8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442721; c=relaxed/simple; bh=SJ2BW98p81Na7BI7ENpdz1Wo6C3u+mKqcgpg9bZolXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nem2XMWshlsBibwSfw89hNZkoxBfI8S7k9gKRIhwt3HlqQnurZysK9t+0b0JP3//mAn8acfJ/IDOXCeywEIwApGnW7JJKqlHEKxSTlyJHzHMcLE6h4IlzuAlAt2jDPEkzqXpuxZ8YR6Px+BP2Mv8jIhtKBMzylo5KhF+g70D5Vw= 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=NkUTzfs+; 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="NkUTzfs+" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2b788a98557so26559045ad.2 for ; Sun, 10 May 2026 12:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442720; x=1779047520; 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=wePw3fvqh14IAiFXg0oU3SyxE97VnhTicxkSYMPbBQU=; b=NkUTzfs+pt2T8R5zOHwnHUJhS6sX5w+g0Oq7lLHAfNnQf9QKdCA9C+eaOMZo274WtR 15JigBDoCvyRLnQWtnm+jDcWDzkn/4xtSA2NqM0MacHxDR03f7BhSbSHq625k4fpoDDZ tcQTeCZWzw6XuIGPw4+18xJuYayuluNOqNGLSzxLNfLAqGGmk4L+P+O5LsqdWg+UPqjE krz+19wokh+XVs4Dt7G1I6gHAvbfdjOSbvHrtLVsIt0SV2FgcqDsN8T+hn8OlszJaZHV FxPMAM1Uke9ckNGXL1oh18rPMbRvyl69+ZvD9uZfAEyjzim+MX0HGeyooqMiHG0ddtKc TEBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442720; x=1779047520; 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=wePw3fvqh14IAiFXg0oU3SyxE97VnhTicxkSYMPbBQU=; b=Pwcg3IuKS7yafiwH/F+HSQ6uoPs27AUz2D14I/PQypEZKrReKWyvkCs9s+sqeSkquj eSAvb4Act7r6R71gP4VvveSJOggbyCZRapvKwvcUzWeWUbiLWDGTVBZhH5v8fMrxTlqU /oQ6K46tWvDq5Yjo80LVBE72gybVwlwqi5c+ZHTEZLVGkOpi9GMQPq52yK17BDa3T9YN FMjDLEiEHy391hXMMMH3WrMVv+XwSQV6bRtmHOYIXCrHEFbGcSFr+dzgexcHu8vV1sRm ++c2IsnHru+tUwAh/LrDdeROeJTZUG/GVtnD2tOzcCXAfrCt/ideyOMQZpvMlaCqI5sj DKcg== X-Forwarded-Encrypted: i=1; AFNElJ9v0g8rCYhmYidbLMlu7Ttlno+xhltirmmpGXLpnmiRII/TLfhIzsDgak6aEFBNx2ihi3X6QeOEVmH0RKM=@vger.kernel.org X-Gm-Message-State: AOJu0YxWUAAGglB1efOlSnNg6zA+JTdH0dwU186vlMXOf4eYa8N6LTTR /24BnsMhQZqKufnpGmY1h1/80pvkUHPDnIwCarRu0c/Nj9ctMyBNGOMj26sFgw== X-Gm-Gg: Acq92OH/jJn1scy5hBep7DWW1iUB1SBaZC6Lw+jljnZGTyNVDyQGWmQnjh+HVXez3kl neJ1p+7jsov8kNWSzU/ahc6WFP3kSXtTdBsjmUVr6qNplcK0CHUXqOH34mM2is0YQXZS0HjWhw4 xcP53UL7eh3h9IalhR7y5Ew56/QjFZtg9jJW2yyvVCunMMzLleXKLpGU9VFRtTfOTAd2JVRv4HG qfx6zn4sEsSS6X1PKuadNioZXMfIYP4ySZmHZYLWAT0xAvgeZwAKgHogoxyxFl8bO/QSYbLvdxM 7ctT4pzykxq50ULDUVTrlsqP8gnvsjOpCbhBQk/pcHzd8WM1G2yL27/3p8WhSkwzhLt+rPE9Pc8 MzZukBrBAFs1d85HOtKqgex9KQLhvEdK2J1nETwXdJQK3SSa1lr6GaqqpPPetjDxaSaPy1K6/Yo PBo8tPkQodYNGKmwCrcQdNYPKP0CLUButqsoASkz9yKYnktIlQPYfMQjYofxbR3wNg5Y4oZFlVN GzH8/LF4sS/cQ8tVmZMIWL87PRD+VPzgh5XvaGXvO4sbV3poQKyq6tW3mCjPMDAuc4E9UYn/tdF KrtV3A== X-Received: by 2002:a17:902:f70b:b0:2ba:5e44:ce8f with SMTP id d9443c01a7336-2baf0bd5421mr116260325ad.0.1778442720061; Sun, 10 May 2026 12:52: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-2baf1e358b2sm77065095ad.54.2026.05.10.12.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:51:59 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Date: Mon, 11 May 2026 01:19:30 +0530 Message-ID: <20260510194947.31997-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 24be690c371b..8da39d2801cd 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,8 @@ 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 04:48:55 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 3B66D196C7C for ; Sun, 10 May 2026 19:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442760; cv=none; b=XIf7JKRN9oTv9HtqkcP90E3nLIu2I6bSngSTuXLbHUiM6rhwl//TcgRCOhGbfaUlLWllV9sW4wSDbqv8nu/GI3BR8r3xw/wYzmxPaxnos3Q4jy1BzCQO+NFtNLjJBzevy8rBm+dRtmwNbq62N+JLFGN/SWfqB/mOilpgdGxcn/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442760; c=relaxed/simple; bh=szr91X0aX1oiL+z0YDbJm/jeuKLCyV7ri0mqBGA+Vhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rr9Y81m/HZjMsUvFZzqWzyDi4/u9IaQBWkfvgRLeVp3jOuSuP8XEFFxwVMg/G/sEcetPJfR2zWZ0ZimODbHeGnGb8yvxA6iPOiwpW9tarlPIphZHcGqiEDh+xYAHXA+i5zTTTDANRgAURnxYvmcdnxcHIUUYFM3c3if5BOrQ/TA= 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=TMPq664W; arc=none smtp.client-ip=209.85.214.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="TMPq664W" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2baef9f5ecdso17787465ad.1 for ; Sun, 10 May 2026 12:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442759; x=1779047559; 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=qGdRP8DOxTfqMmP41Ln6pwyIdScELpEFLbXpkvVWa9M=; b=TMPq664WKsVO/G/14s8GWChSpnzzOKbMOHOu37CRGeB7md9y426b4SAymPhqS0Ef1T kGoCbD/AnCvAyD3K10C1emkoVphf8QKUuqhAPL8noMKx4MXGUrpBI8xNRtEtPr8TvWf1 9FmqU4PkkP84CLmfhP+dL1sBnRovY4zQGyvyUj12SkT7h7HxYZE9zGVwL+iFe9E0EnHT E9fQle75+h4axZ9pHZrbusIHCa7rTuRHz2V5EFhJyojgTEQJPsQW9QqIXE5pTnH7Hwlq oo56xmPno7gIdo8HJVe8emx5rVQ9M4PALDODN+RaBxIsqMVqa8ohnTuYmKctWg355SiZ zr3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442759; x=1779047559; 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=qGdRP8DOxTfqMmP41Ln6pwyIdScELpEFLbXpkvVWa9M=; b=N8kFNAqqDP8k7DEckFwbuxue1NxyyqNjvyysNY0zGcw/KSE/Ee4eYHtbnjsvVPRcqD 7Uck2KLkg9AIyQsLGsSPskegoWHm+lcwIo5ItuwYo1TTo7muBciVKiHuseFqXrSkHIIk wY2n0rHBakXl2GI/rFIJvTLZn94FgEeeaskzP/2sq24etuHzaQ1V19ZxX2jxvK08XHu4 4afYqHii6CwHTmQMKr9oLVgQH/t9trIWWbG/xBtxi94TJ7kSFVpEcE84TZxVwLKMUoIG n1Z3nfOBd4RffNiocs9Rv7tN4/bS+a8hf1WEszQ2DEEjwZHbixhcG1NnQqbadVAQOK0m aajQ== X-Forwarded-Encrypted: i=1; AFNElJ+gn0ly6UEsDal2k9iM0ISoY4ruO6lA1OXr2Oa9I2LcAlIh2lC0utLqbDIgBAOiFCRWC3rHBGaGA3KPyBU=@vger.kernel.org X-Gm-Message-State: AOJu0Yycc4N+Kny9Ll8nNxy4dbJ1iqvgUiuS587Er8tRfdR73g3j5A+o ewCR6YWS9gvJ1qAcK6ONnHmDq1VJhxNfk9HeM1VsSs95D8vPPGc1Q9we X-Gm-Gg: Acq92OGHy+0jUDBLhWdEFf47Zg3DG1oKIXTNYOz4rcMHTM8w7hFQ+bruUTz1skypf5z WHsZ7Wy6LKNh34UGgnX9yAoCZE9lUsG5axCm4JB6RFij4uLq0rGm5sL2rlyFAVKJZOzzXg8jWVC kQnGLCCzQtxKD2HrIzbQCD/mUOLiczNs3bL/6rxEXMt0C+NOQtVzMWSxqjx5PdBF3SWvohghOXr AjrhpjFlMH7OcqO+WShSNsj64iEnUFY9SviEWsSGrek/b1eWGPRCKkO1i3lM2DGUVlQ1ao6QhPR JT3ICcSKb4j6PVW0GKkYDD+EYpbQ9mHYUdat6kC8ZiHu+X4TTx0Li1XTlQcxRsermjaVsrZZcGA ubVFIwNmiGlgtg85MMeBcgntSj9u+vaRxpq4WEnT9JKJ09/gFgxLQXr2dqIaUGwhyjCeoIrnQfS 7IOfY4sr3XiZqb3ye5KKi/G8fIse1DGrK3iJZWQNnpihxozfbJVM17fKtvoWdrBw/hNBIq+Y4Rv cGWmuaMFnAACKRUGMkls0CQFamIG7FVIRgxJlj8s5Qq7TUuJUSeReJgomYqtUthx7JgX1Y= X-Received: by 2002:a17:902:e74a:b0:2b2:9d60:5eaf with SMTP id d9443c01a7336-2bc7a97bd76mr75042445ad.6.1778442758645; Sun, 10 May 2026 12:52: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-2baf1e358b2sm77065095ad.54.2026.05.10.12.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:52:38 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 09/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Mon, 11 May 2026 01:19:31 +0530 Message-ID: <20260510194947.31997-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 8da39d2801cd..9f17cbc6c2e5 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 04:48:55 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 11B962253EE for ; Sun, 10 May 2026 19:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442811; cv=none; b=EYh5//PimcKH8cfHhm0yNEk3bF1G4tAp/fP2mWP6QZ2yzQuJn9RD6hXQ0zov1WpBhQzlpyoG//Sv0uIttMptaW9T1H5zwIqsgzDL+VbhlfgFDrtiaCYwaMw17H4Zo2DCOpSNShavlcpILdIf5sd+AGsOiv3eK9P4jBfqtftk/Mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442811; c=relaxed/simple; bh=CcWVM+e3vOzvxPMHiHam/ZARcRos3URB+mD1NEni2ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aa6uXVbfkCQzH98yrxw3tTpdmC/GMDFaaqfoynlYim6D3Sa+4fHdcUa70ue2hn6lhnn9sMivquqGq4DU0BC8wIROqf15SBDDHOBeY9vvk31+PX8FKXa3sj4iMo38/8j2tnevIO07yEiSc4Ns8rg7Hn6aijoPWyqE0jgsge4rKqE= 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=HWqoo2SX; arc=none smtp.client-ip=209.85.214.175 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="HWqoo2SX" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2ba6485d219so22654935ad.3 for ; Sun, 10 May 2026 12:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442809; x=1779047609; 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=Zq8vqJkGxKnQ4HZxEPkyCpyl+unJgqOC2VHF9A/dltQ=; b=HWqoo2SXrcAwcLVoxkIgD+j0x4+3ROIqH7KRFVsslQx8rO4CmowrJYmRpaV2ODWmLw SJyIw13RhPVLhLrOSvbVsMHxgGzu9ilpHjYJV4yo9penjVe0FLqWUbUaIalhf5oLb4j2 MdBxcrO/J6ia1yW1jzsQW253bCEEAAsQLnHtLNSOtkhY+fuDD1sJtWAyqhZD2dQ7apFx UbCs8gHCSHYr6cRALxpu0wqS/Lj5tV6m+14GTWKTp5a+083oM1bHV8LcnUCCoYqZZaER 4yAwjskLVGzrMfM3csY5YhAyiI14MEPGwqlXliXObC9sunOOAcqoJVel7uwh2WALGCwC j4XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442809; x=1779047609; 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=Zq8vqJkGxKnQ4HZxEPkyCpyl+unJgqOC2VHF9A/dltQ=; b=K9otDG+aQDA30A3qIW6Gs9qXXzrhmCeAzFYaiVVquYH/h9Bh3sen8loEoQZfq0wWLk 9nnu9+drdmQcmZ/3yUXiOGSej/gwhIXKA4lSPNic17jhm41EwzvUowo3Z2taE3Zp9S/f bUmSY1Zb+lw0MluGHqbNyFPlj1vvGmsyzIVQgwUaMNJaKsxqu1TGa2HsaLDs6vJKMZA6 fwkiR5Td0/xfYZtoNZdS6k71SXjWU7h3orW4JqjaAWEdnc7skRqWLz5Jalfgc2ONrrWC YEtElS6pEJOCXcr/at4rQ1CJNDTofYAMVlV0Ui9f1xrnPb1Iqv3pLRRAgS4g/Q7khwVY Wcbg== X-Forwarded-Encrypted: i=1; AFNElJ+3mOiTTlRLOLxbYx9Bku1dQmNMhe6SJN5y1jeNR6Pd9EAwvEaxmARr5A4BpmYAeasUAlwOfUM7yWwvzNw=@vger.kernel.org X-Gm-Message-State: AOJu0YzFmqfXSjkjpNSEiG1a3cjKuJKOpgs1tZvIo0zGrIw5O71JgLCB AhE1sw/kukt81X/kni18u8b3AHM/VgGva7LhIEFfXaDg9ihoF/f4f+UW X-Gm-Gg: Acq92OH4YZtVxsr8bL5aC+0D6y8n4EywziITFV/PmHQswj5/EeHuAsNAPFZPGYwqW/u Xv2Yo637knahoe26SQXvR44CpBO+45YbbL7MNmBq49UEcVHL5rLSp4JhU2eqmYWKdRfm+1qZ0JN B5i5SOIyzeO9Y+470dZlZu2pDslYlyaIR8T15QzBDs0qeMxCFfT43i/4C88qSQT1LkriaKn3/LZ lyoR/hRhEtqq9b9qY0acO90QKg83FHL6ApOebq3jkCQuj5dO1V/LV7zLxvrpo24EoQ8nDdR8Hv+ 0UJ+yLcXax/855MfK9P4pYzL+CPde15SxGHBI+3+dG7xlQHaqtizVD4my3XhlkFcwJnoGBHfSlu zD/SldLRHdaAvodEA/BoK+Ag1TB9IpKRD5LJWj2Bg7jAQV7v09gjDXy8HLdSTZeGCuz9c0UGYuo 9UUuxGnEbKul1UekerIsRyniJbOJKKdd8DIzmeCotBA7ZMG6T18wT2PWYEdLkNgFNYX17uSyoa+ kGGPDabTZSqy2RZB8y3G55kMgZ7EpI2wBqDPF632THJm4s/ClFA3LUzKmteID1v8b9y7DI= X-Received: by 2002:a17:903:3bd0:b0:2b7:beb5:3002 with SMTP id d9443c01a7336-2ba7908142dmr230533385ad.12.1778442809329; Sun, 10 May 2026 12:53:29 -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-2baf1e358b2sm77065095ad.54.2026.05.10.12.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:53:28 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Mon, 11 May 2026 01:19:32 +0530 Message-ID: <20260510194947.31997-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 9f17cbc6c2e5..860f8ef5a7cf 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -268,7 +268,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; @@ -282,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 @@ -300,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 @@ -390,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 Sat Jun 13 04:48:55 2026 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.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 6F7DB30E847 for ; Sun, 10 May 2026 20:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778444832; cv=none; b=YIjendGL5GVu+QNYIa+S6cx0ehmIHM3VwdWCmLUs8q5+OWiQmCtA36bPqPBOzsiVZuCGJcZYrAzcTpyENlLKf54m7bL/O2azcWK0UvmE1bxTxOFXtWBaulcAEWsNFFYv6yWWuqu4J4B9z9K5r4Dao9rxuOnXqMBC1pXbql3JwaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778444832; c=relaxed/simple; bh=yI719AbpDItm5QLKSF7cXjqJwwvZK5DfBOkIkRgOrVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LY7noFGDgLZj88pHxYVSv68uxHeucy1XVVh8W4FjFIAWb5IM+ttU0r+19J60xRIynHfUFcXWmrQPMg2W+rOqnCdHLanjUG5EYXkC+tdal2QEFUm8ZmNV0ZFsfE89+BPeFBQJ0KAJUsoqHvOwwcar1jt/hTTSPiSKpyibs3S2HGQ= 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=p+/HRigZ; arc=none smtp.client-ip=209.85.215.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="p+/HRigZ" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-c80227b1f6cso1457075a12.1 for ; Sun, 10 May 2026 13:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778444829; x=1779049629; 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=op2elmZ9t9E3doPcSF3XGeDi060lHA3vYpa7Xkj8Lag=; b=p+/HRigZdIt+ZC08X1h5x+SfJi7EIEMW2KrqEhyMTE+m7D8Pnm/2AVS1nRo7qN2xM4 xd7Hlu0uUO2tw5norzxYjGTRY285tXVckRRVsMRGwAZ79u1U0Mv81BlJmxSq4dDM9HrI ZA+m+tcPWoGWQoaY5Kb9Q7gfK5bfpIsFLUAUaX7xvICo7ScKka5aKalyvf8ldlj04Q0B AMEhGC57Xov8sPIwFM1WnBsRh/9CBa2EflzKXgcukbOCzqmGXa3pTZn80mN8p1fKCs+x bF7Od2j1uGzN4M9aRwEAr73W87S4o2XPkR/p1oE32D3Vi1GclHB9D9vYvCbXP2rBpntU o9qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778444829; x=1779049629; 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=op2elmZ9t9E3doPcSF3XGeDi060lHA3vYpa7Xkj8Lag=; b=CH0OySEpYPL22UOKefRU8J4wRRec39jgI+5Dz54AHDdyDKMEEV+x3PO9hoiHYuK3Qo npM/v9xwrxULuZdZOn8eqkD8HGDvQ0CclQo1Ohosn0KAlVuC30DMSWifzC61wmGjVnzB bJrz3fktffjxmZK60USxNOGhioCUfIuog6RZhGzbTI5pnv1tv0xhSOzQIxX34JlItqF9 CPU3c6GFb/6ZJlO2ubzoI+C2mAz/usmca1srCdYLbRnjENxoBrAy6du7yTV/JRhCirAM 9tWmGqRIFZ5XOF4SE1HowmlunKkHmwimqkur6PwFOxUdHHWoE0uN4yzqGfoP6lh9wRTT X6fA== X-Forwarded-Encrypted: i=1; AFNElJ9eErkmbGc3Mv0vY81Fmhz14Cxg87AzaycbDOQI+7ok1iBqsYX4cDmhbwtQKR6my9DSOoSYRHGGDD7FifE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzr2WVyjajsEXaip75TvhdEHhVSPtbbTkMLr6QEW7tpne9vps0l dVgTp4RmPIvK4uiP7tKfIPNeEW8EmHruiMqYYLZnyQpZYHkN3Y5FWg7MLaMO4Q== X-Gm-Gg: Acq92OGkPaalabPlpNDxbLHNruYU8meZ841kiRdP7S3nwkWh4wJ3C4iHyzt5+yZbw9t TZuUumB8yG0oAnYFJoAUm4/of8LbxlZHa3r8Tu1yYaEFPjcy/YO/K2QUuWO2RJmVPOtbrjnxOZ5 ZiFmHNB+2Hk3UKTrVJb2YY6ch9So5A9BWLls8oXssqPebZcYMJVkFAk2aZURDen2LsUyiGPAPRw B3pxO/VygS3y0T5iT+Ipz7NVPBN3vW/1K/R8UrJ1hMUvUrbc5u6Rrs5uGtbMVeBahKGSyFBV0m1 SmpR4crq0BUWPrRIlG6MA6WcsE6LsWHSvEvyiN+VPKpOr223XT1Ci3e5MJkzbzN7WoKc2pyfclF vl7UA7Et2RQZjo3ixQXG7c1MJ39fT3NHrIypQxqHXCUzNE9E2Xqzmav9cHnxXaJ0sY6+/WE1j41 WRsUFi5y2V8DnyDQ+Lh95fBHJi/yAOBPcAN7e689lVfsRTIjkd/yWAFIn2gkkduCgnwJVj1UtaU TmYwjSCsg1Y/0cj0xjFIWoQJp0Pk40aMeT5d7FYMWjrdlHI3Qv1lHV2E1LWPGp3VirYBzc= X-Received: by 2002:a05:6a20:734b:b0:3a2:ecb8:56db with SMTP id adf61e73a8af0-3aab17b53dbmr12950078637.40.1778444828682; Sun, 10 May 2026 13:27:08 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c826767bf53sm7060073a12.6.2026.05.10.13.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 13:27:08 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@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 v7 11/11] iio: adc: hx711: add support for HX710B Date: Mon, 11 May 2026 01:56:55 +0530 Message-ID: <20260510202657.38326-1-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-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 | 179 +++++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 24 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 860f8ef5a7cf..d96915902108 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 @@ -84,12 +85,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 { @@ -99,14 +104,22 @@ 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 + 64-bit naturally aligned timestamp + * + * aligned_s64 satisfies the 8-byte alignment requirement for the + * timestamp. For HX711 (at most 2 active channels), iio_push_to_ + * buffers_with_timestamp() places the timestamp at offset 8 + * (scan_bytes=3D8, already 8-byte aligned), identical to the original + * 2-channel layout. The extra channel slot for HX710B does not affect + * the HX711 ABI. */ struct { - u32 channel[2]; + u32 channel[3]; aligned_s64 timestamp; } buffer; /* @@ -207,6 +220,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; val =3D hx711_wait_for_ready(hx711_data); =20 @@ -226,8 +240,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 +300,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 +342,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 +513,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 +549,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 +618,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 +669,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 +743,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,7 +761,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