Re: [PATCH v5 3/3] iio: light: Add support for APDS9306 Light Sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/2/24 00:10, Jonathan Cameron wrote:
On Sun, 4 Feb 2024 21:53:55 +1030
Subhajit Ghosh <subhajit.ghosh@xxxxxxxxxxxxxx> wrote:

Hi Jonathan,
+
+static struct iio_event_spec apds9306_event_spec_als[] = {
+    {
+        .type = IIO_EV_TYPE_THRESH,
+        .dir = IIO_EV_DIR_RISING,
+        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE),
+    }, {
+        .type = IIO_EV_TYPE_THRESH,
+        .dir = IIO_EV_DIR_FALLING,
+        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE),
+    }, {
+        .type = IIO_EV_TYPE_THRESH,
+        .mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD),
+    }, {
+        .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
+        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE) |
+            BIT(IIO_EV_INFO_ENABLE),
+    }, {
+        .mask_separate = BIT(IIO_EV_INFO_ENABLE),

What's the intent of this final entry?
The type will default to IIO_EV_TYPE_THRESH anyway but if that
the intent you should specify it.   There isn't an 'obvious'
default for type in the same way there sort of is for dir
(as it's either direction).
Understood, let me experiment and see the ABI difference, if any and get back to you.
This device has two channels - ALS and CLEAR. One interrupt enable option and
one Channel selection option (Clear or ALS). According to our previous discussions:
https://lore.kernel.org/all/20230415183543.6d5e3392@jic23-huawei/
the event_spec was updated to have two interrupt enable attributes - one for CLEAR and
one for ALS. (Intensity channel and Illuminance channel)

...

Please let me know if this sounds ok to you.
Looks like coincidence of enum values being 0.
It's really
{
	.type = IIO_EV_TYPE_THRESH, /* Value 0 */
	.dir = IIO_EV_DIR_EITHER, /* value 0 */
	.mask_separate = BIT(IIO_EV_INFO_ENABLE),

Dropping 'defaults' for these things is fine if they are the obvious default
or other parameters mean they aren't used, but that isn't the case here so
please be explicit for all the values that are used.

You can put this final mask a few lines earlier as the other fields match
anyway.
	{
         	.type = IIO_EV_TYPE_THRESH,
		.dir = IIO_EV_DIR_EITHER,
         	.mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD),
		.mask_separate = BIT(IIO_EV_INFO_ENABLE),
	},..

Thank you Jonathan. The above works as intended.

Regards,
Subhajit Ghosh





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux