mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arka Mondal <arka@arkamondal.net>
To: Jonathan Cameron <jic23@kernel.org>, Linus Walleij <linusw@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Peter Meerwald" <pmeerw@pmeerw.net>,
	"Matt Ranostay" <mranostay@gmail.com>,
	"Robert Eshleman" <bobbyeshleman@gmail.com>,
	"Leonard Crestez" <cdleonard@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Arka Mondal" <arka@arkamondal.net>
Subject: [PATCH 5/6] iio: humidity: hdc100x: Report the available lists via read_avail()
Date: Mon,  2 Nov 2026 16:46:59 +0900	[thread overview]
Message-ID: <20261102074700.63075-6-arka@arkamondal.net> (raw)
In-Reply-To: <20261102074700.63075-1-arka@arkamondal.net>

The temperature and humidity channels have IIO_CHAN_INFO_INT_TIME in
info_mask_separate, so userspace sees in_temp_integration_time and
in_humidityrelative_integration_time. Two custom attributes list
the values they accept, named temp_integration_time_available and
humidityrelative_integration_time_available. Neither carries the in_
prefix of the attribute it describes, so both sit at the device level,
and userspace that opens either prefixed name finds no such file. A
third attribute, out_current_heater_raw_available, already has the right
name and keeps it.

Report all three through read_avail() and delete the attributes and the
group that held them.

The two time lists hold what hdc100x_set_it_time() accepts. Its loop
ignores a zero request, so the padding entry in the temperature row of
hdc100x_int_time cannot be selected, which is why the temperature list
has two entries and the humidity list three.

No value changes. The heater list still prints 0 1, and the core prints
the times to the six decimals of IIO_VAL_INT_PLUS_MICRO: temperature
reads 0.003650 0.006350 where it read 0.00365 0.00635, humidity 0.002500
0.003850 0.006500 where it read 0.0025 0.00385 0.0065.

Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---

Notes:
    Compile tested only; no relevant hardware available.

 drivers/iio/humidity/hdc100x.c | 61 ++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index bc452cc8fbcf..e2780e436655 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -69,26 +69,19 @@ static const struct {
 	},
 };
 
-static IIO_CONST_ATTR(temp_integration_time_available,
-		"0.00365 0.00635");
-
-static IIO_CONST_ATTR(humidityrelative_integration_time_available,
-		"0.0025 0.00385 0.0065");
-
-static IIO_CONST_ATTR(out_current_heater_raw_available,
-		"0 1");
-
-static struct attribute *hdc100x_attributes[] = {
-	&iio_const_attr_temp_integration_time_available.dev_attr.attr,
-	&iio_const_attr_humidityrelative_integration_time_available.dev_attr.attr,
-	&iio_const_attr_out_current_heater_raw_available.dev_attr.attr,
-	NULL
+static const int hdc100x_temp_int_time_avail[] = {
+	0, 3650,
+	0, 6350,
 };
 
-static const struct attribute_group hdc100x_attribute_group = {
-	.attrs = hdc100x_attributes,
+static const int hdc100x_humidity_int_time_avail[] = {
+	0, 2500,
+	0, 3850,
+	0, 6500,
 };
 
+static const int hdc100x_heater_avail[] = { 0, 1 };
+
 static const struct iio_chan_spec hdc100x_channels[] = {
 	{
 		.type = IIO_TEMP,
@@ -97,6 +90,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
 			BIT(IIO_CHAN_INFO_SCALE) |
 			BIT(IIO_CHAN_INFO_INT_TIME) |
 			BIT(IIO_CHAN_INFO_OFFSET),
+		.info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
 		.scan_index = 0,
 		.scan_type = {
 			.sign = 's',
@@ -111,6 +105,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
 			BIT(IIO_CHAN_INFO_SCALE) |
 			BIT(IIO_CHAN_INFO_INT_TIME),
+		.info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
 		.scan_index = 1,
 		.scan_type = {
 			.sign = 'u',
@@ -122,6 +117,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
 	{
 		.type = IIO_CURRENT,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW),
 		.extend_name = "heater",
 		.output = 1,
 		.scan_index = -1,
@@ -328,10 +324,41 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	return IRQ_HANDLED;
 }
 
+static int hdc100x_read_avail(struct iio_dev *indio_dev,
+			      struct iio_chan_spec const *chan,
+			      const int **vals, int *type, int *length,
+			      long mask)
+{
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME:
+		switch (chan->type) {
+		case IIO_TEMP:
+			*vals = hdc100x_temp_int_time_avail;
+			*length = ARRAY_SIZE(hdc100x_temp_int_time_avail);
+			break;
+		case IIO_HUMIDITYRELATIVE:
+			*vals = hdc100x_humidity_int_time_avail;
+			*length = ARRAY_SIZE(hdc100x_humidity_int_time_avail);
+			break;
+		default:
+			return -EINVAL;
+		}
+		*type = IIO_VAL_INT_PLUS_MICRO;
+		return IIO_AVAIL_LIST;
+	case IIO_CHAN_INFO_RAW:
+		*vals = hdc100x_heater_avail;
+		*type = IIO_VAL_INT;
+		*length = ARRAY_SIZE(hdc100x_heater_avail);
+		return IIO_AVAIL_LIST;
+	default:
+		return -EINVAL;
+	}
+}
+
 static const struct iio_info hdc100x_info = {
 	.read_raw = hdc100x_read_raw,
 	.write_raw = hdc100x_write_raw,
-	.attrs = &hdc100x_attribute_group,
+	.read_avail = hdc100x_read_avail,
 };
 
 static int hdc100x_probe(struct i2c_client *client)
-- 
2.56.0


  parent reply	other threads:[~2026-11-02  7:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
2026-11-02  7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
2026-11-02 22:26   ` Jonathan Cameron
2026-11-02  7:46 ` [PATCH 2/6] iio: light: apds9960: Report the available lists " Arka Mondal
2026-11-02  7:46 ` [PATCH 3/6] iio: light: max44009: Report the integration time " Arka Mondal
2026-11-02  7:46 ` [PATCH 4/6] iio: light: max44000: Report the available lists " Arka Mondal
2026-11-02  7:46 ` Arka Mondal [this message]
2026-11-02  7:47 ` [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it " Arka Mondal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261102074700.63075-6-arka@arkamondal.net \
    --to=arka@arkamondal.net \
    --cc=andy@kernel.org \
    --cc=bobbyeshleman@gmail.com \
    --cc=cdleonard@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mranostay@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®