From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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_data *hx711_data, int chan) return 0; } -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 = hx711_set_gain_for_channel(hx711_data, chan->channel); + if (ret < 0) + return ret; + + *trailing_pulses = 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; } - ret = hx711_set_gain_for_channel(hx711_data, chan); + ret = hx711_set_hx711_channel(hx711_data, chan, &trailing_pulses); if (ret < 0) return ret; - trailing_pulses = hx711_get_gain_to_pulse(hx711_data->gain_set); return hx711_read(hx711_data, trailing_pulses); } @@ -296,7 +310,7 @@ static int hx711_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&hx711_data->lock); - *val = hx711_reset_read(hx711_data, chan->channel); + *val = hx711_reset_read(hx711_data, chan); mutex_unlock(&hx711_data->lock); @@ -386,8 +400,8 @@ static irqreturn_t hx711_trigger(int irq, void *p) memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer)); iio_for_each_active_channel(indio_dev, i) { - hx711_data->buffer.channel[j] = hx711_reset_read(hx711_data, - indio_dev->channels[i].channel); + hx711_data->buffer.channel[j] = + hx711_reset_read(hx711_data, &indio_dev->channels[i]); j++; } -- 2.43.0