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