Re: [PATCH v3 2/2] iio: light: driver for Lite-On ltr390

From: Jonathan Cameron
Date: Sun Dec 10 2023 - 08:39:15 EST


On Fri, 8 Dec 2023 15:52:10 +0530
Anshul Dalal <anshulusr@xxxxxxxxx> wrote:

> Implements driver for the Ambient/UV Light sensor LTR390.
> The driver exposes two ways of getting sensor readings:
> 1. Raw UV Counts directly from the sensor
> 2. The computed UV Index value with a percision of 2 decimal places
>
> [NOTE] Ambient light sensing has not been implemented yet.
>
> Driver tested on RPi Zero 2W
>
> Datasheet: https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf
> Signed-off-by: Anshul Dalal <anshulusr@xxxxxxxxx>

I fixed up the case where you use dev_err_probe() in a path called from
places other than the probe() callback.

Applied to the togreg branch of iio.git and initially pushed out as testing for 0-day
to take a look and see if it can find things we missed

Thanks,

Jonathan


> +
> +static int ltr390_register_read(struct ltr390_data *data, u8 register_address)
> +{
> + struct device *dev = &data->client->dev;
> + int ret;
> + u8 recieve_buffer[3];
> +
> + guard(mutex)(&data->lock);
> +
> + ret = regmap_bulk_read(data->regmap, register_address, recieve_buffer,
> + sizeof(recieve_buffer));
> + if (ret)
> + return dev_err_probe(dev, ret,
dev_err_probe() is only intended for use in probe() and functions that are
only called from probe()
> + "failed to read measurement data");
> +
> + return get_unaligned_le24(recieve_buffer);
> +}