From: Jonathan Cameron <jic23@kernel.org>
To: Arka Mondal <arka@arkamondal.net>
Cc: "Linus Walleij" <linusw@kernel.org>,
"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
Subject: Re: [PATCH 3/6] iio: light: max44009: Report the integration time via read_avail()
Date: Sun, 8 Nov 2026 01:08:42 +0000 [thread overview]
Message-ID: <20261108010842.13470b16@jic23-hlaptop> (raw)
In-Reply-To: <20261102074700.63075-4-arka@arkamondal.net>
On Mon, 2 Nov 2026 16:46:57 +0900
Arka Mondal <arka@arkamondal.net> wrote:
> The light channel has IIO_CHAN_INFO_INT_TIME in info_mask_separate,
> so userspace reads the integration time from
> in_illuminance_integration_time. The values it accepts are listed by
> a custom attribute called illuminance_integration_time_available.
> That name lacks the in_ prefix the core puts on the attribute it
> describes, so it is registered at the device level, and userspace
> looking for in_illuminance_integration_time_available finds nothing.
>
> Report the list through read_avail() and drop the custom attribute
> along with the string it printed. read_avail() wants the values as
> IIO_VAL_INT_PLUS_NANO pairs, while max44009_write_int_time() rounds a
> request to the nearest supported value with find_closest_descending()
> over a flat table, so the two forms stay as separate tables.
>
> The eight values do not change. The core prints them with nine
> decimals, so the attribute now reads 0.800000000 down to 0.006250000
> instead of 0.8 down to 0.00625.
>
> Fixes: 6aef699a7d7e ("iio: light: add driver for MAX44009")
> Signed-off-by: Arka Mondal <arka@arkamondal.net>
> ---
>
> Notes:
> Compile tested only; no relevant hardware available.
>
> drivers/iio/light/max44009.c | 48 ++++++++++++++++++++----------------
> 1 file changed, 27 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/iio/light/max44009.c b/drivers/iio/light/max44009.c
> index 82b8a806c5fa..c27f0f9ecc44 100644
> --- a/drivers/iio/light/max44009.c
> +++ b/drivers/iio/light/max44009.c
> @@ -66,15 +66,16 @@ static const u32 max44009_int_time_ns_array[] = {
> 6250000, /* Manual mode only */
> };
>
> -static const char max44009_int_time_str[] =
> - "0.8 "
> - "0.4 "
> - "0.2 "
> - "0.1 "
> - "0.05 "
> - "0.025 "
> - "0.0125 "
> - "0.00625";
> +static const int max44009_int_time_avail[] = {
> + 0, 800000000,
> + 0, 400000000,
> + 0, 200000000,
> + 0, 100000000,
> + 0, 50000000,
> + 0, 25000000,
> + 0, 12500000,
> + 0, 6250000,
Lot of zeros...
> +};
>
> struct max44009_data {
> struct i2c_client *client;
> @@ -101,6 +102,7 @@ static const struct iio_chan_spec max44009_channels[] = {
> .type = IIO_LIGHT,
> .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> BIT(IIO_CHAN_INFO_INT_TIME),
> + .info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
> .event_spec = max44009_event_spec,
> .num_event_specs = ARRAY_SIZE(max44009_event_spec),
> },
> @@ -284,17 +286,21 @@ static int max44009_read_raw(struct iio_dev *indio_dev,
> }
> }
>
> -static IIO_CONST_ATTR(illuminance_integration_time_available,
> - max44009_int_time_str);
> -
> -static struct attribute *max44009_attributes[] = {
> - &iio_const_attr_illuminance_integration_time_available.dev_attr.attr,
> - NULL,
> -};
> -
> -static const struct attribute_group max44009_attribute_group = {
> - .attrs = max44009_attributes,
> -};
> +static int max44009_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:
> + *vals = max44009_int_time_avail;
> + *type = IIO_VAL_INT_PLUS_NANO;
And the reason for the extra zeros is this. Why not use PLUS_MICRO
and drop 3 of them.
> + *length = ARRAY_SIZE(max44009_int_time_avail);
> + return IIO_AVAIL_LIST;
> + default:
> + return -EINVAL;
> + }
> +}
>
> static int max44009_threshold_byte_from_fraction(int integral, int fractional)
> {
> @@ -464,7 +470,7 @@ static const struct iio_info max44009_info = {
> .read_event_config = max44009_read_event_config,
> .write_event_value = max44009_write_event_value,
> .write_event_config = max44009_write_event_config,
> - .attrs = &max44009_attribute_group,
> + .read_avail = max44009_read_avail,
> };
>
> static irqreturn_t max44009_threaded_irq_handler(int irq, void *p)
next prev parent reply other threads:[~2026-11-08 1:08 UTC|newest]
Thread overview: 13+ 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-08 1:10 ` Jonathan Cameron
2026-11-02 7:46 ` [PATCH 3/6] iio: light: max44009: Report the integration time " Arka Mondal
2026-11-08 1:08 ` Jonathan Cameron [this message]
2026-11-02 7:46 ` [PATCH 4/6] iio: light: max44000: Report the available lists " Arka Mondal
2026-11-08 1:12 ` Jonathan Cameron
2026-11-02 7:46 ` [PATCH 5/6] iio: humidity: hdc100x: " Arka Mondal
2026-11-08 1:14 ` Jonathan Cameron
2026-11-02 7:47 ` [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it " Arka Mondal
2026-11-08 1:18 ` Jonathan Cameron
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=20261108010842.13470b16@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=arka@arkamondal.net \
--cc=bobbyeshleman@gmail.com \
--cc=cdleonard@gmail.com \
--cc=dlechner@baylibre.com \
--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®