From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFF1F3E9C27 for ; Mon, 25 May 2026 10:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706351; cv=none; b=g3DkEEC0ASu3Edum9BDMnSEQLuHGav7DpUlVMVeiKZyfXp6yprJq98ZXtW+BZWvcWSr0O4Ww1TEkaru7fHG6LbWOfakxoQV/CZExddCLiW4Ptn36mcITVI4Any5bl13gMtpVKUQaO8kL+Qhqt0eeRAyPHFec9lNYJFgRRtYjeGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779706351; c=relaxed/simple; bh=3FrcsQlVziUdeKI/N9eYaCs4RJmRsrcZLsIz3cZSFq8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIUpKl/O133dd0brWGk/rlEtKpMNinHp43X55ZNJbZzwa5cRR3vffZ2DkiNXuT9twg6ivc5eEmkOHia0SgwjxY1AOsGM+S0fp+W+FccICuRpHlA61JcYXFa6BjlD6ARfQxWPH3LG7bUM4yoI5RoaxdqI+Mv+cyXE7egjLEbJtXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dZtk8YJI; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dZtk8YJI" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-36ad15213fbso525877a91.0 for ; Mon, 25 May 2026 03:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779706348; x=1780311148; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uk0PkavUtmrtR763X7Xl8KGOaAn01gQsV9JDZDG7T1A=; b=dZtk8YJIakMNipqUj/t5VM0UmqEioiPb7T2UipJtFDoWhi4qCo56fwFT2KsuV5PZjb k8aSFdt6dwFKw3IReX3g2yzvHufrQTQR+AWNiiqKvPX10vU0zGg+gJFpondnj+q7e2BK nM99xoOaui8jmirBTZOHXxna4aA8NIuWa75LUJ3iFuIW/2mu9D/BHE74ndl/bBcN4ajE OHVNerqehTF+KgMbTKtcPjOs0SgQKyRSTHFNoB+X9AdC8mOI4WzYVHcj1xrYzpQ8i/sI wGKEafYgnMumxyj3cBuAZu/ZxYi87OxevNP8atoijn5gEYP+PT8QAkzbNUccN9ZVVsn6 H7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779706348; x=1780311148; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uk0PkavUtmrtR763X7Xl8KGOaAn01gQsV9JDZDG7T1A=; b=lC0MwYfjzIMUpfvf30f8zPgV74BUXFuw2hDcUA0Iomc68syVBWutSNOaPVZqdkosRA 04IajJ76cNJ4aRH88Lo1nCZ5BjgCFm4dUAnQ9GdZv1K9UsW7f3vmHrxEy6TRT8Zy9jKj 3bb/iCJI8HNnmk8peNDYUWoVARxJTjWNop9p7U6usaVkLcG7kxvrS+Nf/tKfl1vN61r0 GwQOdetUAOJciE+Pn3h7Es2XzNSBMUt6q9W2njczbyHaab1EbImx27+crFMoNyAvCGDU 5HEwDrUIrJy1K9dNV72D0Ei2F/9g9KMLuSqOd9yHc1ayw2JjhO2GC9fjor9wkODqnq+b FtlA== X-Forwarded-Encrypted: i=1; AFNElJ+teUb6jwlvQgaMu3PNlPtAzk8DJrkUbp3nTyHldCZIFF6Z5cFIhCn1sTzqFAzeAntHv/Kp9gNjIztaFvM=@vger.kernel.org X-Gm-Message-State: AOJu0Yyen/vWJmA66+4trJ7YAw0IK2T2oQ1YDmhhSTcA7LXwMDRe6k4O nN5MwPyTi20CP4RW30NqMe/u+XchOFiHqx8/fJRIb2w1dB+sK65s5uUr X-Gm-Gg: Acq92OHHpJNXifFw3FypK1jnXrdFkoX9orUjR+nnulNNwmqkguB3kWNPbwuTvlsFbnG GqqiqSFZCxNBHh4Bg1dJkYTpiFjFTrPXBl56x/TWht193zqyAYyrvXovr5kfPKKRKIJpoG6Xreq JvOFQhB3A6DIfgIveSj1LemqIe1xYGXyC4HqgFnM5iaj8K7f4Q0PpLsNqbsk8uUdm2MihJDERjf YpYi/TR0Y8FfEid1sBFi+Y/ryjyJlFCdvUplWmR5+FJL01xmy/I3fe3BUheNd47iqzmZXJ/Pp3q tWQh8ch9YPt7eRVej2U4P1AZ+YDR35iDHyGUitQDLmlwkBPsSlLNWaW3UucA0U/WwrknnwQoPsI WKOzOCbT3m1hKzKP0/J38BcCmn+9dlq4ZDfcEdTfjgD7Agid8ukA3N3comJ6jGjAQuPz7oYArpb hCmkYRdr3ZgM/e9UY94lnY3Ee46PHVFdmGdE6rqqrSTL/VAtJAwFywfeuDbVViBE9F7fX4RmBoh acbNVoTqGYjHcU1yq+wwBDlCuvO5s3n6C9NXC73/j3Uta77ebTz X-Received: by 2002:a17:90b:558c:b0:369:932a:2b8b with SMTP id 98e67ed59e1d1-36a6778aedbmr14172064a91.11.1779706348076; Mon, 25 May 2026 03:52:28 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:2011:e829:fadd:33b:8fc3:b2c8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a7265a001sm9302388a91.7.2026.05.25.03.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 03:52:27 -0700 (PDT) From: Piyush Patle To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, ak@it-klinger.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andy@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Subject: [PATCH v10 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Mon, 25 May 2026 16:21:26 +0530 Message-ID: <20260525105127.180156-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525105127.180156-1-piyushpatle228@gmail.com> References: <20260525105127.180156-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Reviewed-by: Andy Shevchenko --- drivers/iio/adc/hx711.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index e5d842853b71..fde95758b9a0 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -268,7 +268,23 @@ static int hx711_set_gain_for_channel(struct hx711_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; @@ -282,11 +298,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); } @@ -300,7 +315,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); @@ -390,8 +405,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