Re: [PATCH] iio: light: gp2ap020a00f: Correct return type to int

From: Andy Shevchenko

Date: Wed Feb 11 2026 - 03:44:37 EST


On Tue, Feb 10, 2026 at 06:48:19PM -0600, Ethan Tidmore wrote:
> The function gp2ap020a00f_get_thresh_reg() can return type -EINVAL in
> its error path. Yet, the function has return type of u8. Added error
> checking for gp2ap020a00f_get_thresh_reg() return's value.

...

> -static u8 gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan,
> +static int gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan,
> enum iio_event_direction event_dir)

While at it, correct the indentation of the second line.

...

> mutex_lock(&data->lock);
>
> thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir);

> +

Drop this blank line.

> + if (thresh_reg_l < 0) {
> + err = thresh_reg_l;
> + goto error_unlock;
> + }

> thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir);

>

Ditto, no blank line between an assignment and a conditional that checks
the value.

> + if (thresh_reg_l < 0) {
> + err = thresh_reg_l;
> + goto error_unlock;
> + }

--
With Best Regards,
Andy Shevchenko