Re: [PATCH 2/4] iio: proximity: vcnl3020: add threshold options

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

 



On Fri, Apr 30, 2021 at 6:16 PM Ivan Mikhaylov <i.mikhaylov@xxxxxxxxx> wrote:
>
> Add the low/high threshold options.

...

> +                       rc = regmap_bulk_read(data->regmap, VCNL_PS_HI_THR_HI,
> +                                             &res, 2);

sizeof(res)

> +                       *val = be16_to_cpu(res);

So, the rule of thumb is not putting anything to the output, until you
know that there is no error.

> +                       if (rc < 0)
> +                               return rc;

...

> +                       rc = regmap_bulk_read(data->regmap, VCNL_PS_LO_THR_HI,
> +                                             &res, 2);
> +                       *val = be16_to_cpu(res);
> +                       if (rc < 0)
> +                               return rc;

As per above.

...

> +                       rc = regmap_bulk_write(data->regmap, VCNL_PS_HI_THR_HI,
> +                                              &buf, 2);

sizeof(buf) ?

...

> +                       rc = regmap_bulk_write(data->regmap, VCNL_PS_LO_THR_HI,
> +                                              &buf, 2);

Ditto.

...

> +end:

out_release_direct_mode:

> +       iio_device_release_direct_mode(indio_dev);
> +       return rc;

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux