diff mbox series

[v5,1/2] dt-bindings: iio: light: isl76682: Document ISL76682

Message ID 20231125222738.97875-1-marex@denx.de
State Not Applicable
Headers show
Series [v5,1/2] dt-bindings: iio: light: isl76682: Document ISL76682 | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied success
robh/dtbs-check warning build log
robh/dt-meta-schema success

Commit Message

Marek Vasut Nov. 25, 2023, 10:26 p.m. UTC
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. Document it as trivial device.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: Andre Werner <andre.werner@systec-electronic.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Naresh Solanki <naresh.solanki@9elements.com>
Cc: Patrick Rudolph <patrick.rudolph@9elements.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>
Cc: Vincent Tremblay <vincent@vtremblay.dev>
Cc: devicetree@vger.kernel.org
Cc: linux-iio@vger.kernel.org
---
V2: Add AB from Conor
V3: No change
V4: No change
V5: No change
---
 Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jonathan Cameron Nov. 26, 2023, 6:16 p.m. UTC | #1
On Sat, 25 Nov 2023 23:26:23 +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,

One last question + a comment in general. Act on that if you like.

Thanks,

Jonathan


> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };

Why have an available attribute for a single value. Is it useful for anything?


> +static int isl76682_probe(struct i2c_client *client)
> +{

...

> +	indio_dev->info = &isl76682_info;
> +	indio_dev->channels = isl76682_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(isl76682_channels);
> +	indio_dev->name = ISL76682_DRIVER_NAME;
Trivial but I'm not a fan of using defines in cases like this. It just makes
me go find the define when I could see the string directly here.

In cases where matching or similar strictly requires the naming to be the same
in various places a define is useful. In this case less so.

Anyhow, it's a very minor comment so never mind if you prefer to leave it
as it stands.

> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	return devm_iio_device_register(dev, indio_dev);
> +}
Marek Vasut Nov. 26, 2023, 10:09 p.m. UTC | #2
On 11/26/23 19:16, Jonathan Cameron wrote:
> On Sat, 25 Nov 2023 23:26:23 +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,
> 
> One last question + a comment in general. Act on that if you like.
> 
> Thanks,
> 
> Jonathan
> 
> 
>> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };
> 
> Why have an available attribute for a single value. Is it useful for anything?

To report it to userspace, iio-sensor-proxy uses that to control the ALS 
poll interval .

