Re: [PATCH 2/3] iio: light: opt4001: refactor driver to prepare to support more devices

From: Jesper X Nilsson

Date: Fri Oct 23 2026 - 06:12:50 EST


On 10/23/26 11:07, Andy Shevchenko wrote:
[Some people who received this message don't often get email from andriy.shevchenko@xxxxxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On Fri, Oct 23, 2026 at 09:48:14AM +0200, Jesper X Nilsson wrote:
Prepare opt4001 driver to be able to support OPT4041. Extend struct
opt4001_chip_info with fields channels and device_id because OPT4041 has
two channels and another device id.

...

Assisted-by: LLM

Drop this tag.

I will drop the tag in v2.> ...

+static const struct iio_chan_spec opt4001_channels[] = {
+ {
+ .type = IIO_LIGHT,
+ .address = OPT4001_LIGHT1_MSB,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME)

While at it (and I see it was in the original code), add a trailing comma here.

I will add trailing comma in v2.

+ },
+};

...

u8 count;
u8 crc;
u8 calc_crc;
- u64 lux_raw;
- u32 rem;
+ u32 mantissa;

Try to put it to make more of reversed xmas tree order.

I will fix it in v2.

int ret;

...

+ chip->chip_info = i2c_get_match_data(client);

For now it requires

if (!chip->chip_info)
return -ENODATA;

I will add the if check in v2.

--
With Best Regards,
Andy Shevchenko

Thanks for the fast review!

Best regards,
Jesper