Re: [PATCH v5 3/3] drivers: iio: adc: add support for ad777x family
From: Jonathan Cameron
Date: Sat Sep 14 2024 - 12:47:10 EST
> ...
>
> > + 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