Re: [PATCH v5 3/3] drivers: iio: adc: add support for ad777x family

Jonathan Cameron
2024-09-14T16:47:03Z

> ...
>
> > + iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
> > + switch (mask) {
> > + case IIO_CHAN_INFO_CALIBSCALE:
> > + *val = ad7779_get_calibscale(st, chan->channel);
> > + if (*val < 0)
> > + return -EINVAL;
> > + *val2 = GAIN_REL;
> > + return IIO_VAL_FRACTIONAL;
> > + case IIO_CHAN_INFO_CALIBBIAS:
> > + *val = ad7779_get_calibbias(st, chan->channel);
> > + if (*val < 0)
> > + return -EINVAL;
> > + return IIO_VAL_INT;
> > + case IIO_CHAN_INFO_SAMP_FREQ:
> > + *val = st->sampling_freq;
> > + if (*val < 0)
> > + return -EINVAL;
> > + return IIO_VAL_INT;
> > + }
> > + return -EINVAL;
> > + }
>
> > + unreachable();
>
> Hmm... Is it necessary? Same Q for other similar cases. I.o.w. what
> will be if we don't add this line?

The compiler can't tell that the contents of iio_device_claim_direct_scoped()
always runs. Hence normal result is it complains that nothing was returned.

Why the compiler can't figure out? Who knows...

Jonathan