Re: [PATCH 2/5] iio: Add support for LMP92001 ADC

From: jmondi
Date: Thu Aug 17 2017 - 22:59:10 EST


Hi Abhisit,

On Fri, Aug 18, 2017 at 09:34:16AM +0700, Abhisit Sangjan wrote:
> Hi Jmondi,
>
> Thank you for your recommend, I am testing the code will be send the new
> patch in soon.

[snip]

> > > > +
> > > > + switch (mask)
> > > > + {
> > > > + case IIO_CHAN_INFO_RAW:
> > > > + switch (channel->type) {
> > > > + case IIO_VOLTAGE:
> > > > + case IIO_TEMP:
> > > > + *val = code;
> > > > + return IIO_VAL_INT;
> > > > + default:
> > > > + break;
> > > > + }
> > > > + break;
> > > > + default:
> > > > + break;
> >
> > You can remove these default cases or return -EINVAL here.
> >
>
> Abhisit: Okay, I will remove it.
> Could you tell me in detail. Sorry, I do not understand the
> Technical.

This can potentially be reduced to

switch (mask) {
case IIO_CHAN_INFO_RAW:
switch (channel->type) {
case IIO_VOLTAGE:
case IIO_TEMP:
*val = code;
return IIO_VAL_INT;
}
}

return -EINVAL;


But that's definitely not a big deal, there are no optimization in
this code change, just less typing and less default: and break; here
and there