[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20221112163532.16a4dd12@jic23-huawei>
Date: Sat, 12 Nov 2022 16:35:32 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Deepak R Varma <drv@...lo.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
linux-iio@...r.kernel.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: iio: meter: use min() for comparison and
assignment
On Tue, 8 Nov 2022 21:06:24 +0530
Deepak R Varma <drv@...lo.com> wrote:
> On Tue, Nov 08, 2022 at 04:12:17PM +0100, Greg Kroah-Hartman wrote:
> > On Mon, Nov 07, 2022 at 09:40:00AM +0530, Deepak R Varma wrote:
> > > Simplify code by using recommended min helper macro for logical
> > > evaluation and value assignment. This issue is identified by
> > > coccicheck using the minmax.cocci file.
> > >
> > > Signed-off-by: Deepak R Varma <drv@...lo.com>
> > > ---
> > > drivers/staging/iio/meter/ade7854-i2c.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/staging/iio/meter/ade7854-i2c.c b/drivers/staging/iio/meter/ade7854-i2c.c
> > > index a9a06e8dda51..a6ce7b24cc8f 100644
> > > --- a/drivers/staging/iio/meter/ade7854-i2c.c
> > > +++ b/drivers/staging/iio/meter/ade7854-i2c.c
> > > @@ -61,7 +61,7 @@ static int ade7854_i2c_write_reg(struct device *dev,
> > > unlock:
> > > mutex_unlock(&st->buf_lock);
> > >
> > > - return ret < 0 ? ret : 0;
> > > + return min(ret, 0);
> >
> > As others have said, this isn't ok, and I hate ? : usage, so if you
> > want, spell that out please.
>
> Hello Greg,
> Just want to make sure I am getting it right:
> Are you suggesting me to resubmit the patch with revised patch description?
>
> Should I consider using the "if" based evaluation rather than using min() macro?
For IIO staging drivers, I'd take a cleanup that moved to
if (ret < 0)
return ret;
return 0;
As others have suggested though, not a good idea to do this broadly as it
would be a lot of noise. We don't mind noise so much for staging drivers :)
Jonathan
>
> Thank you,
> ./drv
>
> >
> > thanks,
> >
> > greg k-h
> >
>
>
Powered by blists - more mailing lists