From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B962253EE for ; Sun, 10 May 2026 19:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442811; cv=none; b=EYh5//PimcKH8cfHhm0yNEk3bF1G4tAp/fP2mWP6QZ2yzQuJn9RD6hXQ0zov1WpBhQzlpyoG//Sv0uIttMptaW9T1H5zwIqsgzDL+VbhlfgFDrtiaCYwaMw17H4Zo2DCOpSNShavlcpILdIf5sd+AGsOiv3eK9P4jBfqtftk/Mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778442811; c=relaxed/simple; bh=CcWVM+e3vOzvxPMHiHam/ZARcRos3URB+mD1NEni2ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aa6uXVbfkCQzH98yrxw3tTpdmC/GMDFaaqfoynlYim6D3Sa+4fHdcUa70ue2hn6lhnn9sMivquqGq4DU0BC8wIROqf15SBDDHOBeY9vvk31+PX8FKXa3sj4iMo38/8j2tnevIO07yEiSc4Ns8rg7Hn6aijoPWyqE0jgsge4rKqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HWqoo2SX; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HWqoo2SX" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2ba6485d219so22654935ad.3 for ; Sun, 10 May 2026 12:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778442809; x=1779047609; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zq8vqJkGxKnQ4HZxEPkyCpyl+unJgqOC2VHF9A/dltQ=; b=HWqoo2SXrcAwcLVoxkIgD+j0x4+3ROIqH7KRFVsslQx8rO4CmowrJYmRpaV2ODWmLw SJyIw13RhPVLhLrOSvbVsMHxgGzu9ilpHjYJV4yo9penjVe0FLqWUbUaIalhf5oLb4j2 MdBxcrO/J6ia1yW1jzsQW253bCEEAAsQLnHtLNSOtkhY+fuDD1sJtWAyqhZD2dQ7apFx UbCs8gHCSHYr6cRALxpu0wqS/Lj5tV6m+14GTWKTp5a+083oM1bHV8LcnUCCoYqZZaER 4yAwjskLVGzrMfM3csY5YhAyiI14MEPGwqlXliXObC9sunOOAcqoJVel7uwh2WALGCwC j4XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778442809; x=1779047609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Zq8vqJkGxKnQ4HZxEPkyCpyl+unJgqOC2VHF9A/dltQ=; b=K9otDG+aQDA30A3qIW6Gs9qXXzrhmCeAzFYaiVVquYH/h9Bh3sen8loEoQZfq0wWLk 9nnu9+drdmQcmZ/3yUXiOGSej/gwhIXKA4lSPNic17jhm41EwzvUowo3Z2taE3Zp9S/f bUmSY1Zb+lw0MluGHqbNyFPlj1vvGmsyzIVQgwUaMNJaKsxqu1TGa2HsaLDs6vJKMZA6 fwkiR5Td0/xfYZtoNZdS6k71SXjWU7h3orW4JqjaAWEdnc7skRqWLz5Jalfgc2ONrrWC YEtElS6pEJOCXcr/at4rQ1CJNDTofYAMVlV0Ui9f1xrnPb1Iqv3pLRRAgS4g/Q7khwVY Wcbg== X-Forwarded-Encrypted: i=1; AFNElJ+3mOiTTlRLOLxbYx9Bku1dQmNMhe6SJN5y1jeNR6Pd9EAwvEaxmARr5A4BpmYAeasUAlwOfUM7yWwvzNw=@vger.kernel.org X-Gm-Message-State: AOJu0YzFmqfXSjkjpNSEiG1a3cjKuJKOpgs1tZvIo0zGrIw5O71JgLCB AhE1sw/kukt81X/kni18u8b3AHM/VgGva7LhIEFfXaDg9ihoF/f4f+UW X-Gm-Gg: Acq92OH4YZtVxsr8bL5aC+0D6y8n4EywziITFV/PmHQswj5/EeHuAsNAPFZPGYwqW/u Xv2Yo637knahoe26SQXvR44CpBO+45YbbL7MNmBq49UEcVHL5rLSp4JhU2eqmYWKdRfm+1qZ0JN B5i5SOIyzeO9Y+470dZlZu2pDslYlyaIR8T15QzBDs0qeMxCFfT43i/4C88qSQT1LkriaKn3/LZ lyoR/hRhEtqq9b9qY0acO90QKg83FHL6ApOebq3jkCQuj5dO1V/LV7zLxvrpo24EoQ8nDdR8Hv+ 0UJ+yLcXax/855MfK9P4pYzL+CPde15SxGHBI+3+dG7xlQHaqtizVD4my3XhlkFcwJnoGBHfSlu zD/SldLRHdaAvodEA/BoK+Ag1TB9IpKRD5LJWj2Bg7jAQV7v09gjDXy8HLdSTZeGCuz9c0UGYuo 9UUuxGnEbKul1UekerIsRyniJbOJKKdd8DIzmeCotBA7ZMG6T18wT2PWYEdLkNgFNYX17uSyoa+ kGGPDabTZSqy2RZB8y3G55kMgZ7EpI2wBqDPF632THJm4s/ClFA3LUzKmteID1v8b9y7DI= X-Received: by 2002:a17:903:3bd0:b0:2b7:beb5:3002 with SMTP id d9443c01a7336-2ba7908142dmr230533385ad.12.1778442809329; Sun, 10 May 2026 12:53:29 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e358b2sm77065095ad.54.2026.05.10.12.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 12:53:28 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: andriy.shevchenko@intel.com, dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Date: Mon, 11 May 2026 01:19:32 +0530 Message-ID: <20260510194947.31997-11-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510194947.31997-1-piyushpatle228@gmail.com> References: <20260510194947.31997-1-piyushpatle228@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 9f17cbc6c2e5..860f8ef5a7cf 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -268,7 +268,23 @@ static int hx711_set_gain_for_channel(struct hx711_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