From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DC833C183 for ; Wed, 29 Apr 2026 05:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441560; cv=none; b=Svit4Yt7RN0tJtdGCk3nKIRfe1ebGb13QGZ2s6fd8E0Lb3zFeC1M1bqoZ48vPtq7YjP4YEcfJ/k49cUOSx25dBGQVDgBCkIl+KmLcjXV3vtMralr85L77VmqyMi0UJjrqqlisUrzQitlnyyCIMEotvrx6vmheYdzJ2x4SyIsRUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441560; c=relaxed/simple; bh=GGF3jyUqforepyERRKXlYZGTHXws9eodKpfONNX7jDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tQLPdcpidHAQjhMiWTMij0EwSUGPcPwpExyHMPA0OD3veOvmPeu7c8U1KT4orHhu/POJf2GoN0bCLSXtIZEJbpGtHd6SBoyytecca1BEpu9Unku9gmxaU7RdlTyTkIjJDrr/t2Cyzw5D3WQ5AF56STmt8gvJ5CPBy1fWVoSt6lw= 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=lpjVsjeO; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lpjVsjeO" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2b461310af5so2356955ad.1 for ; Tue, 28 Apr 2026 22:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441556; x=1778046356; 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=o7hco1kjJGC/g/8N1qIFMmlsaaKm/pe8oI1boZvWXSc=; b=lpjVsjeOxzELV4T8c+fcI5WTbkVe25kzs9H7KfetunlqZntW9J0hJB71WnaZT/ettd INbbvSt6riqBQiAheiJ28b9YZneEIKbY9i84DnEdUM/rK5OVjeC6sFjYvl1yEYLzZfha EO74D7T+bbiqbGtA2xwb/kHG0GatBvRfxWM1VnAN9txaR57Xl+3wsMBua9d+Vx6yxViV OS3TjBmbNP8oLSwhZXZs4qGTq7+qBxQp7HUxzIxJ8AROsFNPK15CS4p8nnqRdThvuzuW 8m0v+ZNotjRuXVnJRdABbjPkMzJAHvHVUPtKlt83IZYkquD82zVdSMHE6sRMRJD51LaV BUjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441556; x=1778046356; 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=o7hco1kjJGC/g/8N1qIFMmlsaaKm/pe8oI1boZvWXSc=; b=H5gKSEwwEHMQG8vRz6wa2COMTP3/VuWII0d3O1wJWS72w3Qwkwm7Ml0ub2gU2EOFRl uxalb1mxRYWqdEZv1lEokl99mg+2taPHzDZp/RYUbeirGXy99CnuRMGShs4jZS7HJDwo pWDYBQxVhM0PhgHn6bY5fOvIRzcZew/J9e3OHfoa6LDG5mAg2jO3mxc8M1lD1JvEmal1 tuY1q/MUIdqKQWr5bo1hysETZPyMGJIgqiH0PaDG8qThrUkmwxkFHEGO/SFFJWTNKW4t rQGiXPzv6GrOH89x4TbDMf5ftpB98Tr8NrRYa+wqDNT+4dxiWpzSprLmPvmFBHW5pjRk oQqw== X-Forwarded-Encrypted: i=1; AFNElJ95id7eV8pYnBWDUYvO7nYUrU3rJJfEehlugngY4lylqgCN7PC6xi9z3ILNP3/vvHJrwpmi7gc34V5Z/x4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/+FysrQ+x7OQnykUibP/kxz7ARDUcBwe2/8Qj/SVeXwrmy+S8 SVcwiu07UrTZTpPn+SbawUKEjiLA+hZkEO+FUJAjiVxGoszwCu55prnA X-Gm-Gg: AeBDieutvBOk17mgNulNvG7BgOtPANJTiS0zZpHCCAOjkLAgt/oZfyrU3u/ebdqZGLI Ehj9PVL6pqS0/YlodWTCLJy0A2SIYRSr88GbVLo5XEowb1DCS6csVqpPjLdXzprXY4zabEHhb9i Goloy+m/spshRsDwSUtJvouRa0u+AFy73Yf3dpS52ZjGHIvC+qnxCTbgsWJ4Qha+tXXrld8v8ks bW8ih5/Y6xheI3HX+FQNhpzpV5zC1oS6gQLSiJJRzhCnGSZwBATxj56FsjMSxiQSDAFVkJKV8fZ XfYMlK8MR0/Ke/nUs6O0EmdKxXv8XLILwS2LCctpemoti3p2IVISdFvCt11MwjqJyItECt8HO4f Oq1qcQ4GLeB0OXr8ndaUqiA5c3v+GdvIOKvuksk+tryaXSWuaTpDdu2weWj3Fh5uRPd5iuZbp6x CXOItaub+H0EFfrV6XWYs4H2LhahQrIO4Jne6B7BKJktLAvZVaLRONKyvfbk5dpgf/E6FDT904b BMBEWk/nR09VsEbaMMvmUvykiT0iNmxUtN6We6L0CuZbxzdGQ== X-Received: by 2002:a17:903:2acc:b0:2b2:4fc1:f653 with SMTP id d9443c01a7336-2b98836a261mr15391085ad.3.1777441556448; Tue, 28 Apr 2026 22:45:56 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:45:55 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Date: Wed, 29 Apr 2026 11:15:34 +0530 Message-ID: <20260429054544.123862-2-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - New patch split out of the old combined binding update during review. - Limit this patch to cleanup of the existing HX711 binding text and the clock-frequency description. Changes in v4: - This cleanup was part of the old combined binding patch. Changes in v3: - Restore the example node name to weight and drop the repeated clock-frequency default wording in the old combined patch. Changes in v2: - Remove driver implementation details from the binding description and clarify clock-frequency as SCK bit-bang timing. --- .../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 Tue Jun 16 20:37:15 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 AA33C33C1BD for ; Wed, 29 Apr 2026 05:46:01 +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=1777441562; cv=none; b=c0T8On2csFMFy1HE24AQxHT/J/KY5r3CHno9XCM4fH8hL7lu78xouZFhToCmJxdz6xq7CiT6D+3iMp+fhwfRkeas+ECNSEj9n94FhXEpzPrgyEHQEKYVB1skbaIkJ8pLgbeM29ksIKjeYHsBvs4yXilwimCbdq6E7X16QrfGhUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441562; c=relaxed/simple; bh=OCr2Hcn0qix+hqJ1KxJxOzUQfs1MFEoU3VKInobzy38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3MT37MTStWA5kzYK1N+ZG17LTHRnaXhG2/r76EJl0FHG1+LrFmKTqSVUA0Y+141RTJoHN1n0t8gnOhdbNKitxkZwiWsm95C+cPzvf7UcT1CWLhES8QmS8PqL9W/MhumD+CrnzQoRKwEAWyAeqZjG3I1d8KTe+zep1hFi/JVOqw= 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=GyiSOy/a; 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="GyiSOy/a" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-35fb7c1a455so4500688a91.3 for ; Tue, 28 Apr 2026 22:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441561; x=1778046361; 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=QHweuBk06mfMQKKsSg/CDUzFihaXXhNJibA/Sa+cnuQ=; b=GyiSOy/ab8c2XAf6pqJR2S24XrbGw0RSw5SL9oYsBpxAiqVcwlyLUKkNRyafkHe1T6 HWyWO528qjNYxssuwf8YHH0EiaPP703mJuexNdYdjRPuoix3BHijzfGt1M23UJ0CrOEr MfE7u2HH4WO2uNl8NZID4pnVMVuhdBG6qWkeB/06/Wxq0+hLEpfyGPhO8UGVUCi6HSQ6 n8CnudrkMvH/K0x9hC7HK/AuCgIvLu3LEs2OdIioyn7jNbid9BsKUoEXO+olWJ7fPz6T 4ozF6NW5ZQHXwYIdQa/urzZIbFK79IdgS8c335BZuMKmmG2/Ax1oAWx1wP+vPi05ozKD ht3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441561; x=1778046361; 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=QHweuBk06mfMQKKsSg/CDUzFihaXXhNJibA/Sa+cnuQ=; b=WDXXBFZ5xdndjQi3y9A001fx6KHmD8kBn3i28cTZJeK0tsBkWfxtBYSe6153PThZbD yuYWYCVIF39pbjloTei7t0v8KZA7eo81wW2PllrEFH+zOPKkAo52A9akpyPAFaP0Fciu ouUJxzaBw1tTs+0SYH09PFTLONwNIY7dC+hCgI9nN6+GPXeVvKNEgiRjAWnvOis4/7tN q720C9uFoVS3kNlsmzlf+QUNMDxLzE8sLKg9ZlLYQl6CoqC6qISR7Eq334dosoPa45Qs wO4xXpGDOg/RlzJTt5e+UPGLgjitYJu5jJPJdz7fE50aOFI0sA7DAutDDfbbS7JinATP l2oQ== X-Forwarded-Encrypted: i=1; AFNElJ+XQldem/VuNByyyYFYQXS3JK7CvWLZWEGuuq0awL2qQowFmimwppqrs7FEdU4rAeKbSAy4NucPoFvmW3I=@vger.kernel.org X-Gm-Message-State: AOJu0YwDj/I8IxcZrk/pBXW7iIZLH+mWCbPQzykd7+zQTbhlQBy08buV b5m/OiK6mMoHIwxzyxOnCTcbn7d8WiSpcqOnd5cOlVykHR6oD29KpWFd X-Gm-Gg: AeBDiescRyGb5tjJMLL2moESH9oNePOCipaf7VWGd17htiEGg5oo2FV1NxitCAgQWLQ //W9+2Vlo5dP38Hb7PppDJHZWsJHMUAm4LIhfXgBXDHveqyHrp0LuKqdWY2+ZBj4V7Do/RMEWsQ /Tw+4LFarafwOWWn+CfMuSkeGMou+4chBaqa9mgD3yjKXlCEzdFuV9dshTAc3Caf6uHSuMB/yg8 BgdMxfQNtnGYnvu9NrgEajvLvR2dEapzWg/y2e7z6cOLcTboUOr+II/MO9kYG1SEpe2oHAeKOBv SGQnxj2J6Ne6z6nQgq9t0Xw6LdK7w4VrDT1VNHTU3tQGer+NNHlxntAWNuiAcolGQ5lN2lyMCLM ixbIaeHcJk4lUSGXqpSuDd7/7RmF0HnTahuQRAoUOeNSK/qmNSQC8JFICYGW54Pnk6aebM+QAr9 RV/3gbd0FyieWbxYZRoD01McdhRUgkL40KV2Rq0AV95XOEhGom7+DvVuCXGx7BH4RR5PqWjjxRu YzedArrzlQ8XHlYIi5fSAoabzEe1Hd5GKVEGdXzG8aVX8gfZQ== X-Received: by 2002:a17:90b:38c4:b0:35f:bfdd:f5a1 with SMTP id 98e67ed59e1d1-3649204d630mr6255254a91.13.1777441561015; Tue, 28 Apr 2026 22:46:01 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:00 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Date: Wed, 29 Apr 2026 11:15:35 +0530 Message-ID: <20260429054544.123862-3-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the optional VSUP supply used by the HX711 on-chip regulator. Keep this separate from the HX710B support so the existing HX711 binding extension stands on its own. No functional change for existing users. Signed-off-by: Piyush Patle --- Changes in v5: - New patch split out of the old combined binding update during review. - Document the existing HX711-only VSUP supply separately from the new HX710B support. Changes in v4: - This property was part of the old combined binding patch. Changes in v2: - Document the optional VSUP supply for HX711 nodes. --- Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 1ea60dff98d5..a8eaa1f18de5 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -33,6 +33,10 @@ properties: description: Analog supply voltage (AVDD). =20 + vsup-supply: + description: + Supply voltage for the on-chip regulator (VSUP). + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1882527603A for ; Wed, 29 Apr 2026 05:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441567; cv=none; b=RMyoeS2s1dTODo5K7W7GKzVooXmvJoA73HrynaYk0dKk1i1chzZNYMS6hqrdTIOsufVdWAJSnXXJszt6i41R5WbX1uxknhstsHlhvATk4CjOZoKAHagUAgh6LRY4myqmnEl/x09FKbTUdHyRI/iZCGamUjdm/CQ9IcAnY9Tahek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441567; c=relaxed/simple; bh=LVx7QBmq5oHLQS8ou5iLZO5dvWTi5L4BQ0pp1NtWuNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dychPgL85Owqfi2b/Qt9ZYNF0LRc0V9AMIbnGWr4ew74WbYZo/X1c5cTl5qTkpjkzV+9phdA/HE6JVWtawrpyCPlMwm2pZGe3XFgSVJj4ARFMquzJVMFnUbbiS/laVEkFXH1jgYjjcw8drDyTckXOeas0e4v8kgonLYv0yWxjck= 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=G2pyWpqA; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G2pyWpqA" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2b4650d5f5cso46599825ad.0 for ; Tue, 28 Apr 2026 22:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441565; x=1778046365; 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=cMy0u/g2cL7yrYXQqhYNhi1XV/1EanELOFp/N7XhvWc=; b=G2pyWpqAZc/6hclJWHE2ZCbfLpBAqe0Z1p0fZC7AG/LqZXenPC0s4Dih8+QC11/JuT AI4WNTDVFD/DwaljK4qZbVTT3RK3p0Wgfr2YIDCVachmMJ3nFBPOELnGHEAOloGBDBIK osgBQR3Fqf65WYHJ1+p+TVFcLeVNoxBc9LzbgzEv2mzJ7qMywIIz+hX/BcCuJwPoW0wy M5PWIaLqRUOZiKvBkyuV//YTW6L54xp4MDKlh9BcUb3Ti7LPJGLGTM62KSl9BEtDIVId I5Rs28XRJt2Tap704CdwKQzPqJrBYW34wKtQ159WjMZxVgLLEk0Ir9jfiSeFntAP6Xbv cOKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441565; x=1778046365; 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=cMy0u/g2cL7yrYXQqhYNhi1XV/1EanELOFp/N7XhvWc=; b=Jdc806u57lHiuOvzjTbk4/Ok6psSoBowyJw7KQsZybgc8it8/9MuuoZ0VYm7RU9keL JuIXZ/8TN50MwbfonS8jEz1QXKoNkeLnWYPk87ff6D+FH9AFe3e2nSLNhRGUSTyyVu9q Ubs4DL0T73peQs09bz7smHJo+Q4ZoUFLhuLi3lpkU0nTJbIxHK/lGfZow0Yr52KVo63s Rp7X8XnyFGt6KI88gxZv2eQdXwnX1s7UlQZsT4QvKFf/Z+GM7V+3wexQeMLIkQkdUo+v fEWX75lgtyAPo9zuy46n9aR8WijKP4lt3mjTIH+abmheZGtnOOYSOtN5BAkz3LXhqY+q NYRA== X-Forwarded-Encrypted: i=1; AFNElJ++OexRvdIyapNSwE+fKZCxn1h2Nm5DHygeyaTF/5Ww3ZTddDLaouRRdD4v1ocEXS3TlT2nimfBOidDrgY=@vger.kernel.org X-Gm-Message-State: AOJu0YyqskBaDlinQfHH4rCFeGS4UBQz65p20+Zh5hZb+wreo2MVmti9 dAUuP3Z6ECTmWaIBcwgDNSorLQ2VL1pUk5KYC/47vDugJo9P9vcTzG6D X-Gm-Gg: AeBDieu78waX+0LUvqhwBG7dgsHIsiJEmWOF7Clp69ayzloN61hgqFS07XgCKMdeEnJ 6hwNQfnWZho9Nb9ZRw1/BKNpXdxYJeoGCY10rM2Ge5LFF3HetALsLL/1Mu6tcQLt13JLdQ6+6vh /fHd6QJTwUw3PyFnYjc0ugjXxQSzHjFEbnBRMei8k2K1J9EqPr/OebEple7fzWAeomb0LkWLSzC sfdtb7fHYdOoitM6nxu9vpF5AIrY6esQFCzXe04X8s8tPNc4QKi21saYcU0qqpAVfepJjC238CI wM1W0uMQfjkrwHdqX26vWmxokmCvuTbHy6XgpfXz99VcRYgW4mvDsHoXfrt6+1MhZ5rlsyZllij FNcN4TtgSn2SjRtNQ1G32RDonkHzwOxZN0+ky5WCD9Kp3qJqMC7WJefqmgGbh8yldgkMf2ht8Tx xMDLGhOtGFeiup3fPjodPStwIrCqPPpy4xMlR4W5cS4rGb0cuefMvzoO7geJYfgQO9CQFfSfsme M3RhvP4euFgHiDIU+3DSoa1ZH7u2+AWWtKihQMUlnMjZnJDXw== X-Received: by 2002:a17:903:984:b0:2b2:ec31:25b0 with SMTP id d9443c01a7336-2b98741da0dmr22832185ad.29.1777441565346; Tue, 28 Apr 2026 22:46:05 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:04 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Date: Wed, 29 Apr 2026 11:15:36 +0530 Message-ID: <20260429054544.123862-4-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the optional RATE pin GPIO used to select the HX711 output data rate. Update the example to show the property in use. No functional change for existing users. Signed-off-by: Piyush Patle --- Changes in v5: - New patch split out of the old combined binding update during review. - Document the existing HX711-only RATE GPIO separately and move the example update here. Changes in v4: - This property and example update were part of the old combined binding patch. Changes in v2: - Add the optional RATE GPIO property for the HX711 RATE pin. --- Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index a8eaa1f18de5..9134bbe41379 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -37,6 +37,13 @@ properties: description: Supply voltage for the on-chip regulator (VSUP). =20 + rate-gpios: + description: + GPIO connected to the RATE pin. When driven low the output data + rate is 10 SPS; when driven high it is 80 SPS. If omitted the + RATE pin state is determined by the board wiring. + maxItems: 1 + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the @@ -61,6 +68,7 @@ examples: compatible =3D "avia,hx711"; sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + rate-gpios =3D <&gpio0 9 GPIO_ACTIVE_HIGH>; avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A8F233F5A8 for ; Wed, 29 Apr 2026 05:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441571; cv=none; b=Js2aY2pJ4QsZACEhpFXYwFFmugjeC4ZuU3Wkfdj1llO82NSjntZJTodzlhE5UNc9MIQ1lOaoCn6S+HTiE0PZHN4tp8/SfpFBm8jIEQVEHZ2T9Tepsm42d7mGHeQ+JeDMdZSk4qmUxPX+dDiUCPQKvPI9ogkmLnUHYL2K3Rf4pbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441571; c=relaxed/simple; bh=rK4lvNmkMm633W8/JNjJJXCQe0WllFArMfDDBGRU2Jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DFNW+wLJF3j+t2/BE2+vjJReHBZb7Pg1v6cjlkiCDNBPW023kq4riJPfcm0kHDHST3XZF7/xuDKmjDqEEHofL/M/ZWEG8fNIKhj/IKlhJsRGpOyRNW5qJ3+6t/EKJD2Is0OfmfWA8PJMfkq3jWxzDuMAuCltf0C/ux+bqVdduRA= 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=mxkkjIoE; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mxkkjIoE" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2b788a98557so65193125ad.2 for ; Tue, 28 Apr 2026 22:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441570; x=1778046370; 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=8yG6eLDM9IfMZdVUIJDp52SWlVGdhG5JSrqqETcLRiA=; b=mxkkjIoEVm6J2DiH1o1M94kZMGacWv6bTCdXi0vo3CbKFD3DhUqi/BWeTS26oZmgSs nmkazPzbHI5e4A1nU+dYEkKJ3lHKn7TQClkbBgmzIcxmRIvpMIGqshA1ou7YoZmrdgxt N/bDxFJoIfmXzH/LN272fdqq2X8S/a0nR/vEt1VQgjrLOFwe3vzEeeO4UlICMZKsuLo3 RLJthiqrMSFU6WhKhTo0wbYyaiO3gBjeM4Jf/kQ+S3WwlBJARSN1Kq0mmg3bJeGbp6bT rs6VYBtDzLIFzgaovxrkMkb9FfCx6VdQlFXV/bzcT72aUszLzxe7xGglhSEhxR1+AT46 TjtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441570; x=1778046370; 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=8yG6eLDM9IfMZdVUIJDp52SWlVGdhG5JSrqqETcLRiA=; b=m011GWrbsEWzUDEz72euARaN2s0V7J/pNo+JUcvXNxalbl90bmi09KL7g2qQnCEPXh NUs0/9fPQ2mxCOKCR9i+WStEJ7lOyeiaHkdxJW0207t8GGs8J+J/4TOhqn+eVmYxdXiR cfXbWzLFob5XarUdxwgk0+5j+Sk8HujsxarTeKtYdYGVUKhZJUKukGRGcx1Zi7W/dPWz XiRUWFRXHOWnOwn2q7F7Xd+swFZ12Eeu+uDTXcKx+Y5K5zFqTre6cjKv3pY6vh6EUiIP I+CAvFK0j+3bPztEmFoSuqt8lrE86StgpV1ii4TFeefS8ttJpksPVG5UCIR8wbZkcN7x AiTQ== X-Forwarded-Encrypted: i=1; AFNElJ8c+kBgsuD6A6bH0JZOqPPFVbfcLc/wgqvsu4E6pttQ0KZrNA+ItdlM4+ApKsqSXY/PkskOycM9frrnzhM=@vger.kernel.org X-Gm-Message-State: AOJu0YwoXUt9F/7AuiwjE6XB8eMBEzwsY862T31DoW7PdmhQgU5ZTy4h xC88u91zjae90a7JaCkCCsHw3+iuX9jq6J/PFCBt89tfLiatoVYUXf28 X-Gm-Gg: AeBDievwfaenrhtR4K2NJWr6WXAPeKEaycm3XLtx4UpeTL7d12aWHtH6hXKPZil/iOT rxWn0yN1N12r53xZ4546RNZLry4tTY0tta4ySwsBv2nXsPIwZOpOe/YWOsL4nKkfz6KD/4IRyr6 U+QyxKAfsS/CCfKlfl1yXbNgK0uRq0ZZex3tM8IrAQLfakn6d98JcV/deeBNtfaBQxX7SWpR/uR IM78S9AxtpKhmuCJ0xERXHzGg2onOWA6L3aI5LY+ldf0SgwvuCIbc5cMHZN0NFnBnArtk4L+W5i 0qElrDPddUOGBYtjHXSFvc4LZ99gsBRIXylhFQV+F2YZr1AooW3yRKjbZZwFEL/w2fhXl3K0hEG VVZ36HT9XiYAo1sLVQ5MxgCvLalwBQYamRbo/hXprx+3a0s3JzuCHdPX19YC0ZDcSLLnb2++IZI DIo0LHucsMMmlfPCBlXDzPDvz8scZjYV2h79IzgXScpuw6abnWplyCgOrUeRlEK/dM2VF6M8tsb JbpRI0/lEpjbj5+FXlGYs1uF8B3ah9rMIXSJV9Hg5RbLVXdEA== X-Received: by 2002:a17:903:1b07:b0:2b4:5c20:ec7 with SMTP id d9443c01a7336-2b97c4ca086mr58037785ad.41.1777441570041; Tue, 28 Apr 2026 22:46:10 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:09 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/11] dt-bindings: iio: adc: hx711: add HX710B support Date: Wed, 29 Apr 2026 11:15:37 +0530 Message-ID: <20260429054544.123862-5-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the avia,hx710b compatible and document the HX710B-specific DVDD and VREF supplies. Add constraints that forbid HX711-only properties on HX710B nodes and require vref-supply for HX710B, then add a separate HX710B example. Keep the existing HX711-only binding extensions in earlier patches so this change is limited to the new variant. Signed-off-by: Piyush Patle --- Changes in v5: - Split this out of the old combined binding update so the HX710B additions stand on their own. - Require explicit vref-supply for HX710B nodes instead of documenting an implicit fallback. - Use a single if/then/else schema block for the HX710B versus HX711 property constraints. Changes in v4: - Add vref-supply for the HX710B VREF pin. - Remove dvdd-supply from the HX710B forbidden properties. - Add an HX710B example and the vref-supply constraint for HX711/HX710B. - Update the HX710B description to avoid channel-number wording. Changes in v3: - Drop the old vref wording from avdd-supply and remove the separate HX710B example used earlier. Changes in v2: - Add the HX710B-compatible, dvdd-supply, and the initial HX710B/HX711 constraints in the combined binding update. --- .../bindings/iio/adc/avia-hx711.yaml | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml b/Do= cumentation/devicetree/bindings/iio/adc/avia-hx711.yaml index 9134bbe41379..b2b5c7bdf05e 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/adc/avia-hx711.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: AVIA HX711 ADC chip for weight cells +title: AVIA HX711 and HX710B ADCs =20 maintainers: - Andreas Klinger @@ -14,9 +14,14 @@ description: | differential input channels. Channel A supports gain 64 and 128; channel B supports gain 32. =20 + The HX710B is a 24-bit ADC with fixed gain of 128. One input measures + the differential voltage between the two input pins; a second measures + the DVDD-AVDD supply voltage difference for battery level detection. + properties: compatible: enum: + - avia,hx710b - avia,hx711 =20 sck-gpios: @@ -44,6 +49,17 @@ properties: RATE pin state is determined by the board wiring. maxItems: 1 =20 + dvdd-supply: + description: + Digital supply voltage (DVDD). For the HX710B, DVDD must be + greater than or equal to AVDD. When DVDD is a battery rail and + AVDD is a regulated supply, one channel monitors the DVDD-AVDD + difference for battery level detection. + + vref-supply: + description: + Reference voltage input (VREF). + clock-frequency: description: Controls the SCK bit-bang timing. The value is used to derive the @@ -53,6 +69,21 @@ properties: maximum: 2500000 default: 400000 =20 +allOf: + - if: + properties: + compatible: + const: avia,hx710b + then: + properties: + vsup-supply: false + rate-gpios: false + required: + - vref-supply + else: + properties: + vref-supply: false + required: - compatible - sck-gpios @@ -72,3 +103,12 @@ examples: avdd-supply =3D <&avdd>; clock-frequency =3D <100000>; }; + - | + #include + weight { + compatible =3D "avia,hx710b"; + sck-gpios =3D <&gpio3 10 GPIO_ACTIVE_HIGH>; + dout-gpios =3D <&gpio0 7 GPIO_ACTIVE_HIGH>; + avdd-supply =3D <&avdd>; + vref-supply =3D <&vref>; + }; --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 457B3405F7 for ; Wed, 29 Apr 2026 05:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441576; cv=none; b=GgrXrjk1Cp9pxu+V1FXt2k6RE1y+BhPN9/x/IhG+RyvACx4Jgr+zxTQA1atMcPhuN4ZRvYutms/XWLHonEQaUP8HMA7XUNYjZ7w8yI9cWZ+y539x56U748MhT3ZfVe4gFM8uXvvhtJdZwE7D2f3fU/eEMKElIovmKMt2HlY/RNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441576; c=relaxed/simple; bh=DK+4iAJQPI8TVOZxQTPKT+oWqZk7F5L4jn2U7XBUkuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UUVJbNerm1nc8Sb8gvlquCg21ZIBxCVpxyG0pEeUqIB9LshhHBSTWOmTtM7tQ5A8XitG91VNvW2i96wC4UGud0miT43o2DMPOA6M2HtJ/XeD6sVrTLqW1YjKfGuV2vHV3s9duxkNcTDBJ8D1rLIk37SgRd2eft4Nl3TIbLPMpNA= 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=ssN+vjnF; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ssN+vjnF" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2b9705613ddso16717135ad.1 for ; Tue, 28 Apr 2026 22:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441575; x=1778046375; 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=5vPzZS/rZf6EXGV3veckeRDfcrkozmb7gGv2DlMOJnk=; b=ssN+vjnFSi6pMox6RHDhif0guGovZQGKzzxiaX84zTL0qqSQI+rK01V8Wy2CTSqdN+ mntT2sFZhVAhfIMc4OA2Iyzh3T/K9KBMdf4egzfsTWN1RmEB5fqySqP6w5SzkuAMjjS1 FjLOtXeSCTgs7YB2ol5fiYtlXNtP+CY7B6wKsUwULvMW7jZ1iEFWwreKqKsBx94LdmKx WQILxwM3ONXbWxTiQh7bn9G4ezN/YU8LxDgGQZzrLeXHLiYI4S49qTC6hRq05ld/koKb JKO6NxMdpJv8oS6ufA2oNeu8vWWxUs6svvGFe1A7zNFef5NRann93kGfOQdR2rPzXHTl HPbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441575; x=1778046375; 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=5vPzZS/rZf6EXGV3veckeRDfcrkozmb7gGv2DlMOJnk=; b=Dsdw6Z72ZyJwUBl7ljFBLnRElslRd7lSEvTMDzrCPEhsjuYeJsSyiecOJZ/m0qMdkk 656ujopc4TIqKaXPBw51sVlw4+wjSPk+0QdkWXbQkWwNQ4vblTr2LdIRiDDR35MaCHxX GqHVKyzqorzp8xVH4j4YPiC6rVqVncZfR3Hy7FvFdhUfqf36sL3zj6wcHeIjDEkqOUEa 9R2l3N817ZxMI7M0DoCflSFYNlnCrsFQMpapEP0kepMIe9lw/VleulbCbxhZU+zFVGCC kUZN3b+Dvke4ufAjQ/eJLxGjdD/HEr23ioepO/OSQMmzu77g64QcKshLJKyXWQjLXdlp kOmw== X-Forwarded-Encrypted: i=1; AFNElJ8Hc+cBVQAJgmmS77wbS+aT2SM8YP34ISi0hGcmfn3iqUW52MTbglJibP+4J5WbYNQ5qLIedeZn9Nyv77U=@vger.kernel.org X-Gm-Message-State: AOJu0YyvG7Pxqpk378kkmSuwG+8DF9sPlS8REdFTy9rT+3IEyS41awLP CiXOnriNGA/Tae12G4oIQgDbe1DXgB4TfIr+rb/rYYEd8dOJqGvZ4KR1 X-Gm-Gg: AeBDieuKI8r6cUzFt4wlatUOb+sKNxU0dSC7eQUNulh32UT+gp0WVkA4z7T/qgCo05W xQWVy9fJvxXa11b/wa2BevIE0+qDhQBs2kHnQ3qVXu+XHW89aEWMHcjVwziQqpdN+QFl7tAuE79 pJLA+nyL5m23ZNpV5kz1Qvi8UhRglP+xFjeajY78fjKN1DKtO+xBFhYkHfS2MIJ5rXAzBkequut nwGEwKgj+g6I88TAmRg/PhVshrsxNDC8gob84JdVKUPZsrMsVTQpBPgPC/ksPcATOX6/19lvhTh t4rX9lKZ2Iqpb6hZGkhfGAWa60Kyb71irHvhKgb2ArmssuFvYSio6AwWLhKZ2RNnuQ58HMWSRSS +8/jCAdbWitbxH9bLe6Oy+0ICJ97YQ++XTwANjfkZ11aA/SjexQPsH3Hz4T+xZ32AYR5bbeDzRg zC8IicOmSZjVVbouVVHggKeD5D0lK79F3SXXffrvA9u0/pPrKB5pJ0N93XTHW/gd/fjWpTu9k8Q iTg/WWteG/ue55l9hyGTnaMuvqu/E3wmwkU2m03xIQf1v0UDQ== X-Received: by 2002:a17:903:1ca:b0:2b2:eb9d:1648 with SMTP id d9443c01a7336-2b98747085amr22502565ad.37.1777441574553; Tue, 28 Apr 2026 22:46:14 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:14 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 05/11] iio: adc: hx711: move scale computation to per-device storage Date: Wed, 29 Apr 2026 11:15:38 +0530 Message-ID: <20260429054544.123862-6-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - Add trailing commas in the hx711_gain_to_scale[] initializers. - Keep the hx711_data declaration in hx711_scale_available_show() on one line and preserve local declaration ordering. Changes in v4: - New patch added to fix the pre-existing global scale mutation bug reported during review. --- drivers/iio/adc/hx711.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 1db8b68a8f64..8485e18c949d 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -28,22 +28,20 @@ struct hx711_gain_to_scale { int gain; int gain_pulse; - int scale; int channel; }; =20 /* * .scale depends on AVDD which in turn is known as soon as the regulator - * is available - * therefore we set .scale in hx711_probe() + * is available; it is stored per device in hx711_data.gain_scale[] * * channel A in documentation is channel 0 in source code * channel B in documentation is channel 1 in source code */ -static struct hx711_gain_to_scale hx711_gain_to_scale[HX711_GAIN_MAX] =3D { - { 128, 1, 0, 0 }, - { 32, 2, 0, 1 }, - { 64, 3, 0, 0 } +static const struct hx711_gain_to_scale hx711_gain_to_scale[HX711_GAIN_MAX= ] =3D { + { 128, 1, 0, }, + { 32, 2, 1, }, + { 64, 3, 0, }, }; =20 static int hx711_get_gain_to_pulse(int gain) @@ -56,22 +54,22 @@ static int hx711_get_gain_to_pulse(int gain) return 1; } =20 -static int hx711_get_gain_to_scale(int gain) +static int hx711_get_gain_to_scale(const int *gain_scale, int gain) { int i; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) if (hx711_gain_to_scale[i].gain =3D=3D gain) - return hx711_gain_to_scale[i].scale; + return gain_scale[i]; return 0; } =20 -static int hx711_get_scale_to_gain(int scale) +static int hx711_get_scale_to_gain(const int *gain_scale, int scale) { int i; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) - if (hx711_gain_to_scale[i].scale =3D=3D scale) + if (gain_scale[i] =3D=3D scale) return hx711_gain_to_scale[i].gain; return -EINVAL; } @@ -82,6 +80,7 @@ struct hx711_data { struct gpio_desc *gpiod_dout; int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ + int gain_scale[HX711_GAIN_MAX]; struct mutex lock; /* * triggered buffer @@ -290,7 +289,8 @@ static int hx711_read_raw(struct iio_dev *indio_dev, *val =3D 0; mutex_lock(&hx711_data->lock); =20 - *val2 =3D hx711_get_gain_to_scale(hx711_data->gain_set); + *val2 =3D hx711_get_gain_to_scale(hx711_data->gain_scale, + hx711_data->gain_set); =20 mutex_unlock(&hx711_data->lock); =20 @@ -321,7 +321,7 @@ static int hx711_write_raw(struct iio_dev *indio_dev, =20 mutex_lock(&hx711_data->lock); =20 - gain =3D hx711_get_scale_to_gain(val2); + gain =3D hx711_get_scale_to_gain(hx711_data->gain_scale, val2); if (gain < 0) { mutex_unlock(&hx711_data->lock); return gain; @@ -386,6 +386,7 @@ static ssize_t hx711_scale_available_show(struct device= *dev, struct device_attribute *attr, char *buf) { + struct hx711_data *hx711_data =3D iio_priv(dev_to_iio_dev(dev)); struct iio_dev_attr *iio_attr =3D to_iio_dev_attr(attr); int channel =3D iio_attr->address; int i, len =3D 0; @@ -393,7 +394,7 @@ static ssize_t hx711_scale_available_show(struct device= *dev, for (i =3D 0; i < HX711_GAIN_MAX; i++) if (hx711_gain_to_scale[i].channel =3D=3D channel) len +=3D sprintf(buf + len, "0.%09d ", - hx711_gain_to_scale[i].scale); + hx711_data->gain_scale[i]); =20 len +=3D sprintf(buf + len, "\n"); =20 @@ -511,7 +512,7 @@ static int hx711_probe(struct platform_device *pdev) ret *=3D 100; =20 for (i =3D 0; i < HX711_GAIN_MAX; i++) - hx711_gain_to_scale[i].scale =3D + hx711_data->gain_scale[i] =3D ret / hx711_gain_to_scale[i].gain / 1678; =20 hx711_data->gain_set =3D 128; @@ -574,4 +575,3 @@ MODULE_AUTHOR("Andreas Klinger "); MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:hx711-gpio"); - --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E940338E5E9 for ; Wed, 29 Apr 2026 05:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441581; cv=none; b=lWyJ7gCjlGDOh8zrlaIt2TkwZsU/6Wk7RNLoPYexIoVfr59augKEoBwLhneNi8jhg5bGsnJp/vQpktsNTnbrolMDzWli1gIZRlpwDl4RMVYcVzrNpetIR//0PaCT9guregKfBlSDEk4hNvbka32bQlMOFub3mgaoy7WYQs6Zq70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441581; c=relaxed/simple; bh=2qGN2/JyY+PW6JisHDd1B4IGPJkoaZpsrPLx3iP/KD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b5IPg7NjVCrA0Sqj3/YIKkFrUwRRjXQJCLPdOUX5l54jXC1iBP7I5m4tlIZG8kMJ5M9PzJ0JzPVXoqc3Pw3UegPl2Wsfw3L5w91PY+BGvuw2nDMYXq4y28jqG26G8OHrYgtHXCD12bctOp5Opir8pVX5WjjNMaSwm/m9qHKkx18= 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=cayF7/Hg; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cayF7/Hg" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2aaed195901so53141935ad.0 for ; Tue, 28 Apr 2026 22:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441579; x=1778046379; 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=6AugfgYXfL/2aKKIAu18a96jQgE8unArPdW53FSnoNU=; b=cayF7/HgnC52gvZlADdmjoSDAZqSN/OUVMv7VaEZgmOLzcue1rlUTXH65kbF1IqWuE Q3WRNzQhE6/AZmZNOOrHJPUYMbkNT4f1huk62tc2DEymqM7WOscGxExurYlAGiIDPsbt R7Ez6Wm/+DLbkMVxA71q7xP9+lIG63FIOPy5aS+bZDxkS1dcqqzgdJbZfYB5AGABqxDx t79wlRoEfPammYsJeVh1pO/fe8OlGLIDCABmdLPQx+ySmzKQkTM5Ll9sKtN1z+y7DDSt KjXz13q5N+nPm0PIgWkQ2ZszFtbjkVaSClQhEJpy0TSjX3xvRl0BnKokAKU2zaj+1xcc hu/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441579; x=1778046379; 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=6AugfgYXfL/2aKKIAu18a96jQgE8unArPdW53FSnoNU=; b=lCfwX8KBJQBbP5aFcDCUeLiq0aXLUaUu03g+/pdLzxs8iXG2pqu+TalnoszJXarxgr wxob/1fCaxgMCH4x3vHeivO9pgGa5rpWsf72WD7g3mbvn1I3grNLrFOsEUcHT5LkyhZs eYQ35uBRvQqoj0TAb6z5V2znZQsn+bJUnBaNlroBigIkKEu8nrvI3n82LJDFeszfPyqY vERIsd+FIOtSsXSklAQnSJsNrEZ8JiUZXN/8m6RDRHHCnoydvfZs2shvV5voxJBp5ETn ddWHbCTUUG2qHFedT3IHMWxkfLLjm476U01oBD+BGWyjW7oIqc3Kde4md97xgkN3v8b/ LUfA== X-Forwarded-Encrypted: i=1; AFNElJ8n/KT1nX82HNT+98lpnpZCKGGCYeZZVQFkhkPAmdaUPmr2o3gVqeYj1V3B70muGnfQB+9z/PewrCApvoA=@vger.kernel.org X-Gm-Message-State: AOJu0YzsLJIPhu4V1qszmfrv6h9V83fE6ZVKHkAnPS2xIHEr46gK07ka rpkLS4JbAAzWI30lXuf7QnaEfucd+Bp5OLVFO/H9zZf7U4sHABb3d2CP X-Gm-Gg: AeBDiev6zpt9iBON2H3ExOIU0AbW75N/V5tecvJrTxZn1i+eOsazLGCUxWEEJ6iGyL7 0I2IlQtuswZ+Cx7jigZmB5tFS9jrdgTTm4PY2td0sftAx5shrQEBSSOvnwTvkfiqsATQNxmm9Pq oTjjvbHbztEj9Zsfqy95kLDJUVH5HXK8LUvfXeaY8Bse/uzfkVIRkITooeJfUOoD1bnPXz67HBV N8E5XepuTxbGnEW4ZHD4AICa8C17fPBeuB3X+NikbQPgOYDGMcAzFE2oUIHyOS4WdP4tFp00msB qyAcgUgeyJlhZyNBf48CMPZw7D3A1F2Q8zvcjiLaKbQcpIZU9dUNOaThzznxD/ZMYb7AVBzdz4E fFavL69lpkBq3WbuSbbtoTq+drC5lLne/dyvHrlrGC33IAW/A2EKO+ZZZYwUd6TbT8p772BbGyk SniLNKMxQdo0tnCZ+Ix0Rbdv2cVI3xXU0nsKwCVzAulHWbTwsiMqFNRbSuamv+zujw7v66AySmR sBDXVJTOyAk/pqv5ljZKrUjVrsFDnPLch+vXTlNBaQJe89Erg== X-Received: by 2002:a17:902:e34a:b0:2b0:4579:ae6 with SMTP id d9443c01a7336-2b97c4cb993mr46159175ad.38.1777441579261; Tue, 28 Apr 2026 22:46:19 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:18 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 06/11] iio: adc: hx711: introduce hx711_chip_info structure Date: Wed, 29 Apr 2026 11:15:39 +0530 Message-ID: <20260429054544.123862-7-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - State explicitly that this is preparatory for adding another HX711-compatible variant. - Move linux/array_size.h and linux/dev_printk.h here where they become needed. - Use "missing driver data" for the NULL guard and preserve local declaration ordering. Changes in v4: - New patch split out from the earlier refactor during review. - Keep hx711_chip_info fields in their final order from introduction. - Add the NULL guard on device_get_match_data(). --- drivers/iio/adc/hx711.c | 43 +++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 8485e18c949d..666f64284a0d 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -4,6 +4,8 @@ * * Copyright (c) 2016 Andreas Klinger */ +#include +#include #include #include #include @@ -74,6 +76,20 @@ static int hx711_get_scale_to_gain(const int *gain_scale= , int scale) return -EINVAL; } =20 +/** + * struct hx711_chip_info - per-variant static configuration + * @name: IIO device name + * @channels: channel specification array + * @iio_info: IIO info ops for this variant + * @num_channels: number of entries in @channels + */ +struct hx711_chip_info { + const char *name; + const struct iio_chan_spec *channels; + const struct iio_info *iio_info; + unsigned int num_channels; +}; + struct hx711_data { struct device *dev; struct gpio_desc *gpiod_pd_sck; @@ -81,6 +97,7 @@ struct hx711_data { int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ int gain_scale[HX711_GAIN_MAX]; + const struct hx711_chip_info *chip_info; struct mutex lock; /* * triggered buffer @@ -456,11 +473,19 @@ 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) { - struct device *dev =3D &pdev->dev; + const struct hx711_chip_info *chip_info; struct hx711_data *hx711_data; struct iio_dev *indio_dev; + struct device *dev =3D &pdev->dev; int ret; int i; =20 @@ -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 Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18B9B349B0D for ; Wed, 29 Apr 2026 05:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441585; cv=none; b=QonE3BznbGP1IiW3LULyLX3eQQwJBgKi01f6C9A5sQHg9Ss6mHoP6YJTo57znowu/0NrESSWTW/UEL2GC3CydHxNbLrUMHQojqrOEuTuYBkA6Lu3DrANwIGMIpjIfRmVvGej4vGYent59onzj7KkELeaZBD9+yMUQWVVQVPPnac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441585; c=relaxed/simple; bh=xXaxi51qGj7aWurvmfktAlX9UTUq1LtX72gN1BATBxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n981kIDWFveTKeg/hwUBxLRLk1itJ9r3W1kzPAOcA9Hj3LkqL5wrMXC418NgzDbxjavB2ebNJGPYsZ4bFgqUNl8EWudL5kTAeIvusX4tPjV3ObLcyOn4t9qhDeem5AgrHfnFxcVwYHprLODLWZxCxd3TTlQCqAnPTy1jIVYrGXY= 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=OirhAIjf; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OirhAIjf" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2b24fede2acso80311265ad.3 for ; Tue, 28 Apr 2026 22:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441583; x=1778046383; 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=pxEW3u9KIKQo+IcX8Gj4fVHnzWaGq05CdwSfKooXYVY=; b=OirhAIjfm7Rhik0AuLp0Nslvu++fvKXzdfigB4laAFx3VXS+PZLc0FJX8GgKZu8j6h Z+2FIGj6HW248w5gHn3fsVwjD2MCV6HkQ489hlWKWmhXD1szT3FRVt4GBguAwaovfUIq QEw5SjQ08yj3cgCwz2hu2Ujj7RrJ4Fy6oMggwsJnWteR+joHPQBpoLA3urq1j4BojVgE ND56zx9ewilRLsIKugQfWaxOSKexMFSerIpoVe/GkIDh+stobQokFqoebUJ6LYJij2Q2 64m5n98dpwg/5weJ6V/z6s3U9dFe6ZP5pS92cCHhLliinjNVbufJxthOxeHYnXzFhwhw dxyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441583; x=1778046383; 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=pxEW3u9KIKQo+IcX8Gj4fVHnzWaGq05CdwSfKooXYVY=; b=DVdvUur+nuwoM+HK6e8K65Wdrbc7MiAynXl8jbXzSNguRsF+lZnTU7t+9n3JD/pCP7 mJ9RwtwuiD8P8MmDhWM4kLRwkV26s0F4RgR8+FdsdbX5jYrkmsUwmlsxyVKm8G9bjY6g bng5BaPKMICqeMy3QvQ16lqg9Hj0+lEb+j7o+LBmLNqfGqJxTUXf5cSYsUjBcqzGT5OC 29gr6HHViGSxJzuW0SNILotrO4Sb3FgjyrYDxDP3qBVNmAsUVnlf+WAZ9XS9dpzN4jgT kHcjfJYUfrP2aVlZSYGLegwvjou2+o25BzuviePPUfAVzbwEnkImOpbXnMoDNDJDcnKj P2WQ== X-Forwarded-Encrypted: i=1; AFNElJ8qgvSuWHlnbjzhC3wZaDqs2dwDcRLU5wAqC04vSYWqcFTQo1jKrXqP6xjSI7ZcqqUwqA0/Afpts6NJOwg=@vger.kernel.org X-Gm-Message-State: AOJu0YzP/QjDardLzkmJWIbeaInCEaSFxgR3r2qyEPwtV+X+0oT9tNQQ GE8Gd0s0+ANS3Sma4yPFYEWWjUj/jdAaFyhbDFH6Gqj6Q/dgZac9exVw X-Gm-Gg: AeBDievUyAVkUPMytAbR+CWLkbGLA9gDe347/2fF+5i3wUmNU4XW4iiRaC1o9Ca1Sv7 e1dxJuxLas98q2jr/6sgYZomJS1nTWP7wxIw4tGqR+lak/PdHLalKab5Ne8ElpLcmYgkZizlx7y cC09wt8r26SMoCa9pshUawK4MCN0z6cp63iHQi/ZQUybpBqkRCILuW/9APuMY7tQbW6tHIQxeJV DQkMhB31ZYaxTjFIijeguMUztkhRtXrNf2Bbv95f/37uwKHORBSwf5Cem7a7d1REKKkW6rD3cV+ Af+lIzqGGvdcVI1JDVV4twA1cR0oPD3JvUA+2ES6gbwZmPZIWazGtFdgoJjC0iql+iLFwR8cHdG r62MZOZHkIiCP8StujlN8ESM2q1fzFMJVxl3mX9KnEUqT3SgT/zJn3HTIw+G9Xn73LT3npe/cYI kGlZMZSWb4ZjEyD9NxjKptkSA5yjOfLw/ZURuzak67egbVnvehO4De0uTRJGBYK4WbWMXHcnzPO tl4RuGlw07yu2VKGXhuWIw78s7XHameAokuWsXJr8Uxpdi5kA== X-Received: by 2002:a17:903:380b:b0:2b0:663f:6b53 with SMTP id d9443c01a7336-2b98733776dmr22390335ad.13.1777441583465; Tue, 28 Apr 2026 22:46:23 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:22 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Date: Wed, 29 Apr 2026 11:15:40 +0530 Message-ID: <20260429054544.123862-8-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - Split the trailing-pulse refactor from the loop-iterator cleanup. - Keep the loop variables unchanged in this patch. Changes in v4: - New patch split out from the earlier refactor during review. --- 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 666f64284a0d..d85ff2f4a3dd 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 Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78F0938F941 for ; Wed, 29 Apr 2026 05:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441590; cv=none; b=XvBgl8ojgvsUVU9VCC0Nmv6ICBNpk/ABpxwiKF0cZ7ME8LkLU12/7TW9r5KM6HfVcA1JiuKw4IdapSdQiTYqBkhtU2okMJ7Poe470qXYKhG9prQvbiIwufI+w0o8++34RqUncAAiStTseZMTM/2tN9z7s9PgRmf9d2e7jQeAnf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441590; c=relaxed/simple; bh=8jcauZUpKBKt1Y2SRePdT2j5+qzSTeLWSFY+PfQPmXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPUt1Vd74b8MBCvP+cDzkhG3oo6xjzLL3N2s9RijbBwaL9eSBZADPAwxBhOSFV5QyP0JDkYNVp190q2nhB7jBlvDD1UjVdqTwP4qNFwDMBE9vMMwxLwXXvwU8v8zsmO9nflxx8StxSEfiZvrK6Jqi/bhbpY2YAOcgz2E2WH+xoM= 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=g17JNizT; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g17JNizT" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2b24fcc2b5dso77557615ad.1 for ; Tue, 28 Apr 2026 22:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441588; x=1778046388; 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=z9GS+fDU8N+RMGg3TIx8An5pT4tHPP5/YiqsDlbIWGo=; b=g17JNizTchzVAnSbb3u+gEZiiVPDHhOKO4BnQ3ATthBgEF5hjMOiMOiF73SwwwXb62 djZpvj04prQbTLANsVCv/lyFUCTZ64TrCJ1IX5k2evLhJif5EXs1IIC+DAp8xe4DYvGd Rq3lN4MC9GEneoFHQGtThEsdkSSz15MJK3MPBAJkA4h7Zo3jhar6LUGj9KppqbgmihLn n81cDBYLUIz1U1qvSgPja7hmnK38c40eeBkfKL41S5EdxXxGxSXYej9Q5H6SCrp77DLn kdpJoMhK+TzQ3LAKtOwvCY4VGyVG1RUgkHMM6FuUN1jx1btmfEK3kYkLFyjorbngtRqf Tifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441588; x=1778046388; 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=z9GS+fDU8N+RMGg3TIx8An5pT4tHPP5/YiqsDlbIWGo=; b=WpGgXri+Fmpxlj6OiGjq+DzmZFGfu9on9UUM25pvsBE31Y2MJdTVxcS4gqhNKKXaj5 vaiyPVFUvFvwGhFG6osc5oFOL3wdFNwiRRkHbAv5RzsI6sDMnqpYkqNTMEjmGVgRayCk 3gE05/j8GwVuWeAd8z3UuwdeX3jHWEgfiB5zpol40UNg9tC7WVFfjk+azkoVCBcKJDfN 9cT8IyGFHOBzol/cQR9aDbjM71l0lGp3qvZweuoJAVbW86bH+psdxKmXxPpjX04akOFg rWdLEZ+9qNQXzNAgm6RxEy5QisZBnGm8bw9ca7eWxWRFOT6x/OyCccU47eG6gywhF0zp ieww== X-Forwarded-Encrypted: i=1; AFNElJ/8FAEvH8rsxAhr2rf02q6wqnq/gWQJAHpi35dV2t3Bl+OoL6trMSBMYlDLrbGS5pB/FTJMFrRdBLvd3l4=@vger.kernel.org X-Gm-Message-State: AOJu0YwyD3PnNp/l9CU5TzUGOx8VgNpWYOKVB7gNPgsLPnoHbpebltlA LyWLVTH+EiOeXnLak02kHlK2ZRsb4bMJpVYXAqTcjeowJB1ipfGrsj7v X-Gm-Gg: AeBDieuz/GKODUTqfB2Tcl42SmDwtIIVc1XcKXErkcMqlDt9hdcjZWpyhOuEeHpixfU JygKPu6Y4U2Sk2yozJsxzE2bDbkEtlg6LHvhdiJNIdzDsmxxZBBnUVIB+9splyq+Y7nlBVjpsSt bn69DGyqfGzxFvetmWc9xIkU6Ng+PQYblcMj8MdHIUuzqnpa5gDULL0HF4T8bSnkccsPIDhVO3t 0Emwm2u5ZpkPUoheqYVp2jHAqiwnaQYUR+jPCVYoe+pB90xQ9D3u3R6HboxdgCMuJ3YfMYVjQsw bgpHq0aDX1sWeiImJiUvy4WZMtc5kssQJNBY1yqpKyAXJ1zOlkoUwc56JP3bfSx2V31XYN0KMJn 3Z/v5yuKjcEOQ7TmSsKESdqn03Paa/zaAzmArAqFaJy54FtSuYV+YlAjMiIQ9kFUZ/BbnFQ/q74 29rX9brRbPkqqnRpCOa/bJ7X1qeaKrr6r6iAJZIhevES8/d+I6Aw4XS9RCUicW9MwEupWTmP/UD 6bwyITt51GG6B9i/RNbuXNEXjxGc5qILl5NtevxJ4BOfMAcoQ== X-Received: by 2002:a17:903:985:b0:2b4:5986:cd80 with SMTP id d9443c01a7336-2b97c47b524mr63574105ad.26.1777441587586; Tue, 28 Apr 2026 22:46:27 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:27 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 08/11] iio: adc: hx711: localize loop iterators in hx711_read Date: Wed, 29 Apr 2026 11:15:41 +0530 Message-ID: <20260429054544.123862-9-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 the trailing-pulse refactor is in place. No functional change. Signed-off-by: Piyush Patle Suggested-by:? --- Changes in v5: - New patch split out of the trailing-pulse refactor during review. - Use unsigned scoped loop iterators in hx711_read(). Changes in v4: - The scoped loop-variable cleanup was previously bundled with the trailing-pulse patch. --- drivers/iio/adc/hx711.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index d85ff2f4a3dd..15b9f78b6a25 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -157,7 +157,7 @@ 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 ret; int value =3D 0; int val =3D gpiod_get_value(hx711_data->gpiod_dout); =20 @@ -165,7 +165,7 @@ static int hx711_read(struct hx711_data *hx711_data, in= t trailing_pulses) if (val) return -EIO; =20 - for (i =3D 0; i < 24; i++) { + for (unsigned int i =3D 0; i < 24; i++) { value <<=3D 1; ret =3D hx711_cycle(hx711_data); if (ret) @@ -174,7 +174,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 (unsigned int i =3D 0; i < trailing_pulses; i++) hx711_cycle(hx711_data); =20 return value; --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FB2F33C1BD for ; Wed, 29 Apr 2026 05:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441594; cv=none; b=sMCdhyTed8x5QGq+Zp8jaVKEnZgGRlEI0wCjuJzmNTr6SGh4wgF/1p5PO/vRVGiWMpFGllVrtOveIv8ncJmCG4e1sdLPhVW2bp1tYUP19U5Z0ULwe9PUXbYoBbmWFAmxdAp1gNiW81xMa2QQj+Tk39VjrQ5FQwWa5t2cqXIFTG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441594; c=relaxed/simple; bh=kQZvYd3COKoX8RudV7x4j1dykAfeucnnU3nu7dss4Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W4pe5cUEHB2yoWTFECLyLX5V2Y0/EgX7AJtNRuTHTrDhtZhEO9daZb2StZADztSHw9f5Lljjjak+xXCy6pj94rTgtf4vrQHH/xD8iFS+EEewncREVM0wfBHLeKLNiPoc3Lxa8X29ARtsUs4P2ysRKGahZtp7+hNUIta3LzGd/FA= 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=MkdlTgUN; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MkdlTgUN" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2adbfab4501so56481545ad.2 for ; Tue, 28 Apr 2026 22:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441592; x=1778046392; 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=4xKyx1TNWCB3y9Efgr+8HQY2irrCydQ2wje2Tvlo7Ds=; b=MkdlTgUNcoONGMQ0aJPM9z06uhAW00PHpZbOwobPFkO0iHU9j3B0mCiZHn7RdQb997 uIT4Ejs2hmEmrBlztQtyWye0yWIh+X0WPRTej/mqE40C7gokM6l+jJY8M4wXTmVe3q9M FjAywz/k2r86Fs1+yW+SCsinBPW2pSetkCdHKT1P2hpqKZj0YSTdREDhsjvoIMwP0HMD r58e82pJ0C/IGv/2RVX1eYnkeqTddUXZBciiJspQ4DbP2nChpqYqF0edWyZHPyHhLqmt 8UbBTGjw2qdwdrLgFVeQUYw0Zr2JrmXtjRIA8FWSPC/H0FVsOi37Lm/uSa/PZiABi7le qKPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441592; x=1778046392; 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=4xKyx1TNWCB3y9Efgr+8HQY2irrCydQ2wje2Tvlo7Ds=; b=lfrPd4Ex25fZYzwGUOvDATPuoMXmbaa5jXNJfxX4eE29Xi+yFLiQTM5v36i1oLykD3 wtRw4M4cTPXkLV+gKCIZJBhbwjpKPrUpc9hUJXBXBk6DwVyWMV/ST/xAYMcrOMHs4ngd nIlqH8hrkI0jbquI/N8zCxyBVP/iXNhvCujz6afqfzraR/KVafk8x1kNpBasBS9mlKse F4gab3xaLDqp1It2vf2L7rx4YHfr9YP22FGoHDEF4idePsByK/U5ABXdcRdk3kU6bNXJ YsKFpkfbNl75eFo6icQI99WC9Rk39MttQp0ffMjIskwd7rfaHIhHuixiXxiRqwqRBX0T Rc3A== X-Forwarded-Encrypted: i=1; AFNElJ9fJdc4epKKQxwVtxAMESGPAXKAmvr8dQen/shlaZ3/STiy/bPlXcH7T7SDLR9nHPFl/aa4tG+LzWdJT4Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzA1drmwhr9Z8Mlsb2DE4E0EuLWuaAbLZA7Nvlo1zuizGdC0SFy o2xcu68bu46NXjwdSKPLKEdtuKlUUxkbISqkmGLYDyont6cPBua0P9aY X-Gm-Gg: AeBDiesNy2jjK5Q9zeCWluzTCXEXXPyXtWZPoOduV7Vm5xnblydUbpmu1GAksYwA0f0 qpqTWUSI5tvE0Eh4lqhDNNvyTaCWiMTTruclpDIOHoVbdXbhEQMkpMkmJEEn8vyc69Cg4a9VyqV TZizMY9pJyZ6v3Xtmb0ln6XIcajQaG9i4/zCFcn9RRyH33+jFdSNosYCSeHs2vyc85jmPl/nO4z Ax7qyr0uH/pbDaHHC4BYQROm5aupAvWZYFvVJHMRsnxxyaOBRZr/Z4DysbzH0vvln7Cv9PghaKS pFuQJbMO4MxjH1+XCL4eiYPfFmSQWXgqPNXsjINi/Te8tz8OkeBqfQLW45VirHv1PUarbjKrQ+i RxqO5rp1vlfgRaEcOgE1nVyBt9MbUJcQ/jRIQrDAy1MzW/TRVq7HBSVjHMfIvzQ3QmGbo20AAOp ZX/1fYSVfDQjWjc4sh15yDHnWFCZSmMTg0+FfiVLlzQljK6EbI6b0flbP+tN1Ftt9OODEjndVmk byyxdnXVVb3JhPSn4QUKvHvpb2CUgD5aCPlkfmMj7Xn5E7ZIlJh4t/0of0+ X-Received: by 2002:a17:903:bd4:b0:2b2:ebed:7af5 with SMTP id d9443c01a7336-2b97c415991mr43426645ad.13.1777441592593; Tue, 28 Apr 2026 22:46:32 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:31 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 09/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Wed, 29 Apr 2026 11:15:42 +0530 Message-ID: <20260429054544.123862-10-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - Use "change" instead of "patch" when referring to the later HX710B follow-up. - Extract hx711_set_hx711_channel() so the HX710B patch can add a matching helper. - Reindent the triggered-buffer call site as requested. Changes in v4: - New patch split out from the earlier refactor during review. --- drivers/iio/adc/hx711.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 15b9f78b6a25..914c6efd0f96 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -264,7 +264,22 @@ static int hx711_set_gain_for_channel(struct hx711_dat= a *hx711_data, int chan) return 0; } =20 -static int hx711_reset_read(struct hx711_data *hx711_data, int chan) +static int hx711_set_hx711_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan, + int *trailing_pulses) +{ + int ret; + + ret =3D hx711_set_gain_for_channel(hx711_data, chan->channel); + if (ret < 0) + return ret; + + *trailing_pulses =3D hx711_get_gain_to_pulse(hx711_data->gain_set); + return 0; +} + +static int hx711_reset_read(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) { int trailing_pulses; int ret; @@ -278,11 +293,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 @@ -296,7 +310,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 @@ -386,8 +400,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 Tue Jun 16 20:37:15 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 8F123390993 for ; Wed, 29 Apr 2026 05:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441598; cv=none; b=ljBKAX+yVzkb1pQ7npg+mHbm3oa3jW6thyp8vSSnevlCHXR/rcGU6G2zajXVdSyboaSosgwv7bKeI6Mk+xY3y9wBLHGJyL4zkdrG5HSx0fJohwa+jFIHqeNeHJFyhEIyFobFgx41DSazTEVzKlpft6b7xVVLIVdskwq8vjetj1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441598; c=relaxed/simple; bh=fQvcWMwpPn5jGYP4rTJSr7QPrnzNGFhXHUOHyu6rfqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fnpIY/QTqnUaWLxn4OSDCtEWE5YjaAlNl75p1Hgh5EbnTQYLntQVE12uvZXL6KhnAojopdcm8RlAY/z94OUJoSTWP20zsY3LeJf/tCI2mZsv9wJ4k3MsLdJKVXnFpSF8euHRMGsGWlONewdgwpXKtbYcBf/AZHvm+hhL+2yAlV0= 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=TVcH7tf9; arc=none smtp.client-ip=209.85.216.49 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="TVcH7tf9" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-35fb166b0c6so260506a91.0 for ; Tue, 28 Apr 2026 22:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441597; x=1778046397; 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=ERdmP9UytYv63GQaQ/8HDqVpk3AgA73GyDjAubkwUxc=; b=TVcH7tf9NYUNKP1AdQJxpP1l6TF9SmSlZrI5vyPPIo/2k+DXDhfH2hHV2SkB53gZyc 0f0DEM/zkTd70eT8u3NSAyNiPgQm6TaLF3VmXevgr5QTdLIS9dhwG2qJk9VzsfHvg5eW 3MkccEyinFvZLzk91m9V43/NYuvssTHuy+QEThd9Nc1Y9vFC7wIxKMSJjbmz7ZEpd11n Pui+Y0lRJd8TyPOMdmlBCFU6yQFlfQtXguw3v62TvWqU3+alWj2Pw8m/iXT4HC+Obj1K cZrLO+Zak2XWins+18S31Jvpr4kjjHrchEV//yC1NXrPBri4xF8OjXJdXVy1XrtcS9oE gWoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441597; x=1778046397; 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=ERdmP9UytYv63GQaQ/8HDqVpk3AgA73GyDjAubkwUxc=; b=A20DyJVKPHsBrT4REmbps6a8xniy2Vrl8oyh+2PhbuEwIUjY4Dyul4TQvoxRWGf8Tf RmwjMVrBbP2/TxqpHXPceDpLT/V13Y3x6BVm+7sTwtzRv7I29EsTRukJ1nfzLoASSLL9 f11Ni6qI2Ka7IdGOHnhPvXA53IdPVVt8cPQaJiLy8P44d+bjFwSdGl1Ka8xXj0yT8QU3 LjOyCGICrY4Rso8NQSFFyv1YYgDpTkikfR0w1qcZJnZ1DQpPqQp9UPoslbNOnfnrnE0z qTiOAWcrGiIl3RkCZICtkIinj1frTBNH0DRDPwe5RX4pasRF4d+KVqjrcQtizs7UtVEH VbDA== X-Forwarded-Encrypted: i=1; AFNElJ8MRXqC9I0X4clTOeIif7U0idCRZtimc0wbhIuM0Q8UTsizWzqVKL4LeMou6wSW6QVxCVtaJ/8mRqpDjyY=@vger.kernel.org X-Gm-Message-State: AOJu0YzHon1MuCJag51IdE3fj3XaC363tqDLaqsxkQ3jxvF5FVAI80Mh LdnE0yMmocW3Kfh/WkjvGiN0FwbcPRdcdrBZtAeQWmd9sv9xyDoCdd5d X-Gm-Gg: AeBDietWvnTovqFwl0AnLOSB4Beb+i0Qvg1JydlXFwkI3c8gITJo4hvkNJ+TxFn9gZD cfdkPbQavvnnDImDR6/FJN2xtLAc2t4TUjX4arYpykfVvgNU6cC0eEM7k+x2k4BGebZwjtDDlCQ 18ZzhYC/FOPCvenqDUcvRZEqyp5dP7pqnvF4pVBuc/2gg9HCAvWCYw7IXWPfVkPiJ8U9MVBnoVZ /Vg17dssLRkNKO0ZSKilft7i7vaasMFG3NvO0WVLzxJEjTi3XO6SJ0SltzLrr07T7B6z6bdGQZw kak7DYmcDg8Wd5ivBcvuPEaqtoOK79IGFZhNthfmHR+ylvQkjzdkv5wJaw8QA6z3c3+u2VpZLLv f55ZhOpYfY+E/cJKGcFU+y53pWbx64P7yXwYv8dbpzDPs2YeLI+xm6bwCRvYNeBkXf9XmAeozA2 fr76kBRlZ3axigSLVQmvYjL7Pb9oRSvo0eaZaiF258Zv8MkdaEAfjxWgYGc4SsUb7pzsyZpxt6O d2d2R5F5TMeFcWict6MWZEMFItfIB5z43FVqxLBHiLgQrPgdw== X-Received: by 2002:a17:902:ce11:b0:2aa:e47d:e3b with SMTP id d9443c01a7336-2b9880a66e9mr17228955ad.0.1777441596911; Tue, 28 Apr 2026 22:46:36 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:36 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 10/11] iio: adc: hx711: split hx711_reset variable assignment Date: Wed, 29 Apr 2026 11:15:43 +0530 Message-ID: <20260429054544.123862-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 hx711_wait_for_ready() assignment from the declaration in hx711_reset(). This is a small preparatory cleanup before the later variant-specific changes add another local variable in the same function. No functional change. Signed-off-by: Piyush Patle --- Changes in v5: - New preparatory patch requested during review. - Split the hx711_wait_for_ready() assignment from the declaration before the later HX710B change adds another local variable in hx711_reset(). - Keep this separate specifically because Andy Shevchenko asked for the prep split rather than mixing it into the HX710B feature patch. --- drivers/iio/adc/hx711.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 914c6efd0f96..e72f3c2cdbcf 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -204,7 +204,9 @@ static int hx711_wait_for_ready(struct hx711_data *hx71= 1_data) =20 static int hx711_reset(struct hx711_data *hx711_data) { - int val =3D hx711_wait_for_ready(hx711_data); + int val; + + val =3D hx711_wait_for_ready(hx711_data); =20 if (val) { /* --=20 2.43.0 From nobody Tue Jun 16 20:37:15 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC6FF390993 for ; Wed, 29 Apr 2026 05:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441603; cv=none; b=GoyqwAAe5JP/16AOQKHP8QEyVJ7oju+Qv8QntR0FYMaZPYPkKyZ1BGAoQwlebO37+4Hhn/UFEoXheoaVppiUV9w+12oi1iVyA28Q1VuKnCsuhokXvOMjxXGTLObRC41spdgvybZOImSTI7vM7pJxYvCrklnyWsQh84BF9lVo1c4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777441603; c=relaxed/simple; bh=HJW5D//8BqgWA13tKfLLfTLZaoBlMcHxWPtJHqXciO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qj9ROFKnbfDdDX4YYHBz4mZGBWDTy4q2jRyMuwBJg1SjLX+VS9aM+aC8P4r4HkEJYr6ij3Aht7SODlVN0A6yoi7DpuFG+cwE8QxBYCA+r5krl0/0F0qKqx4NyJcer3OPbZeQtfsXb/BrScJIMgbpuJylTEM0u/loZswLKhqKDqI= 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=X+Y4fD2z; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X+Y4fD2z" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2b7d3ecc10dso39517485ad.2 for ; Tue, 28 Apr 2026 22:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777441601; x=1778046401; 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=C8XRdJotgf4uh9lwezR8ax8dhrSr+4NmvcAw2Ol7yFI=; b=X+Y4fD2z1g2OiJ+y3JBv6kCKdkIRCZjKKMJiNcliRtIlUK7rUBsseKBnhtLzmMk8+Q wNBpB1U/TBewYunMPfWcJ5A35eN0/J+ss+OWDYZ2rpYsgB3IK5vFT7iBDUH3zOFr3YhL IUhcFsBHiKy2JO14LKP6NlWFf2YoYZ1znUPDgZEpbrnp8uA+kXVWANNTEiX60AAX5YkZ pFX7sKjhLAbO+EO9VYDXPughapEzzEs9N5YLa5bU0nUkdkOeYmtL1Y2R4RVFitfOJSSB i9BnO+hWQx/pGKGf7FINolmPZDfNKSJL7gQtiJXxs6Y55nlYgnfWq8/0Hod4yznWVRVO f1LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777441601; x=1778046401; 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=C8XRdJotgf4uh9lwezR8ax8dhrSr+4NmvcAw2Ol7yFI=; b=WE9a3WYlEgivDmiy3ZEAh4cBXvxoHpN/Usi+pJJY0fDiVUogv60uZmEbsdtPyiOhAg rTmqVIvieA+mbfWuNdZR3wA/aCVQRvqUyJi30Xtm9DNH8wnKfbCRiRHYHmf1my3Jqg5v 5CgIULqBWnBE572dn08cdkSDdnyWlff553Ll+f3sWQ1Vcs6A7jv/BvwxI5HhnQzO+sD0 TdNMyn3E/iHJOk83oTE1aqXcLD6feIpLFOp0M97+gNdpCnVFM2er4D4QLBYAnwKOUQf7 xhkiwC1u1v7NufkXeA31Qzkj+QZExGQM8k5ANiSun/Oz6kt8s56gEimSyTsM7UQb+Txc Ak+A== X-Forwarded-Encrypted: i=1; AFNElJ8qOBFD0h+jBLzZCU1jR913ikNSnMw2N8yp6QHg403YmqQwyFlY60xO/tDfw/4FIel7seTN05h4N6WhAL4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxl+uvI7ixjs9qodfsR25vP0ZV8dI01AKl/m1hKr7SrJs6DGtFi cGU6KU3TbCI8qe1z4RcpNKJeRVhi0tkRKiADIbVmVHlpUlWYjzdFJEFe X-Gm-Gg: AeBDievQRSDzZlBE0MzFsthei5PhZy1kUvwJioWm1pnoT3HwA7xGZ+nuP5l0TPS4cnV AMylRk1TswLMbsLwEDYNJS2NRyVcG+5nFoX5L3u/jjGpOL2SR+X9jCLoSMOCuNw38f5STecLIxO RBNCRk7aHq01ccWlMYp56F1PuWRbEWNgdDyou71+vk9q3FUUakw2BDUDDCh3KnFDFNLNjBcTVai TafxeIbO0O5R5MpjrhOtY4YnYEBcF/Hxz01qIgJc7jCtHCwewwmVbmJ+5W1TNeFOHnSrSsNHfU0 2CP3Aw+nXX2fM+hPfofZ8V0DuuCoVMNfhDQpZSUAer9ez3tqlxFFqfQvnRHtrqaihxQKDp09Zeo Y8lQiu3775Tmrzy6aV1MDSJrx/TzyE24umsBWG08w7fcAxIhJZi6Il4W8di1IZqReYe6ff2C1F2 TTYyK2O2KGTNs7z3DhTV/f1dhZiEYfJgVhNBI5ElzuLf+4No8qhzTJjx50X7V8BtRzOsERM7oPo KzInpfWmcwtiXuqWdUNYk6JVku5dhI3nNU4inklXBl4Cvj0Zw== X-Received: by 2002:a17:902:d482:b0:2b2:9d60:5eaf with SMTP id d9443c01a7336-2b97c406c53mr65944585ad.6.1777441601148; Tue, 28 Apr 2026 22:46:41 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d01f:5fb:20b2:c2f6:85bd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98879656dsm9346365ad.25.2026.04.28.22.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 22:46:40 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/11] iio: adc: hx711: add support for HX710B Date: Wed, 29 Apr 2026 11:15:44 +0530 Message-ID: <20260429054544.123862-12-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429054544.123862-1-piyushpatle228@gmail.com> References: <20260429054544.123862-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 --- Changes in v5: - Fold the Kconfig help text, file header, and MODULE_DESCRIPTION updates into the final new-hardware support patch. - Add linux/types.h here where the fixed-gain fields become needed. - Keep a single gain_scale[] path for HX710B instead of introducing a separate per-device scale field. - Add hx711_set_hx710b_channel() alongside the existing HX711 helper and update comments and formatting per review. - Read the HX710B ADC reference from vref-supply and require it in the binding instead of describing an implicit AVDD fallback. Changes in v4: - Add the third HX710B channel (27 pulses, differential 40 SPS). - Use .channel =3D 2 for the supply monitor to avoid the differential-pair indexing clash. - Update channel_set only after both hx711_read() and hx711_wait_for_ready() succeed. - Keep a single fixed-gain scale derived from gain 128. Changes in v3: - Add HX710B support on top of the separate hx711_chip_info refactor. - Keep chan->address for HX710B trailing pulse counts and describe the first HX710B channel as a differential IIO channel. - Use unsigned state where appropriate and verify chip_info layout with pahole. Changes in v2: - Fix the pulse-count bug by storing trailing pulse counts instead of total SCK cycles. - Add .differential/.channel2 for HX710B input channels. - Replace the old channel-pulse tests with explicit fixed-gain support. --- drivers/iio/adc/Kconfig | 8 +- drivers/iio/adc/hx711.c | 173 +++++++++++++++++++++++++++++++++++----- 2 files changed, 157 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 60038ae8dfc4..09a1b29fbd9c 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -784,13 +784,15 @@ config HI8435 called hi8435. =20 config HX711 - tristate "AVIA HX711 ADC for weight cells" + tristate "AVIA HX711 and compatible ADCs" depends on GPIOLIB select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - If you say yes here you get support for AVIA HX711 ADC which is used - for weigh cells + If you say Y here you get support for the following AVIA ADCs: + - HX710B + - HX711 + which are used for bridge sensors such as weigh cells. =20 This driver uses two GPIOs, one acts as the clock and controls the channel selection and gain, the other one is used for the measurement diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index e72f3c2cdbcf..4c087e8b9abf 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 weight sensor modules * * Copyright (c) 2016 Andreas Klinger */ @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -82,12 +83,16 @@ static int hx711_get_scale_to_gain(const int *gain_scal= e, int scale) * @channels: channel specification array * @iio_info: IIO info ops for this variant * @num_channels: number of entries in @channels + * @fixed_gain_val: fixed PGA gain (used when @fixed_gain is true) + * @fixed_gain: true if the variant has a fixed ADC gain */ struct hx711_chip_info { const char *name; const struct iio_chan_spec *channels; const struct iio_info *iio_info; unsigned int num_channels; + unsigned int fixed_gain_val; + bool fixed_gain; }; =20 struct hx711_data { @@ -97,14 +102,16 @@ struct hx711_data { int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ int gain_scale[HX711_GAIN_MAX]; + unsigned int channel_set; /* HX710B active channel */ const struct hx711_chip_info *chip_info; struct mutex lock; /* * triggered buffer - * 2x32-bit channel + 64-bit naturally aligned timestamp + * up to 3x32-bit channels + pad + 64-bit naturally aligned timestamp */ struct { - u32 channel[2]; + u32 channel[3]; + u32 pad; aligned_s64 timestamp; } buffer; /* @@ -204,6 +211,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); @@ -224,8 +232,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->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; @@ -280,9 +291,36 @@ static int hx711_set_hx711_channel(struct hx711_data *= hx711_data, return 0; } =20 +/* + * Switch the HX710B to the requested channel for the next conversion. + * chan->address holds the trailing pulse count (Table 3 in datasheet). + * channel_set is updated only after both reads succeed. + */ +static int hx711_set_hx710b_channel(struct hx711_data *hx711_data, + const struct iio_chan_spec *chan) +{ + int ret; + + if (hx711_data->channel_set =3D=3D (unsigned int)chan->channel) + return 0; + + ret =3D hx711_read(hx711_data, chan->address); + if (ret < 0) + return ret; + + ret =3D hx711_wait_for_ready(hx711_data); + if (ret) + return ret; + + hx711_data->channel_set =3D chan->channel; + + return 0; +} + static int hx711_reset_read(struct hx711_data *hx711_data, const struct iio_chan_spec *chan) { + const struct hx711_chip_info *info =3D hx711_data->chip_info; int trailing_pulses; int ret; =20 @@ -295,9 +333,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->fixed_gain) { + ret =3D hx711_set_hx710b_channel(hx711_data, chan); + if (ret < 0) + return ret; + trailing_pulses =3D chan->address; + } else { + ret =3D hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); + if (ret < 0) + return ret; + } =20 return hx711_read(hx711_data, trailing_pulses); } @@ -459,6 +504,10 @@ static const struct iio_info hx711_iio_info =3D { .attrs =3D &hx711_attribute_group, }; =20 +static const struct iio_info hx710b_iio_info =3D { + .read_raw =3D hx711_read_raw, +}; + static const struct iio_chan_spec hx711_chan_spec[] =3D { { .type =3D IIO_VOLTAGE, @@ -491,6 +540,68 @@ static const struct iio_chan_spec hx711_chan_spec[] = =3D { IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 +/* + * HX710B channels (Table 3 in datasheet). + * 25 pulses (1 trailing): differential input, 10 SPS -> channel 0 + * 26 pulses (2 trailing): DVDD-AVDD supply monitor, 40 SPS -> channel 2 + * 27 pulses (3 trailing): differential input, 40 SPS -> channel 3 + * .address stores the trailing pulse count for hx711_set_hx710b_channel(). + * Channel 2 is used for the supply monitor to avoid aliasing the + * channel2 terminal of the first differential pair. + */ +static const struct iio_chan_spec hx710b_chan_spec[] =3D { + { + .type =3D IIO_VOLTAGE, + .differential =3D 1, + .channel =3D 0, + .channel2 =3D 1, + .indexed =3D 1, + .address =3D 1, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + { + .type =3D IIO_VOLTAGE, + .channel =3D 2, + .indexed =3D 1, + .address =3D 2, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 1, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + { + .type =3D IIO_VOLTAGE, + .differential =3D 1, + .channel =3D 3, + .channel2 =3D 4, + .indexed =3D 1, + .address =3D 3, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index =3D 2, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + static const struct hx711_chip_info hx711_chip =3D { .name =3D "hx711", .channels =3D hx711_chan_spec, @@ -498,6 +609,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, + .fixed_gain =3D true, +}; + static int hx711_probe(struct platform_device *pdev) { const struct hx711_chip_info *chip_info; @@ -540,32 +660,42 @@ static int hx711_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout), "failed to get dout-gpiod\n"); =20 - ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); + if (chip_info->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->fixed_gain) { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / chip_info->fixed_gain_val / 1678; + hx711_data->gain_set =3D chip_info->fixed_gain_val; + } else { + for (i =3D 0; i < HX711_GAIN_MAX; i++) + hx711_data->gain_scale[i] =3D + ret / hx711_gain_to_scale[i].gain / 1678; =20 - hx711_data->gain_set =3D 128; - hx711_data->gain_chan_a =3D 128; + hx711_data->gain_set =3D 128; + hx711_data->gain_chan_a =3D 128; + } =20 hx711_data->clock_frequency =3D 400000; ret =3D device_property_read_u32(&pdev->dev, "clock-frequency", @@ -604,6 +734,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 }, { } }; @@ -621,6 +752,6 @@ static struct platform_driver hx711_driver =3D { module_platform_driver(hx711_driver); =20 MODULE_AUTHOR("Andreas Klinger "); -MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells"); +MODULE_DESCRIPTION("HX711 and compatible bitbanging ADC driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:hx711-gpio"); --=20 2.43.0