lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1220395cfe158e2116a1f2826ef6ce96074463b4.camel@analog.com>
Date:   Wed, 8 May 2019 07:50:07 +0000
From:   "Ardelean, Alexandru" <alexandru.Ardelean@...log.com>
To:     "melissa.srw@...il.com" <melissa.srw@...il.com>
CC:     "kernel-usp@...glegroups.com" <kernel-usp@...glegroups.com>,
        "lars@...afoo.de" <lars@...afoo.de>,
        "ardeleanalex@...il.com" <ardeleanalex@...il.com>,
        "knaack.h@....de" <knaack.h@....de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "jic23@...nel.org" <jic23@...nel.org>,
        "21cnbao@...il.com" <21cnbao@...il.com>,
        "Hennerich, Michael" <Michael.Hennerich@...log.com>,
        "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
        "pmeerw@...erw.net" <pmeerw@...erw.net>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "Popa, Stefan Serban" <StefanSerban.Popa@...log.com>
Subject: Re: [PATCH 2/4] staging: iio: ad7150: use FIELD_GET and GENMASK

On Tue, 2019-05-07 at 17:44 -0300, Melissa Wen wrote:
> [External]
> 
> 
> On 05/06, Ardelean, Alexandru wrote:
> > On Sat, 2019-05-04 at 13:43 +0300, Alexandru Ardelean wrote:
> > > [External]
> > > 
> > > 
> > > On Sat, May 4, 2019 at 1:25 AM Melissa Wen <melissa.srw@...il.com>
> > > wrote:
> > > > 
> > > > Use the bitfield macro FIELD_GET, and GENMASK to do the shift and
> > > > mask
> > > > in
> > > > one go. This makes the code more readable than explicit masking
> > > > followed
> > > > by a shift.
> > > > 
> > > 
> > > This looks neat.
> > > I'd have to remember to ack it from my work email.
> > 
> > Acked-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
> > 
> > > 
> > > One minor comment inline, which would be the object of a new patch.
> > > 
> > > > Signed-off-by: Melissa Wen <melissa.srw@...il.com>
> > > > ---
> > > >  drivers/staging/iio/cdc/ad7150.c | 6 +++++-
> > > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/staging/iio/cdc/ad7150.c
> > > > b/drivers/staging/iio/cdc/ad7150.c
> > > > index 24601ba7db88..4ba46fb6ac02 100644
> > > > --- a/drivers/staging/iio/cdc/ad7150.c
> > > > +++ b/drivers/staging/iio/cdc/ad7150.c
> > > > @@ -5,6 +5,7 @@
> > > >   * Copyright 2010-2011 Analog Devices Inc.
> > > >   */
> > > > 
> > > > +#include <linux/bitfield.h>
> > > >  #include <linux/interrupt.h>
> > > >  #include <linux/device.h>
> > > >  #include <linux/kernel.h>
> > > > @@ -44,6 +45,9 @@
> > > >  #define AD7150_SN0_REG                         0x16
> > > >  #define AD7150_ID_REG                          0x17
> > > > 
> > > > +/* AD7150 masks */
> > > > +#define AD7150_THRESHTYPE_MSK                  GENMASK(6, 5)
> > > > +
> > > >  /**
> > > >   * struct ad7150_chip_info - instance specific chip data
> > > >   * @client: i2c client for this device
> > > > @@ -136,7 +140,7 @@ static int ad7150_read_event_config(struct
> > > > iio_dev
> > > > *indio_dev,
> > > >         if (ret < 0)
> > > >                 return ret;
> > > > 
> > > > -       threshtype = (ret >> 5) & 0x03;
> > > > +       threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret);
> > > >         adaptive = !!(ret & 0x80);
> > > 
> > > Why not also do something similar for the `adaptive` value ?
> 
> Hi Alexandru,
> 
> Yes, I'm working on it!  However, taking a look at the driver datasheet
> (Table
> 13, page 19), there seems to be a little mistake in choosing the variable
> name
> and its meaning,  since when bit(7) is 1 (true) the threshold is fixed,
> and not
> adaptive. For this reason, I removed it from this patchset to mature the
> solution. I will send it as a bug fix if I prove it's necessary.
> Do you have any advice or feeling about it to share?
> 

Good find.
Since this is a bug-fix, typically it's good to fix the code as-is now
[even if it isn't neat code], and then do the conversions to neat code.

Bug-fixes always take priority over cosmetic changes.
So, I would send the bug-fix as-soon-as-possible, and then update things.


> P.s.: Sorry for having previously sent an email with HTML.
> 
> Melissa
> 
> > > 
> > > > 
> > > >         switch (type) {
> > > > --
> > > > 2.20.1
> > > > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