From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: References: <1501578742-4501-1-git-send-email-s.abhisit@gmail.com> <20170811143847.GA19152@localhost> <20170818025835.GE19152@localhost> From: Abhisit Sangjan Date: Fri, 18 Aug 2017 14:42:59 +0700 Message-ID: Subject: Re: [PATCH 2/5] iio: Add support for LMP92001 ADC To: jmondi Cc: Peter Meerwald-Stadler , jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, fabrice.gasnier@st.com, Lee Jones , robh@kernel.org, Akinobu Mita , marek.vasut+renesas@gmail.com, jacopo+renesas@jmondi.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Content-Type: multipart/alternative; boundary="001a114076ac32a4a8055702472e" List-ID: --001a114076ac32a4a8055702472e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jmondi, After I removed those cases, I got warnings "no handled in switch". On Fri, Aug 18, 2017 at 10:15 AM, Abhisit Sangjan wrote: > Hi Jmondi, > > On Fri, Aug 18, 2017 at 9:58 AM, jmondi wrote: > >> 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 n= ew >> > patch in soon. >> >> [snip] >> >> > > > > + >> > > > > + switch (mask) >> > > > > + { >> > > > > + case IIO_CHAN_INFO_RAW: >> > > > > + switch (channel->type) { >> > > > > + case IIO_VOLTAGE: >> > > > > + case IIO_TEMP: >> > > > > + *val =3D 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 t= he >> > Technical. >> >> This can potentially be reduced to >> >> switch (mask) { >> case IIO_CHAN_INFO_RAW: >> switch (channel->type) { >> case IIO_VOLTAGE: >> case IIO_TEMP: >> *val =3D 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 >> > > Abhisit: Thank you so much. > Abhisit: If I remove those default cases, I got the warning. How do I would do next to fix warning? Should I leave this code as it? # What have I changed. diff --git a/drivers/iio/adc/lmp92001-adc.c b/drivers/iio/adc/lmp92001-adc.= c index 68f7a6c..ebc6423 100644 --- a/drivers/iio/adc/lmp92001-adc.c +++ b/drivers/iio/adc/lmp92001-adc.c @@ -92,12 +92,7 @@ static int lmp92001_read_raw(struct iio_dev *indio_dev, case IIO_TEMP: *val =3D code; return IIO_VAL_INT; - default: - break; } - break; - default: - break; } return -EINVAL; # Compilation. CC drivers/iio/adc/lmp92001-adc.o drivers/iio/adc/lmp92001-adc.c: In function =E2=80=98lmp92001_read_raw=E2= =80=99: drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_CURRENT=E2=80=99 not handled in switch [-Wswitch] switch (channel->type) { ^ drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_POWER=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_ACCEL=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ANGL_VEL=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_MAGN=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_LIGHT=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_INTENSITY=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_PROXIMITY=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_INCLI=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_ROT=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_ANGL=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_TIMESTAMP=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_CAPACITANCE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ALTVOLTAGE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_CCT=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_PRESSURE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_HUMIDITYRELATIVE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ACTIVITY=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_STEPS=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ENERGY=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_DISTANCE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_VELOCITY=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_CONCENTRATION=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_RESISTANCE=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_PH=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_UVINDEX=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ELECTRICALCONDUCTIVITY=E2=80=99 not handled in switch [-Wswitc= h] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_COUNT=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98II= O_INDEX=E2=80=99 not handled in switch [-Wswitch] drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_GRAVITY=E2=80=99 not handled in switch [-Wswitch] > > > --001a114076ac32a4a8055702472e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jmondi,

After I removed those cases,= I got warnings "no handled in switch".

On Fri, Aug 18, 2017 at 10:15 AM, Abhis= it Sangjan <s.abhisit@gmail.com> wrote:
Hi Jmondi,

On Fri, Aug 18, 2017 at 9:58 AM, jmondi <jacopo@jmondi.org> wrote:
Hi Abhisit,<= br>
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 n= ew
> patch in soon.

[snip]

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

This can potentially be reduced to

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

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -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

Abhisit: Thank yo= u so much.

Abhisit:= If I remove those default cases, I got the warning. How do I would do next= to fix warning?=C2=A0 Should I leave this code as it?

=
# What have I changed.
d= iff --git a/drivers/iio/adc/lmp92001-adc.c b/drivers/iio/adc/lmp92001-adc.c=
index 68f7a6c..ebc6423 100644
--- a/drivers/iio/adc/lm= p92001-adc.c
+++ b/drivers/iio/adc/lmp92001-adc.c
@@ -9= 2,12 +92,7 @@ static int lmp92001_read_raw(struct iio_dev *indio_dev,
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 case IIO_TEMP:=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 *val =3D code;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return IIO_VAL_INT;=
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 default:
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 }
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 b= reak;
- =C2=A0 =C2=A0 =C2=A0 default:
- =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 }
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EIN= VAL;

# Compilation.<= /font>
=C2=A0 CC =C2=A0 =C2=A0 =C2=A0drivers/iio/adc/lmp9200= 1-adc.o
drivers/iio/adc/lmp92001-adc.c: In function =E2=80=98lmp9= 2001_read_raw=E2=80=99:
drivers/iio/adc/lmp92001-adc.c:90:3: warn= ing: enumeration value =E2=80=98IIO_CURRENT=E2=80=99 not handled in switch = [-Wswitch]
=C2=A0 =C2=A0switch (channel->type) {
=C2= =A0 =C2=A0^
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumera= tion value =E2=80=98IIO_POWER=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2= =80=98IIO_ACCEL=E2=80=99 not handled in switch [-Wswitch]
drivers= /iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ANGL_= VEL=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp= 92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_MAGN=E2=80=99 not= handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3= : warning: enumeration value =E2=80=98IIO_LIGHT=E2=80=99 not handled in swi= tch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enum= eration value =E2=80=98IIO_INTENSITY=E2=80=99 not handled in switch [-Wswit= ch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration val= ue =E2=80=98IIO_PROXIMITY=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80= =98IIO_INCLI=E2=80=99 not handled in switch [-Wswitch]
drivers/ii= o/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_ROT=E2= =80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-= adc.c:90:3: warning: enumeration value =E2=80=98IIO_ANGL=E2=80=99 not handl= ed in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warn= ing: enumeration value =E2=80=98IIO_TIMESTAMP=E2=80=99 not handled in switc= h [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumer= ation value =E2=80=98IIO_CAPACITANCE=E2=80=99 not handled in switch [-Wswit= ch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration val= ue =E2=80=98IIO_ALTVOLTAGE=E2=80=99 not handled in switch [-Wswitch]
<= div>drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80= =98IIO_CCT=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/= adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_PRESSURE= =E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp920= 01-adc.c:90:3: warning: enumeration value =E2=80=98IIO_HUMIDITYRELATIVE=E2= =80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-= adc.c:90:3: warning: enumeration value =E2=80=98IIO_ACTIVITY=E2=80=99 not h= andled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: = warning: enumeration value =E2=80=98IIO_STEPS=E2=80=99 not handled in switc= h [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumer= ation value =E2=80=98IIO_ENERGY=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value = =E2=80=98IIO_DISTANCE=E2=80=99 not handled in switch [-Wswitch]
d= rivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO= _VELOCITY=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/a= dc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_CONCENTRATI= ON=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp9= 2001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_RESISTANCE=E2=80= =99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc= .c:90:3: warning: enumeration value =E2=80=98IIO_PH=E2=80=99 not handled in= switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: = enumeration value =E2=80=98IIO_UVINDEX=E2=80=99 not handled in switch [-Wsw= itch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration v= alue =E2=80=98IIO_ELECTRICALCONDUCTIVITY=E2=80=99 not handled in switch [-W= switch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration= value =E2=80=98IIO_COUNT=E2=80=99 not handled in switch [-Wswitch]
drivers/iio/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80= =98IIO_INDEX=E2=80=99 not handled in switch [-Wswitch]
drivers/ii= o/adc/lmp92001-adc.c:90:3: warning: enumeration value =E2=80=98IIO_GRAVITY= =E2=80=99 not handled in switch [-Wswitch]
=C2=A0
=C2=A0


--001a114076ac32a4a8055702472e--