Re: [PATCH v2 4/5] iio: light: ROHM BU27008 color sensor

Andi Shyti
2023-04-26T12:20:25Z

Hi Matti,

> > > > > +static int bu27008_chip_init(struct bu27008_data *data)
> > > > > +{
> > > > > + int ret;
> > > > > +
> > > > > + ret = regmap_update_bits(data->regmap, BU27008_REG_SYSTEM_CONTROL,
> > > > > + BU27008_MASK_SW_RESET, BU27008_MASK_SW_RESET);
> > > > > + if (ret)
> > > > > + return dev_err_probe(data->dev, ret, "Sensor reset failed\n");
> > > > > +
> > > > > + /*
> > > > > + * The data-sheet does not tell how long performing the IC reset takes.
> > > > > + * However, the data-sheet says the minimum time it takes the IC to be
> > > > > + * able to take inputs after power is applied, is 100 uS. I'd assume
> > > > > + * > 1 mS is enough.
> > > > > + */
> > > > > + msleep(1);
> > > >
> > > > please use usleep_range().
> > >
> > > I prefer to not require setting up hrtimers as we have no real requirements
> > > for the duration of this sleep. I know the msleep() is likely to exceed the
> > > 1 mS, potentially a lot if there is things to do - but we don't really care
> > > at this point. The main thing is to give the HW time to reset while allowing
> > > other things to be scheduled.
> >
> > For the reason above, msleep(1) is quite a meaningless
> > instruction. If you need to wait around 1ms, then usleep_range is
> > the function to be used.
> >
> > Refer, also, to the Documentation/timers/timers-howto.rst
>
> I know the msleep() may sleep much longer. It still is not meaningless. Here
> we use the msleep() in a purpose:
>
> "Sleep at least 1 mS, but actually I don't care if that is 20 mS or more -
> as long as you allow scheduling other things with as little overhead as
> possible".
>
> For that purpose msleep() works just perfectly :)
>
> I actually had a comment clarifying this in previous IIO driver I wrote
> (just to avoid confusing reviewers) but Jonathan asked me to remove the
> comment ;)

OK... ok... you convinced me :)

Thanks, will check soon your v3.
Andi