[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230113141640.00006fb1@Huawei.com>
Date: Fri, 13 Jan 2023 14:16:40 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Hugo Villeneuve <hugo@...ovil.com>
CC: Jonathan Cameron <jic23@...nel.org>, <hvilleneuve@...onoff.com>,
<lars@...afoo.de>, <robh+dt@...nel.org>,
<krzysztof.kozlowski+dt@...aro.org>, <linux-iio@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] iio: adc: ti-ads7924: add Texas Instruments
ADS7924 driver
> > > + break;
> > > + }
> > > + case IIO_CHAN_INFO_SCALE:
> > > + vref_uv = regulator_get_voltage(data->vref_reg);
> > > + if (vref_uv < 0) {
> > > + /* dummy regulator "get_voltage" returns -EINVAL */
> > > + ret = -EINVAL;
> > return -EINVAL;
> > > + } else {
> > > + *val = vref_uv / 1000; /* Convert reg voltage to mV */
> > > + *val2 = ADS7924_BITS;
> > > + ret = IIO_VAL_FRACTIONAL_LOG2;
> > return IIO_VAL_FR...
> >
> > > + }
> > > + break;
> > > + default:
> > > + ret = -EINVAL;
> > return -EINVAL;
> > > + break;
> > > + }
> > > +
> > > + return ret;
> > > +}
>
> Done. With these changes, I propose to also remove last "return ret" (like in rcar-gyroadc.c). Then, maybe also remove break statements?
Definitely to both. I was just being lazy whilst commenting ;) No breaks after returns, and as you
have noted, the last return ret is unreachable.
> > > +
> > > + if (num_channels > 0) {
> > > + dev_dbg(dev, "found %d ADC channels\n", num_channels);
> > > + return 0;
> > > + } else {
> >
> > As per other review. Give us what we expect which is error paths
> > as out of line.
>
> Already done as suggested by Christophe:
>
> if (num_channels <= 0)
> return -EINVAL;
This is an out of line error path because it's indented more than the normal
flow.
>
> dev_dbg(dev, "found %d ADC channels\n", num_channels);
> return 0;
>
> Although I do not fully understand what you mean by "...error paths as out of line"? Do you mean to drop the debug message?
See above.
>
> >
> > > + return -EINVAL;
> > > + }
> > > +}
Powered by blists - more mailing lists