From: Marek Vasut <marex@denx.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Matti Vaittinen <mazziesaccount@gmail.com>,
Alexander Stein <alexander.stein@ew.tq-group.com>,
Andre Werner <andre.werner@systec-electronic.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Conor Dooley <conor+dt@kernel.org>,
Fabio Estevam <festevam@denx.de>,
Guenter Roeck <linux@roeck-us.net>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Mark Brown <broonie@kernel.org>,
Naresh Solanki <naresh.solanki@9elements.com>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Rob Herring <robh+dt@kernel.org>,
Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>,
Vincent Tremblay <vincent@vtremblay.dev>,
devicetree@vger.kernel.org
Subject: Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Date: Tue, 5 Dec 2023 02:26:36 +0100 [thread overview]
Message-ID: <8df89527-cd9e-4a70-8681-2b347f7c9d84@denx.de> (raw)
In-Reply-To: <20231204112001.7dff7066@jic23-huawei>
On 12/4/23 12:20, Jonathan Cameron wrote:
> On Mon, 27 Nov 2023 22:26:53 +0100
> Marek Vasut <marex@denx.de> wrote:
>
>> The ISL76682 is very basic ALS which only supports ALS or IR mode
>> in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any
>> other fancy functionality.
>>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
>> Signed-off-by: Marek Vasut <marex@denx.de>
> Hi Marek,
>
> Discussion around available on v5 made me look closer at that aspect.
> You are providing all the available entries in the callback but they
> shouldn't be exposed to actually read unless the *_available bitmap
> bits corresponding to them are set.
>
> If you like I can just rip the unused code out whilst applying?
> Or if you'd prefer to send a v7 that's great too.
>
> Otherwise everything looks good to me.
>
> Jonathan
>
>> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };
>> +
>> +static int isl76682_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_SCALE:
>> + switch (chan->type) {
>> + case IIO_LIGHT:
>> + *vals = illuminance_scale_available;
>> + *length = ARRAY_SIZE(illuminance_scale_available);
>> + *type = IIO_VAL_INT_PLUS_MICRO;
>> + return IIO_AVAIL_LIST;
>> + case IIO_INTENSITY:
>> + *vals = intensity_scale_available;
>> + *length = ARRAY_SIZE(intensity_scale_available);
>> + *type = IIO_VAL_INT_PLUS_MICRO;
>> + return IIO_AVAIL_LIST;
>> + default:
>> + return -EINVAL;
>> + }
>> + case IIO_CHAN_INFO_INT_TIME:
>
> Never used. So can just drop this case which tidies up the question
> I h ad earlier on what the single entry array was conveying.
Seeing the diff, that now totally makes sense, thanks !
>> + *vals = integration_time_available;
>> + *length = ARRAY_SIZE(integration_time_available);
>> + *type = IIO_VAL_INT_PLUS_MICRO;
>> + return IIO_AVAIL_LIST;
>> + default:
>> + return -EINVAL;
>> + }
>> +}
>> +
>> +static const struct iio_chan_spec isl76682_channels[] = {
>> + {
>> + .type = IIO_LIGHT,
>> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>> + BIT(IIO_CHAN_INFO_SCALE),
>> + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),
>> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
>
> Without setting .info_mask_shared_by_all_available (unless we have a bug)
> you won't see the available attributes for INT_TIME.
>
>> + }, {
>> + .type = IIO_INTENSITY,
>> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>> + BIT(IIO_CHAN_INFO_SCALE),
>> + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),
>> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
>> + }
>> +};
>> +
>> +static const struct iio_info isl76682_info = {
>> + .read_avail = isl76682_read_avail,
>> + .read_raw = isl76682_read_raw,
>> + .write_raw = isl76682_write_raw,
>> +};
>
>
>> +static const struct i2c_device_id isl76682_id[] = {
>> + { "isl76682" },
>> + {}
>> +};
>> +MODULE_DEVICE_TABLE(i2c, isl76682_id);
>> +
>> +static const struct of_device_id isl76682_of_match[] = {
>> + { .compatible = "isil,isl76682" },
>> + { }
>
> Completely trivial but why { } here and {} in the similar
> case above? Pick one!
I sent a one-liner for this , it might make sense to squash it if possible .
next prev parent reply other threads:[~2023-12-05 1:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 21:26 [PATCH v6 1/2] dt-bindings: iio: light: isl76682: Document ISL76682 Marek Vasut
2023-11-27 21:26 ` [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver Marek Vasut
2023-12-04 11:20 ` Jonathan Cameron
2023-12-04 11:23 ` Marek Vasut
2023-12-04 14:35 ` Jonathan Cameron
2023-12-05 1:24 ` Marek Vasut
2023-12-06 17:20 ` Jonathan Cameron
2023-12-07 13:28 ` Marek Vasut
2023-12-05 1:26 ` Marek Vasut [this message]
2023-12-04 11:29 ` Jonathan Cameron
2023-12-05 1:43 ` Marek Vasut
2023-12-05 15:54 ` Andy Shevchenko
2023-12-05 21:02 ` Marek Vasut
2023-12-05 21:57 ` Andy Shevchenko
2023-12-05 23:11 ` Marek Vasut
2023-12-06 17:23 ` 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=8df89527-cd9e-4a70-8681-2b347f7c9d84@denx.de \
--to=marex@denx.de \
--cc=alexander.stein@ew.tq-group.com \
--cc=andre.werner@systec-electronic.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@denx.de \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luca.ceresoli@bootlin.com \
--cc=mazziesaccount@gmail.com \
--cc=naresh.solanki@9elements.com \
--cc=patrick.rudolph@9elements.com \
--cc=robh+dt@kernel.org \
--cc=stefan.windfeldt-prytz@axis.com \
--cc=vincent@vtremblay.dev \
/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;
as well as URLs for NNTP newsgroup(s).