From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 BA8B23E9C06 for ; Mon, 25 May 2026 10:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706308; cv=none; b=N0z68Vc5AouzBfpOIZeeUx5K6RpHmhvPSdh57ZlYE01Ynogt0JkvTsXYgMhCRJ18ABn0SBhFsDWfOwt2yNpZGINkQ33QJBbfk51bWuLSkWIELSwDnTCBtdkoflWxoPB7VYf49Y9XtPFXvcijB0SuKsui5DFyDKPJ0xSEg9WiW9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706308; c=relaxed/simple; bh=fGN8QACq5acyX3/tm53OfWk81sTlEN73wII2m7as1Oo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ex7v8scGjeLZL7G6qZGaNDTSgvK4e4DyVyuH9ieiWn0c83Fiy1lnomXfE3Lf853+MTi3zSfAyvvWEjzqnOFVr2JaTrzE1QIN8E9aD7iNgPDhJfuM0kgtFQXo7/4BqEI3yvLSYvdhf0xM2osVp5mxboGE4RBuSSjjGl15rJkkEHE= 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=FlK/JZGf; arc=none smtp.client-ip=209.85.216.45 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="FlK/JZGf" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-36931e4f5e8so8801051a91.2 for ; Mon, 25 May 2026 03:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706302; x=1780311102; 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=FlK/JZGfALU3zpzsgZQRkL0bE9hcwMEnyz2P/DT0Zl4usRSuQUB0zv6zBy5TpBSwkz KcYfshz0A7ctoWjj0Mz4bskHGX3RcIuWYZ/qxlMyFF5tmvK95TAy66xzO6+gudB2yCBR q8ZgoTf2OpFaPIF0H4n9s+hnmGV2qoDK3ZTKTMcdz8mgJSPfZtsbTuUjBQDnJszhrDRH G/IMtRSOzNCEiOXI8fegkApgiU2mswc6kyX1rG97Mk2tw1HUyez/H4smt3yw1RVgSrp2 knAykL51LAHCktFnSm9xD2CNExbLnulQTfh+v2hQCStmkuQVc2t1eJhxar8+AAKcORkg tGLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706302; x=1780311102; 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=D/Mmr9xXX+pu3kFFK57Yp5W7l6vpNBsiv6JUF+oWr2CgULhHW+Pdie68WlbXbjmm+c ZbvKVhZwC+flsNHt3fAaxczwnVgDEiBLsZjmAUK1REyhRju4IReuDN40+skiwEGnLvAW D2sILKYRj7Sy9sruP1boro6jz37DwsfPDZul7gu7WNvytew6UeqcctgETbSu4yrtiP5v 62iCvMNgcLCnGW1wXQchcHUiZnOC+6LDxD7uF70ZUV1m6mtDSfJjO+05sD6MDTXiSqh5 DORZegm2G2U/4BiJkpzS2GVBFJLLjAimhTjdw9TegqLf/1VltEYZBoiwb2yOh+h0hxbC jcWw== X-Forwarded-Encrypted: i=1; AFNElJ8PjvYPqXZ5cIb6COxxuOsi3ZAMr2NTOL1edDBblzMGwRTbmJEu3rwk9ninTC6dipIC1/KArVjCvoxNbhg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+6rsqqn7lYp8fZRWzzH6AiEffC1B0NUICyx/xjH7p4LwNFZu7 Y+pAn8XFXwuitrKVIT7UQ1b9In7PRp+6uzzA+TdBoQUkqzvBJ7y65r9Z X-Gm-Gg: Acq92OGAsUGvJBSFh/WuVT9XahJhgb2DWZZ54BcBR/O00T6koXBS83Lz81dWWuNmivn i43N4pnHZiHn5uVxmkHZmOUlMYlszZui4jOnAjmnhE4i3eAaGaKg4IGeOayjWQCiTBEE1bMxB8e +BdAQfqkqWHqy2I/qgVCY+oy0ISBXvU/SsQ4/f6ITr3zyLybnYiwcc2xKgT7iuqLTBFuoJiAf4K TTqQkwS7cwDNw2mOn8RRMI6uM7NgyFAgh29IbdTRJKywNVCNWlSzmeApm22R+t2tjCPCfOcVc4X lcbA7kPOIvf7yi/gYBVnaLqW+0fokL2IMYEJXCCYy6NQ9gWfiKzAYArs3NRrDk9tTna7h3bSjaA 2nlBM9FLqBj7ZAwu/o2cDojBTwtAkRfEGhPIYJH9tzA60n3/ep9BjFNMETcyXDIFOkS3W0XgsLk z6duPOCjc1vj+Fi+EoeoeZ95NPHeAzvdp0Ee6FXcGO1xF0PcdQdl4kwW8yNHqvZnyC5PLaYyJrq jEJDnXmJb2eG2dRqwooOsw6kq8H3RWWUqTenFxM8w== X-Received: by 2002:a17:90a:c110:b0:368:341a:a925 with SMTP id 98e67ed59e1d1-36a67616959mr14192750a91.23.1779706301802; Mon, 25 May 2026 03:51:41 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:51:40 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Mon, 25 May 2026 16:21:17 +0530 Message-ID: <20260525105127.180156-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 874BE3793AB for ; Mon, 25 May 2026 10:51:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706309; cv=none; b=IT4cujXSbLuvCbgSDoAmYbbY6Hlp9GhnAHbRx39B7HE8HiJEYHibNKLUsmNUGVYeEwF5tT/530aw+DlXQbFZZdGMd77B2iWu9HaDhb3dhSGg2ZpbkYsufAnW1FkvhWt1pJHFnEM6qPjgJ8l7NuN18Opm85gVt2iyL/GSp459tso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706309; c=relaxed/simple; bh=QtSgviyssTBIh+gpFF5oWYlI+wnUX6VDGWmwQj4nPj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SMmjYppg64KmFilnuQHro8/qqJwMNXTV9W2jGSuwQ2pZPlCMEYPsw0d1NkIgKWbRPNCGd4Zd7J6TvFBdRrkMMQ8SzhaAVFXZE2amfie/axpGv5EGU/FYtW9z3LDwHyUIBHBtZpKZQTpeUW3pPC8z/xZbF0ElEyjEuzNCdEM/iVA= 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=m/fU6hsW; arc=none smtp.client-ip=209.85.216.42 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="m/fU6hsW" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-368f25ff4c4so5193470a91.2 for ; Mon, 25 May 2026 03:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706307; x=1780311107; 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=gK5p5D62bxTBsAn+SEu49ocLQ2IY7s+ZtWdqBWFj84c=; b=m/fU6hsWYm8YZJ38EllPAKS6N9wrzCKLL9FncPvNMDRUTA5cL3mz3BLwgI6bnjUJi/ De5Jj2P4ERqTBOjOUG9NzTnlfgkD3oWLDEeGh7dFW+dxY+w8fEWcTytqPPuIl2kw+Ff4 MbFjzK2oyNYlakFJo5yOtgmdMkzzHai6vTBtHEo6eP14Tcz1cENVt+1FI3K2vos/WdU/ VAoSNfQbV9P+kqxKefpmS7bdaD+mtxxx8AFt36ipjXP13Bse7jJ6e/BJ95CAIZ8kyVRf Jd82+CUiCqCvPYpzMQbOPWh4N2zlEVkyh1eQI3mQZwv3mWCGalC5B4aOWew5O53P+re6 B/4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706307; x=1780311107; 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=gK5p5D62bxTBsAn+SEu49ocLQ2IY7s+ZtWdqBWFj84c=; b=GADa3oRgnsSwisj3Dm2F7aGBedkLu0BF6rG3GNYQX41k93ePDn2RXp8L38D8tOv/pa vnTmui/2LR+LS1GLTHCCK1+YAm/j5o6WYAq2WHK2Ixkw6z0/9UCPC9yPSwrkG6DUBPx/ dRqexodW2huc8mO8NksuTdro3FMm0OsYYeUw178TeCdDKkC6QPGCBUFrfXaOtvB/iMPw xOcFI6KQoSojUriqkg84iaKFLLLLsXAnUnyfncGwOoCnU0jl9YASNL4sYCMQxv83TxWI ifM6+FnIPzwpGMrUG1UA84SkJ78PtSPO2DZJSsJmsZ6tgSAh5D8k6s08SJ7lbhxLoe91 7LDQ== X-Forwarded-Encrypted: i=1; AFNElJ8W86rMWSIpCCGODYG7atfSz49xbqoHaufIUPDwdAJzuUQWAnBjz1dKY3c315NKKT9Toc8/XcnvQG+qJLM=@vger.kernel.org X-Gm-Message-State: AOJu0YxSNchSjQHPOF1pQBzsB6oWBZQ5FSlR5f06BjtGNMpn8bKZPVbJ 1+wdk7sX7PYM2PWb/Gfup20BSP2+vIu9HTk2TaIfgNlvyZ2efKOUTIR+ X-Gm-Gg: Acq92OGwc8QADMZCp+UzYigvxjZ94ZB4fBmOMDsHJRa1XA/IVpO8/HvhHA9tv5dtJAa S8X+jezsvm4Rp6+3Mzjo72q5DbCaujgflEVybBto9I6B4OY0QYXHOTSwLkb4JaeKqbn0aK+VQjm eX4fCSw0SDib4IJ/pPFroXSCLCh2eyveBw8ooggPUXLeh9Z7VN6ovOp8Fq834k88AwPQP+CyNPh iGPYYyJH0dB9eRTRV0lWIeMYiDw5+zZgkQHHVwTb/a89A7b6x5r4qMv50mM8VnW/1uYib5EXmhw 4cce5nRw3wKPaNWmcJTnpdEsRcR+YA2xgue/6sCXmNyDKxxQhFFpf7naPelJUnzTIEAxGAsFdmG DHQqfvIW9F7l61qu/vCE/jmjYPcZ8dLH7o4BlRonanFxnolzBHcVJBoXJ5WRw2uTI/RwwdYMslo HLJinT3lUIEfMe+GFLuK5AEgfpUdfOPgPpNxtD5+B3Sa5DFwDRwLSmUbrELEhR8tSnT6m//hzUR oRrqdzHRmPCQ+ietNUAvegThU6UdomXMFzX8lgFt1EIagppmY4uWOYm0GI8azA= X-Received: by 2002:a17:90b:4d0f:b0:36a:6a4c:17dd with SMTP id 98e67ed59e1d1-36a6a4c19a2mr14431253a91.27.1779706306855; Mon, 25 May 2026 03:51:46 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:51:45 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Mon, 25 May 2026 16:21:18 +0530 Message-ID: <20260525105127.180156-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 --- .../devicetree/bindings/iio/adc/avia-hx711.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 1ea60dff98d5..0baf620e9057 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -33,6 +33,19 @@ properties: description: Analog supply voltage (AVDD). =20 + vsup-supply: + description: + Supply voltage for the on-chip regulator (VSUP). + + dvdd-supply: + description: + Digital supply voltage (DVDD). On the HX711, DVDD is a + board-supplied digital rail; it was missing from the original + binding. On 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. + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the --=20 2.43.0 From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 2BB0A3E9C0B for ; Mon, 25 May 2026 10:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706315; cv=none; b=TotnZVVvm0y0mPsFA5S6HfwU8PvrwfBRbLY8mAJmwLmXfu947sZ+q8o4Ynqg9B0oQ8bLWa5IKr0bR1aVO4pSiiNb07p2V747rYwCE1u7q9uUlRm5SzoWr9ndfu2YU0zAemHCsaS3bhV/utpiTKKGumqrwSXIgBQBupvhocw366c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706315; c=relaxed/simple; bh=EoAF4YHy3iYTq0qtbpAuxEpwDtw0CacTgV3exikXeKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IohkL0on5OoimVdqFRcEII87nVkbt05d72q8OR5pVn0r8dYqBGexITLJAylGCW57yw9OI5LDmYI9DZwAWg0phkw2kGQ2WwUR7u96/yRDodqV0kfx79DsDTam5Y71PfsCLNDK/a79Zu9MXQYT69krqQNI15rQgyhiPZ0HzTrsLQc= 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=HxJzXkQ5; arc=none smtp.client-ip=209.85.216.43 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="HxJzXkQ5" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-36931e4f5e8so8801213a91.2 for ; Mon, 25 May 2026 03:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706313; x=1780311113; 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=ygX2OtS8jtfRsEiUpxVA4rgdEOhC6dRMuJ3m7A2/544=; b=HxJzXkQ5rxe5Rd4uWXWIjPaVgR8KxN2cTumIZeaZaned0FATuWmH5u1zHCv/QvRi5O 5G9gQTUmxUuBHEAhqx0uuZbc2BPkyvgg3cGWkptYjBw2Z+5GW5oVlkTHxAeusqSCFxUL a1B9lNbgtdBjdN92/a1eo1L3szpdMoAMfg7Tdnkm7M5tFA/gOWbc5z0unohNAYgwKPVD UPg+lxO78OZGb5aeM926Dgu8tiis/9OE/UI9zYY5X2rvQGNwXGNS3tkJPwC5Nd4ogDgM CTpSnxobVtT/N/xgsQAh2igywtKiGIibsVaDPz6jSXeUbbcNlTnIrh8XCL1ztQE0hDe6 eCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706313; x=1780311113; 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=ygX2OtS8jtfRsEiUpxVA4rgdEOhC6dRMuJ3m7A2/544=; b=CqQ54IImw7c/IhW1jxaOZfQzfuIyBRX4H0gxn5nS8M8CrGFZwYZvm6QGAtDNYN6b1V XeiSPf0ljL0vTnT/myNRVqWL+23BzvFtlXDKziN6eeYeSmrOSdfer1LzRuZn0XMXnawn Mwex9gze1pzuBXiNfnzLkcoTDlShCQB2wAJncYessF6DOSirzeOGc0+M7+dRQlHEF3tw 6V/zA5nTHfKIcsGEaQ0R4I0VuQO6fl7luh2TAsuOzGZ8vOLZ08qOa2qP82HdKKzgba3a SOWcsx3dflaFMDtns5wLDl3uLKWTbIkDqhoQLb8nL67iE5r+p3yYlAhzCQnafDF9x5NG BXnw== X-Forwarded-Encrypted: i=1; AFNElJ+3z29KfwVS3hss/+lOuLKD/IMsNuIN+Mgvh8T4I52tcowc1+yg7J0rR2AxTAV79IE3tUSXF6vYAiv/vDA=@vger.kernel.org X-Gm-Message-State: AOJu0YwCCCCa8YiEY/BHS1jNxA4SoS+kYSUq7IB7rWJrs9skShzy7MbL kIyBHUGrc81qYAD0KvjiyJgKw3FP1juti5JBLgQuhUyiTSl25o+yDifl X-Gm-Gg: Acq92OGYJRqdNdvbSOgTT/raJZy3VzEtMpmbn1OI4E6CzgW/KUk/+6RQxUrWEhr1JWt GCleolskh37wFNm9plvB3uZsNGjAMFpM89ZLFJ+7kBEpwiWxFK4/msVAejQzh7FtFKVpjTkow+Q 9HVuptiYl3rgTJqejqi48V4zOpNG2heIKzScm77HjOkzp62UcMsIlga42qDBhagZAfZIvxzuELC SdmdIrNRTBnB5hgQz6zCpybwXuG1ZuFzVyiJBjVaTzKPvtKCPLY3ANaq26QGOCZUUiDkRJymB1s loOyxMFFoJ12GerQG2uPQGGj6tJXsgL7TX3MlhUEx1nkPwGYqoleltATDmzONCBFUaNSPgfVw4f 5kFwUqT/SsmrM0quaCEKtVcomggqG95Lb4+zV3pkffqWqUdL56ndVqn3HwmkZZ5TUHdwZNDA+VU 1KymUrUlP9Mnqy+2PyGyFHy+DRXZqOJCCwv6kHZ6b07j16vBlrI7pGj57o1xA4lDagth8u3+p0z 9k8PGDLK2xqPM1nbf/YaDgPePk2iNN01WFC1Jn9dQ== X-Received: by 2002:a17:90a:dfce:b0:369:932a:2b6d with SMTP id 98e67ed59e1d1-36a67402bccmr11933827a91.6.1779706313343; Mon, 25 May 2026 03:51:53 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:51:51 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Mon, 25 May 2026 16:21:19 +0530 Message-ID: <20260525105127.180156-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 0baf620e9057..099235b5fd54 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -46,6 +46,13 @@ properties: one channel monitors the DVDD-AVDD difference for battery level detection. =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 @@ -70,6 +77,7 @@ examples: compatible =3D "avia,hx711"; sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + rate-gpios =3D <&gpio0 9 GPIO_ACTIVE_HIGH>; avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; --=20 2.43.0 From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 417E33E025F for ; Mon, 25 May 2026 10:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706321; cv=none; b=omUQNku7gnCZxy46EYSgVu4vn0uIHcyRJwkLVMhfqgvb7sdU41cpxN0n8NuuTr99z/uHPamfIGk+lhFESYRfTVESRSp1mhyEydSHmQmPlNqmZzVa33Lzrtq3ZqE09PKurN4PUCW/l3BRCzM6cNK1KMUwNKhuDpfWHpNdFPBolyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706321; c=relaxed/simple; bh=cyVQaYp09rTmHhwDXV8k3udRvnCCwyJNeI/CPfraGR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UZUI4Q+8hLwdBkn0BAC0eLNNbjM7zv3v4yVL31vJ5HgDOjOLT5M18vgIR/naKLGuRVbXxNTo9SWXvXug7qvBjNtSS7JWVg7IEYkMWvyWoVwdxFVNjmOfZEQSHXwi91rbpGRIpdeFwtvHMieJx/3P+EZbOy7+hRETcQdU6Wgto/o= 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=SI289PxG; arc=none smtp.client-ip=209.85.216.41 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="SI289PxG" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3697c35eab7so5694836a91.0 for ; Mon, 25 May 2026 03:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706319; x=1780311119; 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=Xe8F6BBtHSCnTWy+Jvz/dHP4g87OMQse/dKMPfWduuM=; b=SI289PxGk2LrzmA4Pgaqv+O/WdeFWwr9qagJk3fg5KeYYl5qkGLWZri+SzC3XGtMKT Ckvb3ZAezvy+UkG94YZb3jYfIAuVMJd2yRpUXghJ7UEq9OSQUzTh/DbnTMFF/WLHE6St Gp4GxvJh83Qm/YPIlEfde2UtVjwelR6XqGrepUZajHpYF1vBo6PikvyWKC7H1p0hyqt/ PYkxUdsrYeiBEE0VEmer5q9axDigV4tJFnPlwID2xJk8lbjXCAQ+KbnL14F8PWOoJLTb JpSKhVkFjt2+bjZRz1TVDUmO8jkdyQWHBBNiD1cuNT94+KoTpzVlZhCYUU5I7ocLWESn kDUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706319; x=1780311119; 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=Xe8F6BBtHSCnTWy+Jvz/dHP4g87OMQse/dKMPfWduuM=; b=Rh5ZsOky7X+j+BK+d3RvOC9f7TCM+PNdniSki7QrFZ1cMGSJhuIIjDlq4PQ02Hv2aN 0pt1/OM+1MEj5ddOBhsqLcA+4vIjLWbLkxpUUpylSPpovnXvDWHIYfasVeu9XOrhbhGJ p8dBCLgDvcjI8V/sbN0QYTgd+yOet1I1ZowTLpKfaVhmpHyQ7r1sUQ1VizTuX/MBC9wp kwitX1Mr2973q9RGnHDEtZy6l1wSof7SnBSOqhHu0gUaF+IFV4eQWB/3VqbYRnArSGvC mS8d1w8tR5/ZvnkEdfhW4YAJI0oLZVzhZddc7WJ447oe5/RVQUJG8gCQSUxHPlAGJtBd ON+A== X-Forwarded-Encrypted: i=1; AFNElJ/Q1+AQq48/RGmbQvZRpUlS/Kut8LmWgQSIypXwLrPeI3Ry7eQ0ktpuz6HPdaz6ZRMOkjwHokEBN3CPAIc=@vger.kernel.org X-Gm-Message-State: AOJu0YxCxOgyHMFDl+6FyFJHzzQK6hfcd6PNnjSxOJ+GwDFlakO05yrn Hw+jeRWhuathZvp87mmfiHEBwaWZF1rPdC05miGZK3et+XAVyU7drDK7 X-Gm-Gg: Acq92OHOL43iOdm74+s3cwUL8UePmDW5SkgbZudDB7zGzBkWFTjRLhpYjezXA4era7j Khh5hOj5xVLj8G5vJmS5BzA3Rhw0skofKL5G/IK8e2F82uNmXUI+QP8MNmtqZ8qXP99WmiTO2cq tPonIPhFieSlP060Wp7g+3GH3wSnmk/GORPGqUFT/6e0UYFMEnlR0w7BHgM3YB+FU9LoVAtzVRi HEkbOVqNKSkLwTIZXsbQ3hakiwiv1mIu2Wl+yOzUBs+R2osduSKJlp1wsEUHR+4TWot/jLUPsBI BVrwoi0W4HahE9u26QsMmBwAA0QXH/YpDU3O9wZP+LFhNfTe1YkGAtfsSmliFpqknQyqEYYVsU3 /23Dih20nnsaANojpOei4PGJU2p/xrNMrxCK/h2xCs/IevXCR0XjbUR9NJVL7uuR7xwV2IPdwO4 8VIGw5S0XkXZEaV8dpIlBk5I2rWWKfeawC543JMcB9iAByX8K4xlhrds8Kli2EDw07iCIPuBX7L 6iKeW3Mqg2x6K+v4g5wOA3UPPEU8YYUFurfsKW2qA== X-Received: by 2002:a17:90b:3887:b0:369:a359:b181 with SMTP id 98e67ed59e1d1-36a6787b0dcmr13675423a91.23.1779706318473; Mon, 25 May 2026 03:51:58 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:51:57 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Mon, 25 May 2026 16:21:20 +0530 Message-ID: <20260525105127.180156-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the avia,hx710b compatible and document the HX710B-specific DVDD and VREF supplies. Add constraints that forbid HX711-only properties on HX710B nodes and require vref-supply for HX710B, then add a separate HX710B example. Signed-off-by: Piyush Patle Reviewed-by: Andy Shevchenko Acked-by: Conor Dooley --- .../bindings/iio/adc/avia-hx711.yaml | 35 ++++++++++++++++++- 1 file changed, 34 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 099235b5fd54..f0aeb15e9eb9 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: @@ -53,6 +58,10 @@ properties: RATE pin state is determined by the board wiring. maxItems: 1 =20 + vref-supply: + description: + Reference voltage input (VREF). + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the @@ -62,6 +71,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 @@ -81,3 +105,12 @@ examples: avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; + - | + #include + weight { + compatible =3D "avia,hx710b"; + sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; + dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + avdd-supply =3D <&avdd>; + vref-supply =3D <&vref>; + }; --=20 2.43.0 From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 F0B863E9C23 for ; Mon, 25 May 2026 10:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706325; cv=none; b=J5haFNHTRQmDBXtioVmOtvU6eGOEs2cVReAmkg4ynxAmahOlYEe94j+ObuAzpglmKlv9UsBJUWKclW2NcxVNvyKP44/p90wKg+FypU0k+rY9KeSkAcddr8wHenmq8ruHbW77r+PYBTj60clqbRNlRCYfUxz0V2QgeUStulmwLbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706325; c=relaxed/simple; bh=jqPYoYhLKYYlSYtUJdzENTM/X/PaYeN8NKoJ7tNg6Wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T/mVR/I+0iZ6SlzCjeF/6+3PQ/36PYudI3VMz7C4mgoS+bxPEtfFcnGfylla0NlOuBXTx3c16Qy/YBRLUivBUhiz/Hzwgsgopfn+lU1V/vCj6F5X0ZZYiTO6CFLl0rLTGcQVrK+wNOMcjZI2gHc2PkaumAg4QEFKeqgDShvDPLk= 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=raPianl2; arc=none smtp.client-ip=209.85.216.47 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="raPianl2" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-36af4b7840aso211599a91.3 for ; Mon, 25 May 2026 03:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706323; x=1780311123; 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=raPianl2aAU5SCgXT1HVAAaAbEst5RjcHjMgZMSXqTLot7y0CWP8Vg785j+ofSEHyf VE/E0xxZn+tKg01sy4UX9Vg/Woa6znSPJwk5e6UDE3gDKooskW6DohxST7/tHJ8s+yKi wNiaNRkzNlJDvTl6km/J/XyKabykRaM7y0imw+FDMEUIzVkv8EYeCXlUNG20pyiZlkHh leSvsUwJTU7jiKozkflJMBGzA+nJGpBUK1iIotWRdyw6nAh0FrROcy8YDRoQq5JuWCfT mAumT1LMHROhK+MZ9LZq673gFw9OzP3tx9pBoSw38rsZ+97PJ/4sNrFuR4KzOaiHd+L/ 9+RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706323; x=1780311123; 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=s5BPfIYePAlfolRK/afIYmRX4sPrScH5JMNPZmYCOKrcGIdoxNot+4V05i6p6hVbBj Qg9GvMOlFfYbsrIBgEOA+Jpr0msPpmQ3oKlgRDw2CcK0kO4WYPdHJegbyESZd0lt3q60 Bb8U/zZtAVFL9cDxZ5tUUSXxYXIB8wxZHkwsoHXLQACX8xxGkaj2jU/SMrCZO2/WsAxw LynvHPmSMfyeMsLsHiZFksUlXHyxgJYbb6V2I1AlcmFvjLZp2fSJ0r65YEJl0A9ybdZH I6yUF0ZPHCGUClexVKuopOqZjavACTG/0k0fAWYi0X+Trz2qqQjjiRDHHCg18crQO/1J v1cA== X-Forwarded-Encrypted: i=1; AFNElJ81W1tznH1Zsx7VoDhX6ke7SCDFZLWmb8f7AchINmwBNhwHzBk5eofUVPR1mzSul+UZoK+t/djsevytW4c=@vger.kernel.org X-Gm-Message-State: AOJu0YzfuUjEQKFZ7cNoswwGGM+xQ/CZ+anAt6et4T74yKL2xeFShVxx GQ83Bo/bHRXPk3Gjq7vtIyc/bhx1ldRJz37oU1Oc0RxEL83NH4tof9dR X-Gm-Gg: Acq92OEsAffZLJF06FEifRC2WEXf+yPv46K2+7p3LsBJT3RXchl5x2RymAdnNjicXMx s/Kts+nzj8VrwsBMZc6J8jblKH3gIASEhKfze/wKZnGQ3G8MkaewfHONGkQPVMivHcqsFBnDkvk k6EYsu9kA3ZydPm+H4NHJ+MsdCOIX9zdQu2N4DCdhDakGg/Ks5K3ynLBSctz3IJ2XMxB3xfbzHQ PDRJ9Mazmdpr3z2wrt3++TogXIuLxQIxMt3emJZ0OagbLIoVDc8pNvmnJZB9HsBQPP2GhU+JGP0 HnLYKPLysdLphy+Ek5wpuOLn+luFzcIlUEDovN/0k8PmucJl7wNYGtzhAD/q5DQ1DVHP3izNLKs cLMub5lgBZa+Gecw0tPbIJRRf60DL/5cIm8PI74pK60m60s+l/XYs65SmS/5kiEZW6KYSu0Fbwf how3u3AW5niEiFt6p6SIWWsNcFiFb/S8Nfj3uw/gQmbmMhktP48IAW3DAGVO/dEIfumk+1i+wht aDQxnw2NHpl3NY8G7MK2N1D8lckwCRN4dcrXblekw== X-Received: by 2002:a17:90a:c88d:b0:366:10f1:3d86 with SMTP id 98e67ed59e1d1-36a67616988mr14689661a91.22.1779706323154; Mon, 25 May 2026 03:52:03 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:02 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Mon, 25 May 2026 16:21:21 +0530 Message-ID: <20260525105127.180156-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 A5BD83E9C27 for ; Mon, 25 May 2026 10:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706331; cv=none; b=PpOOwq34Zk/LtX1gFfz8s2PhVwJwwBMDALT3Vo/lCYkPB3lq7BaieS7yfnPL3WcfYq1uU6IYJWXaJfC0W/ORdYqeKJuMCeXVPeFfWsyP32ZJVFwUZ1V817Pt9bu5nVLEScTErGKeR/QhT39ZTEN18Zw+OyAHgKgJkFlre+EggLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706331; c=relaxed/simple; bh=GP/zXsIk7W/qQ+UNS2wJhazgPEjZIr5oEO/HNA2gsAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ApmsY2Z+ipKzUi1NIdSBV6YEF0jv1ZRz316HaJYav6SXL97xLnYs8dbCkSby/Y7biL75QJlUiI58OfAxOtbcVttK6W6Nbq/tdH65neDj2hD8OHmTmZDBuUUyFNTCcMb6dDfBp+Jj43MOQ+DwG6NC+y8xWasUSPU4W2AJIx6Pays= 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=W5omaTn1; arc=none smtp.client-ip=209.85.216.52 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="W5omaTn1" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-369576666d5so4476355a91.0 for ; Mon, 25 May 2026 03:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706328; x=1780311128; 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=W5omaTn1Kuq7YRrg3sxDP92r72DQ/MHSWPFT82vziYYoerkSM1GW+vrdv/J/t2DIkc HBtu2vtsJYvezz0e8IbEGMnhiFOKkGiMSnBgSNKXf4jh8uF8Ja0OAejh5RXO6Y/5CZwL vfw44dNgKCVyu2hRWYd2BxMsQje+2qSCIlKFsHvkWi12XlmH77hpSIbshjzgVNarBbCo A2ButPQROKCi+lI2dbrRiPkFVuIah8252aWhiA8MCuCOWqpCuC1WJwZ73VbKDUSZemeR inuwh9NYMWTkao7+WEDc4fA63gH+OGHjJjahHrjGq3Z3JannqBlxVc9NhecfU1J5EqvM JKqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706328; x=1780311128; 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=fYFvByoKM2RUDzMLiz7NP68WYn9l6focz8tmBLGEnXmtXmsFqzE2MM+5SbqeAdcbh4 OoMwT6t42tjsnrlLusw2hJ0aOrYCv9fLfngeemwFgtBRX5PTKpiwWWkpnIdUqHjYmh6g mAO2osNcedFeyzTBD8rMrRv9fh/NJF21NHRAf/avAJ//+7oSba9iBNNtMpO3Eo2gkv6e blfSgng0KVVjnEzzdB5Z6kLt66mti8pn3Yrnkms1iXYplQjeE02z38jsFO/ApEyXFyJW zf4U7+zbwawEHSlfHhl2CwKKaP2U+YMLDlDcz8vExb+t3+pljzeVrjnN14eU2Mtl6waf Fclw== X-Forwarded-Encrypted: i=1; AFNElJ/k9XAji9trfxt2O6K/nA4tfNgIsUnofp7OWGyPl2vDmGaApX8wv4EYCvC2wWHjeOqY4RvKC0JwKwofCEo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp229sqzkL2xBnEqP8rKIHpONVActd5kgQSOwoN30JZgHXSLoG W9Qveiw2SyMg6cXDU8qsoqwEP3dXETedKcldG/3n7E9rl6DjmXMYSN6f X-Gm-Gg: Acq92OE0mwOkL1JFoOTu1Jejo95BU4eCxvfXbcDBdgfNbaFfRMdfsr8wNZcYJCHASyE +RTPuPWPSiSgaRdsMbLKRaMjTe0wX0p7xsOXG61ep9cRBedMD2LxcQygxWl5wLf0WrnYkIlv4U2 ZLAkyiCbuDtdoprtV3imgJaUD5ATXQ1oCQxsxliLP7xGLg5HeP6YpEnDnyyqsweGnzgeVl4D1/g dwKuYLS8F9qSYCrQ2lBiNDyqz/e4AuYQk0Ncf0Wy+UYhun/FrpQIxNozotKlLtZsJMUVX4vUffd mGNxXr13o7CyGDHZ/yhYsP50eHnQiGH/Zo8+2GzVD3pveS5+QH0TKAFwMeDXfyeGraXlvSIUTh3 7CR3e/JGiv/SULW1PsHgze2JtvbGWd16XVPuMEF0NueiId1554yq8SsjXGBv5aa2YzlFM8sFgxY GAsxQmuGCGMVU5vc3qnspTfLvtEc3EyMhWp14w4+Eovx7t9Av/SWg8cHOmkS6g/Vx4qa4tvOT+W wiPsECBJhlsKM5eNriPM0T9gJg/nVlRvM/qOxGkDdgH3JQkI7rA X-Received: by 2002:a17:90b:38cd:b0:369:2e00:1ff0 with SMTP id 98e67ed59e1d1-36a6749e96amr13533601a91.6.1779706327843; Mon, 25 May 2026 03:52:07 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:07 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Mon, 25 May 2026 16:21:22 +0530 Message-ID: <20260525105127.180156-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 Mon Jun 8 23:57:32 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 A99FE3E9F61 for ; Mon, 25 May 2026 10:52:13 +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=1779706335; cv=none; b=k80k1+dZ6H5wlTHSpeSwkS/AH3xXWQAfdNCU3qiXRysz/2nRAOseb7mhh5VII00WLCLUUJ1iTmZGitcMl4bOJ6ekPPc4lmtFgGSvvjoTwl8afMz7g92OFd0JwDsNTonU8Y984IrG4zMBm51fWxGHLw2tKXRgIQuO4OyUHDwyE/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706335; c=relaxed/simple; bh=aTUwaw1cZjKNO7pd1qP0S4T7HG4+2wRyJbUWydgN08M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lKwHpkh//oSOfQE8TMDWCb8iFNzPI7hnqm9BxD22y96hBM+U1v6DQebvUOerxXkZRYYayVJItShameIYfCN+7ACa0l5Nm8SSXJ6K57Blz8WyUcXy+nISTxlvxrlvMv5qiLKgZlqWAaKVIajCPB7lAhCQI5jK2rWON4vsV8WWKgo= 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=g26pvKJk; 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="g26pvKJk" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-36608b2f2dcso6231042a91.2 for ; Mon, 25 May 2026 03:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706333; x=1780311133; 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=g26pvKJk8kJkKq4DB+Ey2H5NxktwBMySmxYg2LknZX71pD9WGl5QnLA21aq66PIbOE lo89xOMrZsrNjWBVd7+n/UE2Y93gYr8m29p5muRUknrKSA3aGXxapxWnRjuf42Qv9hbB 8W/JDt9s8VVj3/KILDK/605zz7xFcMzZZsTd4d483hXxCk0bkslq4gtViW+awgIi3GGw Qo/NwKfsb/japKCVN+5EIgnv8/O/asGmROBG1DyB3FSvw75DV2p2QaeAM/LReCc63W7A mOph3eSdXqm2u+zVTe9+HXog2rObT+sT5Gblednrddr0wWjLaRt/pskLm2IoB8LuhM6/ ncMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706333; x=1780311133; 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=pfilyzTE3kF8CB+OnTrFtv7MrqTDSMeysCawraEnfR4In9/8jpVp0otXivipJhF3a7 LXGZWUxbxGVEmeNUvMfDFdGSd6O/jCHlPVVePO781M4VfPXdxAj5F5JQ6FjE8alBT8SV eKvXbs5lT0GryR/SwFxR6Sdzv/MuRE3DiAadz87eQOzWjO7l1i7mY+2pAgGyv7ZAgQ4y Ca3iI2JKzYvD6tMle96e/PUl+9Ir+9rnDq95TH8VvLArR3NnvW1+KwAcgHr64LIVGbLx drvqeHFQY2aw24u76OStUgL6zXmnXbvFqVi6EXuydImQqFmeKtqVWA66GB/3ZMuyK/kM bLIw== X-Forwarded-Encrypted: i=1; AFNElJ9F7gfCwokiPo2KPR/Bz3xvyD2kqVRVJic3W9bW6a3PLj/QozQPIVwYWFtvnvXWR04Ym1qkYF2j+uHXiU4=@vger.kernel.org X-Gm-Message-State: AOJu0YyJXEXsJlUNPmbseLEomRxCMzeI2YeDGWQ7GaZqjImmMfOjuPwV u0LjvLQkMss2nRH5BMTVlGSq0X3hET9db5CpRo41y3EwV3/hX/Q9MJe0 X-Gm-Gg: Acq92OGbDoerSlOScVSZp8EuOkb6CBSi2+30ii4sJNO76917uWUwdDvH47vIv7MJTzs tVjIXaIOErMkX27OBhPuRAh2NVqt0d1e9mg43Fwz26X7PKDclfClreE/3krqG9ZX+/TWVysQk7y EXZzCd1CeyckpwtwjkqPKDN5nOhNApOXgh+Juvgg14U0UqPu3NxUInqTARiycv5tDOHwTi5nKNx 2oZIjzR0jReuLCF7gtsx7NfmIgfGMxNIEebNFHcczZkaspOKtRGHjU44lU/9Vs8wYm5KnEZcKLD L2kyU/oRNQ7i3xEbW4dcM31JKz1G3Fg1wpc6ggkYW1gvwhfjTLZvCVLscRR124DVL60AMw6nrAQ ZTFdQ9J14aGOgsVMSSzTmaSdxL/FLpt65SzKBFna8fAcaXNv7wg6DgOROTFi544u3zsTmZATzog hF6qxX09uIL957N11baYUS4FJWx5jXxsIO7v0YU7BW7JwNDTi3n+tdE+S8EuxI47YBp5hr7N1j+ bBc0q9n+FmNP0K3pdnZDComeOI6sCu0XFQEui5ShNrkodd0pToO X-Received: by 2002:a17:90b:3851:b0:368:ddd7:abcd with SMTP id 98e67ed59e1d1-36a678a1050mr12493640a91.27.1779706332818; Mon, 25 May 2026 03:52:12 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:11 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Mon, 25 May 2026 16:21:23 +0530 Message-ID: <20260525105127.180156-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 D53C63E9C2E for ; Mon, 25 May 2026 10:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706340; cv=none; b=hbCgrxtw+hNGHFpCTJ4tRUhT9f4kCAQQkPSgQn/vxMn3Pw4VmetADDOiqyKUFHROutQxWYD4VTN6k9UusBIuT00+MKBSqeDgl7090i+1qcufWbKFCUP/k4u02/SfuqHmyUDKxV+UZfR6Wf7xi9MnAb5P4tVgmstfPOOInlbnqF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706340; c=relaxed/simple; bh=IyYb8UgF/AKA8+P9d730SEMTu3OzJGnh9mo/jac4tKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QbPvbUnW7Pf7OCnkClwTKQyUnXecieenyuvRcXIA5oE5uH0R8ct7sOsZ6W3L7zeLU3Ho5eLpuffpnIffo7pNVVuaK8ZtTfQ7qJLGcNum9LIga3iUJ3LLV+rAOPqSd4Lb5yl02DcZBQ1kj5AqKJY5G2bftzBwhypg4NSFR9GN8XI= 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=HnAlqXMz; arc=none smtp.client-ip=209.85.216.45 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="HnAlqXMz" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-36936dcf19dso4631889a91.0 for ; Mon, 25 May 2026 03:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706338; x=1780311138; 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=O1zPHIbDPv87v1NJ8/Wn8nmreCkN/BzTtCRIc6PgU/s=; b=HnAlqXMz4pjSY6XewYyx+fEW2iNHMKa19A7mrtobAQGct3+c2/dfpzMAPOlTVLTqf5 wcLVtTBfTRBfsgDFXoXHtkirGXI6PmKxPQ7zw2MWIF77SW140NfXxBXKqPK6zNzHDnwj KWvChcBCotPknH0DAUQ2ed/gA8imlLki/q05/3iiMSes0vIZ23pJGwk6fCN5/owh0cxI jTPGVAu0mf9MbHKviTPgfD4xWV967RrehZcZMaYWDnSd9UrqG9miP8RT+cxYPG4buJP+ s2TIkFiofmdq5gxVhlURbx/cT1B9nRRfzaKI6AUBcf33ghlVwxUW0CKcw71S/UYXkCrY oj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706338; x=1780311138; 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=O1zPHIbDPv87v1NJ8/Wn8nmreCkN/BzTtCRIc6PgU/s=; b=JnkWLF6TUbeJnX2dsaRw883fpfweYks2bGABWmgpKleMWHQ964BUpT5mC9QFYYkbmL Iq78saqDZ52kU66bIFcaDYjIUpy39qcMdNrgvY4JE0sNhNLxmsTi0gRWo6FvVjw2Bxud 2CcLI2VWm1GGAxkEjh7mDWJO4Cs+TTbrUbuDwEFnxeeMfAMwSGNvr1yn6mq/oyN+x7Kg ptkWHK3rloJhJ3a9MC3h+MJj/IoYvLecEqz4X7m+aPrTJ5Vx5Wne+Zzv/DG15vvI0/sq K6In/YLw6Pgc+jo6WKhJ8f0l8RylSszsgn9InJIYSfcD5+Uf9q6aiCrTPU61CWjQR9PT pA4g== X-Forwarded-Encrypted: i=1; AFNElJ+BlY20J5bVwVEffLlqGrOzY6QyuJXyDyRnA+dJy+xBHtXYtP9f3xVu4iS3dTEC1nJOVltPXjwYKR8YDa8=@vger.kernel.org X-Gm-Message-State: AOJu0YzhEr2o1r6Xk1LRUp4WUBy6sRoQuxUM1vGEYTOarxuUyQHRxYOA bczPX1UvqMzLSIzS4D88v6MM1FOE+H86NrCSh+8OlsE51amxSCPansYh X-Gm-Gg: Acq92OFKsIbSkUsGb8Phr9sPQrWMAmJreQ19KhIa0Qj2k1XBQ2vh4EYIR7qqezL9UON xhNgIS9yG5Par6KDLuMScv6VKt4mQGv+IJqOd1eW44CW22Dv4XvQYSb/C3x7u6ocIYnbWELAYil 4ZyAX5B1phiuLx/nEz3/vv4LCXiwjHnR7mz6nVP7jrKfWDOH4rgfWIj0eKRA1NaocIkWB/dzn5/ 6kAs+lWm8waHBML+4Kk/6E1O2rB4RNPjc5G84UproAQEkXfqecoNr7Pn/8B4l5j9UMdZb7sMSFd hM/8eoBHmlpxhb9SFvstKMcTG/90QjJnyvGWad53nPkFLmHXABPd2YlXfuKElREBTQm8oS/uArD WaNDxjfcsex1s316fOwxmsV4zGkC1uYXyp7sXfFwV4nR2hjKuGGTZlFJafn5cVwWBtrbkeD/+SI 2QqJSbSafQCnt4wCXrlVRuGGaEkDt9l4OT++cUbi7WDq9FYOvPPEl3RF5Z6iPL9b8aRB+NtFA+8 vD5C7BUBgToGPmYAUpXE/fg3D4oCghcOAReC3GOGw== X-Received: by 2002:a17:90a:d886:b0:36a:4074:9aa6 with SMTP id 98e67ed59e1d1-36a676f061fmr13821722a91.6.1779706337998; Mon, 25 May 2026 03:52:17 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:17 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Date: Mon, 25 May 2026 16:21:24 +0530 Message-ID: <20260525105127.180156-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 30e1ce321747..4ccb0bf2d71f 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,8 +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; =20 + val =3D hx711_wait_for_ready(hx711_data); if (val) { /* * an examination with the oszilloscope indicated --=20 2.43.0 From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 DB33D3E92BA for ; Mon, 25 May 2026 10:52:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706345; cv=none; b=uwANeQacY/Nv7jj+WJX/DRCJHGK+795A69KvhPCbXrcChf/pseWjJGrQNBLQw+CMgQkiypzqV9g3hWB5b8o0uCww5xWDW+zOfAz/k9VSsaIAYnUAGoosm0z8gW6rN3eDBnObNJSoLMLmylYvHnXza39UafXCQJYMJXa/512FKnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706345; c=relaxed/simple; bh=8sTc3ePfTO1HkNzwXZekmT2AeOdDHgPOdpy0VtjDF3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tABLMoJrsFzA6Ch32prkYCL6v8JXlNWipGfzpTLZ8rP8prl0hgwDtn05UlRqHYuaP7JrDeZWLAZ6OiGANqOcZs/G0WXCwZeh76nvzQihbfIj0ruVZLdtfF1V9lchaw/Cbw/0zRwD91RfP1OIiG4EeQTde52Zw7XUz545uSjNdC4= 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=GYL6qeQO; arc=none smtp.client-ip=209.85.216.44 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="GYL6qeQO" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-36aa4ae1f11so927449a91.1 for ; Mon, 25 May 2026 03:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706343; x=1780311143; 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=RTBVI1ML053TliZ0TwngU1Pm81C+cTmh1wKJVMjMXjs=; b=GYL6qeQOgFsAbiNfZPuEXAjds/fXUhR18YR02uFdt3cNwpb59TJGKqrQ1LWb01TyB5 7fM8s6jY9s6hRF1PEOTNNWrOMlp/71VAMlyiBZaNb0bEDtUOkARkr9L7G0H3UMMEQ4QU nnYR6eXyjUFM+H1fQWBR9a06hfi7rsHeifeoRriqkSXnmd6WHEKl2uVXPYWj9gUp9Hik yH5AFeciNE4ho56S1pThyVgSTGmR6j7fi3qZ54a6QF+TN/SyFAgDIFDxg054ortvc8pu UOH8OrWchUFBrg+yGKQmtUxpcuTjDQ9bCm+sSZbTqBGyVcQ9JlUPOXCpXkYZeD4EQJs3 ha4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706343; x=1780311143; 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=RTBVI1ML053TliZ0TwngU1Pm81C+cTmh1wKJVMjMXjs=; b=MgRWanzOPlqOFsXiaagpRLYAJV/cW7hPABUJPHxw+CJ+WGzG6rj0gAlpQ9ihURVXT1 1lcFdM+O/d7Wl3QNC/9Y78mHFgWJ8ZtAlAPVoC/0QxpgM50/LfOgnzFRfr/zy1mibhBq yb21aYFTesXYpth09+hoMrjNUpKIecrCyswYXeTe2S7YYVfENWwOxEBqQoIlvgubU1Tl 7vYtC+TkW6FZYocnuV2gdiDSFcxrRXUZ1UlMJ6GZ+MuSiB5QvhGhofhsUERhjnV4PIQB STlNvTIM009MclSdzXkrGpUSoKnw1rubO8RXvxHhGmRSxqD4BqqkYAyxbZhAtc7vC/oT 6jhw== X-Forwarded-Encrypted: i=1; AFNElJ9NOSNIOdekpCShhK3zAhujMhr1D70IJZfT/l9Cq3PksaLi89YiwHrs1mwkgRHBqXIkyCGsRYRCl3vTLHQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxHyIpAPlLiuC2u5Uf6J0cWOcUfSfztL/uG23z4EEMavv2BATwJ OnJzjkW2O9VaVVH9/6c7lg27ZJ8rUqRfLve8QwQSynJHdCMCq1thj4JL X-Gm-Gg: Acq92OG6AFS2Ju0N1Z+phourSmRdjEsPBR5qEodIkeFyxM8A+vqk55K8G8UnDVKQLAT oIQVKIZNSFqpGle5LWaP7aBLqZRk3J3r0y/wPGifKyBVN0UXAurvrxCQh120MCKn6y3hhSQPrVe LYnsKCCSR5cpFGcS8j9YS4AzE/2d6PFQbLZo1cOWGXt12xT1XvP/67lsRGvsrT5RZByOtvE2KKJ Mw86N54Tgub1AeRnsQCVdcy49q6hwj2f+3t2FuoE7+iT0yzqqE2ZGCFG1cKIgr+VKkC8s5dHb0G GuBWbqSab9uabIICAF2qGpNMyRRiRJuLzcFV+gMoRAYBgAEj1r1M9f+Vevc+lNFufuT9shuK3Qu sgW9X7tP2tPnhXrRZ/mFl3cJBJ0eNctPi74/wBUajPeBykTqYl3OLFMLgGVoIi6AWZMDbzNpAHS 4iEqs6InH32Z+4kbGChtwewMuzfiV+curKSfUhOJ7IoLFOSYOab0bJ6+/mTNcYiQNg/blXOHDgC /mXbfiuH570ayGYcTw/ZUDXYTskHHQjSueX2iOgHkiEZ5KF0Ttf X-Received: by 2002:a17:90b:1b07:b0:369:a9e8:dbf5 with SMTP id 98e67ed59e1d1-36a6749ea42mr13009276a91.3.1779706343136; Mon, 25 May 2026 03:52:23 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:22 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 09/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Mon, 25 May 2026 16:21:25 +0530 Message-ID: <20260525105127.180156-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 4ccb0bf2d71f..e5d842853b71 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -23,6 +23,8 @@ #include #include =20 +#define HX711_DATA_BITS 24 + /* gain to pulse and scale conversion */ #define HX711_GAIN_MAX 3 #define HX711_RESET_GAIN 128 @@ -157,16 +159,16 @@ static int hx711_cycle(struct hx711_data *hx711_data) =20 static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses) { - int i, ret; int value =3D 0; int val; + int ret; =20 /* we double check if it's really down */ val =3D gpiod_get_value(hx711_data->gpiod_dout); if (val) return -EIO; =20 - for (i =3D 0; i < 24; i++) { + for (int i =3D 0; i < HX711_DATA_BITS; i++) { value <<=3D 1; ret =3D hx711_cycle(hx711_data); if (ret) @@ -175,7 +177,7 @@ static int hx711_read(struct hx711_data *hx711_data, in= t trailing_pulses) =20 value ^=3D 0x800000; =20 - for (i =3D 0; i < trailing_pulses; i++) + for (int i =3D 0; i < trailing_pulses; i++) hx711_cycle(hx711_data); =20 return value; --=20 2.43.0 From nobody Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 CFF1F3E9C27 for ; Mon, 25 May 2026 10:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706351; cv=none; b=g3DkEEC0ASu3Edum9BDMnSEQLuHGav7DpUlVMVeiKZyfXp6yprJq98ZXtW+BZWvcWSr0O4Ww1TEkaru7fHG6LbWOfakxoQV/CZExddCLiW4Ptn36mcITVI4Any5bl13gMtpVKUQaO8kL+Qhqt0eeRAyPHFec9lNYJFgRRtYjeGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706351; c=relaxed/simple; bh=3FrcsQlVziUdeKI/N9eYaCs4RJmRsrcZLsIz3cZSFq8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIUpKl/O133dd0brWGk/rlEtKpMNinHp43X55ZNJbZzwa5cRR3vffZ2DkiNXuT9twg6ivc5eEmkOHia0SgwjxY1AOsGM+S0fp+W+FccICuRpHlA61JcYXFa6BjlD6ARfQxWPH3LG7bUM4yoI5RoaxdqI+Mv+cyXE7egjLEbJtXE= 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=dZtk8YJI; arc=none smtp.client-ip=209.85.216.54 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="dZtk8YJI" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-36ad15213fbso525877a91.0 for ; Mon, 25 May 2026 03:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706348; x=1780311148; 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=uk0PkavUtmrtR763X7Xl8KGOaAn01gQsV9JDZDG7T1A=; b=dZtk8YJIakMNipqUj/t5VM0UmqEioiPb7T2UipJtFDoWhi4qCo56fwFT2KsuV5PZjb k8aSFdt6dwFKw3IReX3g2yzvHufrQTQR+AWNiiqKvPX10vU0zGg+gJFpondnj+q7e2BK nM99xoOaui8jmirBTZOHXxna4aA8NIuWa75LUJ3iFuIW/2mu9D/BHE74ndl/bBcN4ajE OHVNerqehTF+KgMbTKtcPjOs0SgQKyRSTHFNoB+X9AdC8mOI4WzYVHcj1xrYzpQ8i/sI wGKEafYgnMumxyj3cBuAZu/ZxYi87OxevNP8atoijn5gEYP+PT8QAkzbNUccN9ZVVsn6 H7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706348; x=1780311148; 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=uk0PkavUtmrtR763X7Xl8KGOaAn01gQsV9JDZDG7T1A=; b=lC0MwYfjzIMUpfvf30f8zPgV74BUXFuw2hDcUA0Iomc68syVBWutSNOaPVZqdkosRA 04IajJ76cNJ4aRH88Lo1nCZ5BjgCFm4dUAnQ9GdZv1K9UsW7f3vmHrxEy6TRT8Zy9jKj 3bb/iCJI8HNnmk8peNDYUWoVARxJTjWNop9p7U6usaVkLcG7kxvrS+Nf/tKfl1vN61r0 GwQOdetUAOJciE+Pn3h7Es2XzNSBMUt6q9W2njczbyHaab1EbImx27+crFMoNyAvCGDU 5HEwDrUIrJy1K9dNV72D0Ei2F/9g9KMLuSqOd9yHc1ayw2JjhO2GC9fjor9wkODqnq+b FtlA== X-Forwarded-Encrypted: i=1; AFNElJ+teUb6jwlvQgaMu3PNlPtAzk8DJrkUbp3nTyHldCZIFF6Z5cFIhCn1sTzqFAzeAntHv/Kp9gNjIztaFvM=@vger.kernel.org X-Gm-Message-State: AOJu0Yyen/vWJmA66+4trJ7YAw0IK2T2oQ1YDmhhSTcA7LXwMDRe6k4O nN5MwPyTi20CP4RW30NqMe/u+XchOFiHqx8/fJRIb2w1dB+sK65s5uUr X-Gm-Gg: Acq92OHHpJNXifFw3FypK1jnXrdFkoX9orUjR+nnulNNwmqkguB3kWNPbwuTvlsFbnG GqqiqSFZCxNBHh4Bg1dJkYTpiFjFTrPXBl56x/TWht193zqyAYyrvXovr5kfPKKRKIJpoG6Xreq JvOFQhB3A6DIfgIveSj1LemqIe1xYGXyC4HqgFnM5iaj8K7f4Q0PpLsNqbsk8uUdm2MihJDERjf YpYi/TR0Y8FfEid1sBFi+Y/ryjyJlFCdvUplWmR5+FJL01xmy/I3fe3BUheNd47iqzmZXJ/Pp3q tWQh8ch9YPt7eRVej2U4P1AZ+YDR35iDHyGUitQDLmlwkBPsSlLNWaW3UucA0U/WwrknnwQoPsI WKOzOCbT3m1hKzKP0/J38BcCmn+9dlq4ZDfcEdTfjgD7Agid8ukA3N3comJ6jGjAQuPz7oYArpb hCmkYRdr3ZgM/e9UY94lnY3Ee46PHVFdmGdE6rqqrSTL/VAtJAwFywfeuDbVViBE9F7fX4RmBoh acbNVoTqGYjHcU1yq+wwBDlCuvO5s3n6C9NXC73/j3Uta77ebTz X-Received: by 2002:a17:90b:558c:b0:369:932a:2b8b with SMTP id 98e67ed59e1d1-36a6778aedbmr14172064a91.11.1779706348076; Mon, 25 May 2026 03:52:28 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:27 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Mon, 25 May 2026 16:21:26 +0530 Message-ID: <20260525105127.180156-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 e5d842853b71..fde95758b9a0 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 Mon Jun 8 23:57:32 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 EACCA3EB80E for ; Mon, 25 May 2026 10:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706360; cv=none; b=YSJL7R3VjAT9ZjT1/pFx9hBI/w7dJ9yLCWOPfKhIIDW2bUrjEGLXo7DCNQMd6w+t69uIivP5WQWv6uIYdcsSr/qzxaPKrpjx3hQZ+djt/rLer931M1OiSZdBQ0mc8fLmKw7DnPhX3tdZWzuwPAr+MmcH+a/Kjy8W3n9QQoHFV0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706360; c=relaxed/simple; bh=h1Mu+c5aWlZ4TVI2ZMCzad4dYzEVAsJI0Beg+oLCU1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CEtDa7ONYL2WbbBDnQVEuW1DC6WA6IwY+Xp+OEhj5ffGIWWpaUNcioIiZbMdBWv/NT4HY02sDU94uc4YBdKtk/AZtNCBTI7KJy+wUKesr+7h19nfpi56DKTW5bkhq/jYhunyVKCSupGvcvPVCNqfMxs/0g3sT1uVb+ruiVTfiDc= 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=UIkj2Ljf; arc=none smtp.client-ip=209.85.216.48 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="UIkj2Ljf" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3664df32e91so10960593a91.3 for ; Mon, 25 May 2026 03:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706354; x=1780311154; 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=fBT7ivZhN63Crud550Vz1jsL4y5b4w8SONDK6zwOrRo=; b=UIkj2LjfGrDOXoQD2c4zcjQSnK2NIyIeuBKzV8lxu8InZ4ENRJJsvGE86YpMm1wNr9 NQzQ4EYZPo+Vp8fiiuAlIrcezJ0WsXpiGpLyiTIwJDiCjSiKOyxhOVGxw6T0kBmVbP2N ngZmM3KTnKBb7/oEFi0aRwNaqYteVFjKgyGZPQX0f7ku5HA7G9vgk8S1+3wOU3mTbLxS 67AeRdJ0+hybGc4u6IV4OwbaAkQY7q8yh8pfB+v3jQHWWECfhcLlRhf3eb14AgaJK61r PUBo1Qhj9G4JGeGqMlEa+JgIwuvdeQ+XgV9SKAnyfdpontGYagUdYVuRWoB6GZeF7CVC QQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706354; x=1780311154; 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=fBT7ivZhN63Crud550Vz1jsL4y5b4w8SONDK6zwOrRo=; b=TfC6DDE3K8BmfMQcoTvIqZy/iQWjxyK9mpSTTuN+GByfmlsWbY1vGXidwFbzDYhbO+ Oi0orLBscxvAtDttK1HwZQRfEu6WAxRSA03Pan6lN2HQcL0w52cPMFWmKoqF+bKJn05Z 4h4KFROmf3dH65NKhI3x/47Z7IAbfvTmhfb85IirZ/Y9ZBXin28MWy2shrqHkgeUP3TD KSdm5moE4q9fnWhAA5ukh8ct3nRJ0uagRCtQ12l5CXE3k0f91NP+eWPaGw8VBlh15zwr +4x4T39aXZqjgSYHWkbGv4ucD5Q//L8VGcOLYRVVDsfIe4Osxuzp3YwWcjbjZWfx0gji Xkjg== X-Forwarded-Encrypted: i=1; AFNElJ/id6XJ/CHUnv96v/s0b2QsPsk6VV3H0besxx8dFttj+SO9eMORH9CDF9znTCzj1vPAWsm8frATzmJTdiQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzk5Teai2I3gjgZOOg8jBDGPa5fLQMxVjRV6piW3xWEWFgnxvqK T2QdLIHOB+/3TfISJ5YFUnbr3HYfEQdHc4Zbij8cLlRwnER36GLilv8g X-Gm-Gg: Acq92OG001EjJxZEogvvZJ4lronAD/Ry6le4QL1F6HcTKFAZDhd/7itVo1ZfsKce2xA 8uv86n1kGHfT/7QQL+3FL0Vl3D9ExKox/kYy+byZCEeF4WNPnHD/bAcV7aQHRSjj7EZuaJ+en60 iNgeEuEtkXjawcXleOFPvA7LNTuhbhkf6S16jFmq5YUePW6kNvZXSpOS2E4n2ZIDoDGCuzaA8Qh zxnVdlLyw0WBHqQOjK82LM0oPW3r3/4wKolwMIBnTXFHgM1XaQZQr/PCtYXTC9t+KLHtwGPcr8b 5FnOVPaUSCJIaAyXcIHjD8HEY2s3PrHm+bm4yB39tzGTQz0mboUXQMltejCNtvlJXO6kKXSuFhp hYjAOyqjSCE86eXY3m86IJeWHiTb0w301WX1yNi+De/hCbnQ8lEEjr13WtiFSJ4/Gy4yTmUlwAK pcprF6ZboP8ETHEu+0TQKlLh2kCaVllG8Nxh1LKU+Zaj6pvre1/35x6xx8gIhW1w2aSx3ekj7ro RigD8mPFUsd253T9NZwaDUV9LLfcSXPa8mVwc8V8HzHEzvCjeBN X-Received: by 2002:a17:90b:5284:b0:35f:b7f5:9b3 with SMTP id 98e67ed59e1d1-36a67420e95mr12704820a91.3.1779706354231; Mon, 25 May 2026 03:52:34 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:31 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 11/11] iio: adc: hx711: add support for HX710B Date: Mon, 25 May 2026 16:21:27 +0530 Message-ID: <20260525105127.180156-12-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-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 | 230 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 212 insertions(+), 26 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 fde95758b9a0..32a35f644834 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,6 +105,8 @@ struct hx711_data { int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ int gain_scale[HX711_GAIN_MAX]; + int channel_set; /* HX710B active channel */ + unsigned int samp_freq; /* HX710B differential channel sample rate */ const struct hx711_chip_info *chip_info; struct mutex lock; /* @@ -207,6 +215,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); @@ -226,8 +235,11 @@ static int hx711_reset(struct hx711_data *hx711_data) =20 val =3D hx711_wait_for_ready(hx711_data); =20 - /* after a reset the gain is 128 */ - hx711_data->gain_set =3D HX711_RESET_GAIN; + if (info->has_fixed_gain) + hx711_data->channel_set =3D 0; + else + /* after a reset the gain is 128 */ + hx711_data->gain_set =3D HX711_RESET_GAIN; } =20 return val; @@ -283,9 +295,51 @@ static int hx711_set_hx711_channel(struct hx711_data *= hx711_data, return 0; } =20 +/* + * Return the trailing pulse count for an HX710B channel (Table 3 in + * the datasheet). The supply-monitor channel always uses 2 trailing + * pulses; the differential channel uses 1 (10 SPS) or 3 (40 SPS). + */ +static int hx710b_trailing_pulses(const struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + if (!chan->differential) + return 2; + return hx711_data->samp_freq =3D=3D 10 ? 1 : 3; +} + +/* + * Switch the HX710B to the requested channel for the next conversion. + * channel_set tracks the trailing pulse count that was last sent to the + * chip; it is updated immediately after hx711_read() commits the new + * mode in hardware, before waiting for the chip to be ready again. + */ +static int hx711_set_hx710b_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + int trailing_pulses =3D hx710b_trailing_pulses(hx711_data, chan); + int ret; + + if (hx711_data->channel_set =3D=3D trailing_pulses) + return 0; + + ret =3D hx711_read(hx711_data, trailing_pulses); + if (ret < 0) + return ret; + + hx711_data->channel_set =3D trailing_pulses; + + ret =3D hx711_wait_for_ready(hx711_data); + if (ret) + return ret; + + return 0; +} + static int hx711_reset_read(struct hx711_data *hx711_data, const struct iio_chan_spec *chan) { + const struct hx711_chip_info *info =3D hx711_data->chip_info; int trailing_pulses; int ret; =20 @@ -298,9 +352,16 @@ static int hx711_reset_read(struct hx711_data *hx711_d= ata, return -EIO; } =20 - ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); - if (ret < 0) - return ret; + if (info->has_fixed_gain) { + ret =3D hx711_set_hx710b_channel(hx711_data, chan); + if (ret < 0) + return ret; + trailing_pulses =3D hx710b_trailing_pulses(hx711_data, chan); + } else { + ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); + if (ret < 0) + return ret; + } =20 return hx711_read(hx711_data, trailing_pulses); } @@ -322,6 +383,9 @@ static int hx711_read_raw(struct iio_dev *indio_dev, if (*val < 0) return *val; return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val =3D hx711_data->samp_freq; + return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val =3D 0; mutex_lock(&hx711_data->lock); @@ -399,20 +463,26 @@ static irqreturn_t hx711_trigger(int irq, void *p) struct iio_dev *indio_dev =3D pf->indio_dev; struct hx711_data *hx711_data =3D iio_priv(indio_dev); int i, j =3D 0; + int ret; =20 mutex_lock(&hx711_data->lock); =20 memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer)); =20 iio_for_each_active_channel(indio_dev, i) { - hx711_data->buffer.channel[j] =3D - hx711_reset_read(hx711_data, &indio_dev->channels[i]); - j++; + ret =3D hx711_reset_read(hx711_data, &indio_dev->channels[i]); + if (ret < 0) { + dev_err_ratelimited(hx711_data->dev, + "read failed: %d\n", ret); + goto out_unlock; + } + hx711_data->buffer.channel[j++] =3D ret; } =20 iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer, - pf->timestamp); + pf->timestamp); =20 +out_unlock: mutex_unlock(&hx711_data->lock); =20 iio_trigger_notify_done(indio_dev->trig); @@ -462,6 +532,54 @@ static const struct iio_info hx711_iio_info =3D { .attrs =3D &hx711_attribute_group, }; =20 +static const int hx710b_samp_freq_avail[] =3D { 10, 40 }; + +static int hx710b_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + *vals =3D hx710b_samp_freq_avail; + *type =3D IIO_VAL_INT; + *length =3D ARRAY_SIZE(hx710b_samp_freq_avail); + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static int hx710b_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct hx711_data *hx711_data =3D iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + if (val !=3D 10 && val !=3D 40) + return -EINVAL; + ret =3D iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + mutex_lock(&hx711_data->lock); + hx711_data->samp_freq =3D val; + mutex_unlock(&hx711_data->lock); + iio_device_release_direct_mode(indio_dev); + return 0; + default: + return -EINVAL; + } +} + +static const struct iio_info hx710b_iio_info =3D { + .read_raw =3D hx711_read_raw, + .write_raw =3D hx710b_write_raw, + .read_avail =3D hx710b_read_avail, +}; + static const struct iio_chan_spec hx711_chan_spec[] =3D { { .type =3D IIO_VOLTAGE, @@ -494,6 +612,51 @@ static const struct iio_chan_spec hx711_chan_spec[] = =3D { IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 +/* + * HX710B channels (Table 3 in datasheet). + * 25 pulses (1 trailing): differential input, 10 SPS + * 26 pulses (2 trailing): DVDD-AVDD supply monitor, 40 SPS + * 27 pulses (3 trailing): differential input, 40 SPS + * Channel 0 exposes both differential rates via IIO_CHAN_INFO_SAMP_FREQ. + * Channel 2 is used for the supply monitor to avoid aliasing the + * channel2 terminal of the differential pair. + */ +static const struct iio_chan_spec hx710b_chan_spec[] =3D { + { + .type =3D IIO_VOLTAGE, + .differential =3D 1, + .channel =3D 0, + .channel2 =3D 1, + .indexed =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), + .info_mask_separate_available =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + { + .type =3D IIO_VOLTAGE, + .channel =3D 2, + .indexed =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 1, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(2), +}; + static const struct hx711_chip_info hx711_chip =3D { .name =3D "hx711", .channels =3D hx711_chan_spec, @@ -501,6 +664,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 +715,43 @@ static int hx711_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout), "failed to get dout-gpiod\n"); =20 - ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); + if (chip_info->has_fixed_gain) + ret =3D devm_regulator_get_enable_read_voltage(dev, "vref"); + else + ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); if (ret < 0) return ret; =20 /* - * with - * full scale differential input range: AVDD / GAIN + * With + * full scale differential input range: reference / GAIN * full scale output data: 2^24 * we can say: - * AVDD / GAIN =3D 2^24 + * reference / GAIN =3D 2^24 * therefore: - * 1 LSB =3D AVDD / GAIN / 2^24 - * AVDD is in uV, but we need 10^-9 mV + * 1 LSB =3D reference / GAIN / 2^24 + * reference is in uV, but we need 10^-9 mV * approximately to fit into a 32 bit number: - * 1 LSB =3D (AVDD * 100) / GAIN / 1678 [10^-9 mV] + * 1 LSB =3D (reference * 100) / GAIN / 1678 [10^-9 mV] */ =20 /* we need 10^-9 mV */ ret *=3D 100; =20 - for (i =3D 0; i < HX711_GAIN_MAX; i++) - hx711_data->gain_scale[i] =3D - ret / hx711_gain_to_scale[i].gain / 1678; + if (chip_info->has_fixed_gain) { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / chip_info->fixed_gain_val / 1678; + hx711_data->gain_set =3D chip_info->fixed_gain_val; + hx711_data->samp_freq =3D 10; + } else { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / hx711_gain_to_scale[i].gain / 1678; =20 - hx711_data->gain_set =3D 128; - hx711_data->gain_chan_a =3D 128; + hx711_data->gain_set =3D 128; + hx711_data->gain_chan_a =3D 128; + } =20 hx711_data->clock_frequency =3D 400000; ret =3D device_property_read_u32(&pdev->dev, "clock-frequency", @@ -607,6 +790,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 +808,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 similar bitbanging ADC driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:hx711-gpio"); =20 --=20 2.43.0