>> +static int isl76682_probe(struct i2c_client *client)
>> +{
> 
> ...
> 
>> +	indio_dev->info = &isl76682_info;
>> +	indio_dev->channels = isl76682_channels;
>> +	indio_dev->num_channels = ARRAY_SIZE(isl76682_channels);
>> +	indio_dev->name = ISL76682_DRIVER_NAME;
> Trivial but I'm not a fan of using defines in cases like this. It just makes
> me go find the define when I could see the string directly here.
> 
> In cases where matching or similar strictly requires the naming to be the same
> in various places a define is useful. In this case less so.
> 
> Anyhow, it's a very minor comment so never mind if you prefer to leave it
> as it stands.

I added it to V6 .

I'll wait for the integration time reply above and then send V6 .
Marek Vasut Nov. 26, 2023, 10:17 p.m. UTC | #3
On 11/26/23 20:33, Dr.-Ing. Andre Werner wrote:

[...]

> +static int isl76682_write_raw(struct iio_dev *indio_dev,
> +			      struct iio_chan_spec const *chan,
> +			      int val, int val2, long mask)
> +{
> +	struct isl76682_chip *chip = iio_priv(indio_dev);
> +	int i;
> +
> +	if (chan->type != IIO_LIGHT && chan->type != IIO_INTENSITY)
> +		return -EINVAL;
> 
> In my understanding, this is not necessary as you use that 'iio_chan_spec' to specify
> the channels available at all. So there will be no other channel types created by the IIO environment, I think.

That's a good point, I think we can drop it in this case and the next one.

Jonathan , is there any reason you can think of why this shouldn't be 
dropped ?

I'll add it into V6, thanks.
Andy Shevchenko Nov. 27, 2023, 4:11 p.m. UTC | #4
On Sun, Nov 26, 2023 at 08:33:26PM +0100, Dr.-Ing. Andre Werner wrote:
> Dear Marek,
> 
> see remarks below.

Do not top-post!
Do not overquote hundreds of lines just for a single comment!
Andy Shevchenko Nov. 27, 2023, 4:13 p.m. UTC | #5
On Sat, Nov 25, 2023 at 11:26:23PM +0100, Marek Vasut 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.

...

> +	for (i = 0; i < ARRAY_SIZE(isl76682_range_table); i++) {
> +		if (chan->type == IIO_LIGHT && val2 != isl76682_range_table[i].als)
> +				continue;
> +		if (chan->type == IIO_INTENSITY && val2 != isl76682_range_table[i].ir)
> +				continue;

You forgot to drop indentation level for 'continue' lines.

> +		scoped_guard(mutex, &chip->lock)
> +			chip->range = isl76682_range_table[i].range;
> +		return 0;
> +	}
Marek Vasut Nov. 27, 2023, 8:52 p.m. UTC | #6
On 11/27/23 17:13, Andy Shevchenko wrote:
> On Sat, Nov 25, 2023 at 11:26:23PM +0100, Marek Vasut 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.
> 
> ...
> 
>> +	for (i = 0; i < ARRAY_SIZE(isl76682_range_table); i++) {
>> +		if (chan->type == IIO_LIGHT && val2 != isl76682_range_table[i].als)
>> +				continue;
>> +		if (chan->type == IIO_INTENSITY && val2 != isl76682_range_table[i].ir)
>> +				continue;
> 
> You forgot to drop indentation level for 'continue' lines.

I noticed that too and already fixed it in v6 .
Jonathan Cameron Dec. 1, 2023, 6:17 p.m. UTC | #7
On Sun, 26 Nov 2023 23:09:36 +0100
Marek Vasut <marex@denx.de> wrote:

> On 11/26/23 19:16, Jonathan Cameron wrote:
> > On Sat, 25 Nov 2023 23:26:23 +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,
> > 
> > One last question + a comment in general. Act on that if you like.
> > 
> > Thanks,
> > 
> > Jonathan
> > 
> >   
> >> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };  
> > 
> > Why have an available attribute for a single value. Is it useful for anything?  
> 
> To report it to userspace, iio-sensor-proxy uses that to control the ALS 
> poll interval .

It should use integration_time, not the associated available attribute.

> 
> >> +static int isl76682_probe(struct i2c_client *client)
> >> +{  
> > 
> > ...
> >   
> >> +	indio_dev->info = &isl76682_info;
> >> +	indio_dev->channels = isl76682_channels;
> >> +	indio_dev->num_channels = ARRAY_SIZE(isl76682_channels);
> >> +	indio_dev->name = ISL76682_DRIVER_NAME;  
> > Trivial but I'm not a fan of using defines in cases like this. It just makes
> > me go find the define when I could see the string directly here.
> > 
> > In cases where matching or similar strictly requires the naming to be the same
> > in various places a define is useful. In this case less so.
> > 
> > Anyhow, it's a very minor comment so never mind if you prefer to leave it
> > as it stands.  
> 
> I added it to V6 .
> 
> I'll wait for the integration time reply above and then send V6 .
>
Jonathan Cameron Dec. 1, 2023, 6:20 p.m. UTC | #8
On Sun, 26 Nov 2023 23:17:55 +0100
Marek Vasut <marex@denx.de> wrote:

> On 11/26/23 20:33, Dr.-Ing. Andre Werner wrote:
> 
> [...]
> 
> > +static int isl76682_write_raw(struct iio_dev *indio_dev,
> > +			      struct iio_chan_spec const *chan,
> > +			      int val, int val2, long mask)
> > +{
> > +	struct isl76682_chip *chip = iio_priv(indio_dev);
> > +	int i;
> > +
> > +	if (chan->type != IIO_LIGHT && chan->type != IIO_INTENSITY)
> > +		return -EINVAL;
> > 
> > In my understanding, this is not necessary as you use that 'iio_chan_spec' to specify
> > the channels available at all. So there will be no other channel types created by the IIO environment, I think.  
> 
> That's a good point, I think we can drop it in this case and the next one.
> 
> Jonathan , is there any reason you can think of why this shouldn't be 
> dropped ?

I don't mind a little paranoia, but fine with dropping it as well.

The reason paranoia is fine is that if other channels are added in future
we might not remember to fix this up if they happen to have no writeable attributes.
I leave that assessment up to driver authors.

Jonathan

> 
> I'll add it into V6, thanks.
>
Marek Vasut Dec. 2, 2023, 6:46 a.m. UTC | #9
On 12/1/23 19:20, Jonathan Cameron wrote:
> On Sun, 26 Nov 2023 23:17:55 +0100
> Marek Vasut <marex@denx.de> wrote:
> 
>> On 11/26/23 20:33, Dr.-Ing. Andre Werner wrote:
>>
>> [...]
>>
>>> +static int isl76682_write_raw(struct iio_dev *indio_dev,
>>> +			      struct iio_chan_spec const *chan,
>>> +			      int val, int val2, long mask)
>>> +{
>>> +	struct isl76682_chip *chip = iio_priv(indio_dev);
>>> +	int i;
>>> +
>>> +	if (chan->type != IIO_LIGHT && chan->type != IIO_INTENSITY)
>>> +		return -EINVAL;
>>>
>>> In my understanding, this is not necessary as you use that 'iio_chan_spec' to specify
>>> the channels available at all. So there will be no other channel types created by the IIO environment, I think.
>>
>> That's a good point, I think we can drop it in this case and the next one.
>>
>> Jonathan , is there any reason you can think of why this shouldn't be
>> dropped ?
> 
> I don't mind a little paranoia, but fine with dropping it as well.
> 
> The reason paranoia is fine is that if other channels are added in future
> we might not remember to fix this up if they happen to have no writeable attributes.
> I leave that assessment up to driver authors.

So, dropped, since this chip seems to be very much legacy hardware.
Marek Vasut Dec. 2, 2023, 6:48 a.m. UTC | #10
On 12/1/23 19:17, Jonathan Cameron wrote:
> On Sun, 26 Nov 2023 23:09:36 +0100
> Marek Vasut <marex@denx.de> wrote:
> 
>> On 11/26/23 19:16, Jonathan Cameron wrote:
>>> On Sat, 25 Nov 2023 23:26:23 +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,
>>>
>>> One last question + a comment in general. Act on that if you like.
>>>
>>> Thanks,
>>>
>>> Jonathan
>>>
>>>    
>>>> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };
>>>
>>> Why have an available attribute for a single value. Is it useful for anything?
>>
>> To report it to userspace, iio-sensor-proxy uses that to control the ALS
>> poll interval .
> 
> It should use integration_time, not the associated available attribute.

So, what should I do with this feedback ?

I did send the V6 already, so shall I change anything in V7 ?
Jonathan Cameron Dec. 4, 2023, 11:13 a.m. UTC | #11
On Sat, 2 Dec 2023 07:48:12 +0100
Marek Vasut <marex@denx.de> wrote:

> On 12/1/23 19:17, Jonathan Cameron wrote:
> > On Sun, 26 Nov 2023 23:09:36 +0100
> > Marek Vasut <marex@denx.de> wrote:
> >   
> >> On 11/26/23 19:16, Jonathan Cameron wrote:  
> >>> On Sat, 25 Nov 2023 23:26:23 +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,
> >>>
> >>> One last question + a comment in general. Act on that if you like.
> >>>
> >>> Thanks,
> >>>
> >>> Jonathan
> >>>
> >>>      
> >>>> +static int integration_time_available[] = { 0, ISL76682_INT_TIME_US };  
> >>>
> >>> Why have an available attribute for a single value. Is it useful for anything?  
> >>
> >> To report it to userspace, iio-sensor-proxy uses that to control the ALS
> >> poll interval .  
> > 
> > It should use integration_time, not the associated available attribute.  
> 
> So, what should I do with this feedback ?
> 
> I did send the V6 already, so shall I change anything in V7 ?

I'll reply there.  Just noticed some other oddities around available.
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index 441b55723675a..d7ffecc0e9bf5 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -181,6 +181,8 @@  properties:
           - isil,isl29030
             # Intersil ISL68137 Digital Output Configurable PWM Controller
           - isil,isl68137
+            # Intersil ISL76682 Ambient Light Sensor
+          - isil,isl76682
             # Linear Technology LTC2488
           - lineartechnology,ltc2488
             # 5 Bit Programmable, Pulse-Width Modulator