From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "ardeleanalex@gmail.com" <ardeleanalex@gmail.com>,
"melissa.srw@gmail.com" <melissa.srw@gmail.com>
Cc: "kernel-usp@googlegroups.com" <kernel-usp@googlegroups.com>,
"lars@metafoo.de" <lars@metafoo.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Popa, Stefan Serban" <StefanSerban.Popa@analog.com>,
"knaack.h@gmx.de" <knaack.h@gmx.de>,
"jic23@kernel.org" <jic23@kernel.org>,
"21cnbao@gmail.com" <21cnbao@gmail.com>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 2/4] staging: iio: ad7150: use FIELD_GET and GENMASK
Date: Mon, 6 May 2019 06:51:31 +0000 [thread overview]
Message-ID: <179d019c34cc69e50f19499a6089ac94740b59f5.camel@analog.com> (raw)
In-Reply-To: <CA+U=Dso6zSLzhhdiZcc+P4-2zcabxnoMd2539HmofTXrtYoKDQ@mail.gmail.com>
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@gmail.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@analog.com>
>
> One minor comment inline, which would be the object of a new patch.
>
> > Signed-off-by: Melissa Wen <melissa.srw@gmail.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 ?
>
> >
> > switch (type) {
> > --
> > 2.20.1
> >
next prev parent reply other threads:[~2019-05-06 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 22:13 [PATCH 0/4] staging: iio: ad7150: improve driver readability Melissa Wen
2019-05-03 22:13 ` [PATCH 1/4] staging: iio: ad7150: organize registers definition Melissa Wen
2019-05-04 10:13 ` Alexandru Ardelean
2019-05-05 12:52 ` Jonathan Cameron
2019-05-03 22:14 ` [PATCH 2/4] staging: iio: ad7150: use FIELD_GET and GENMASK Melissa Wen
2019-05-04 10:43 ` Alexandru Ardelean
2019-05-06 6:51 ` Ardelean, Alexandru [this message]
2019-05-07 20:44 ` Melissa Wen
2019-05-08 7:50 ` Ardelean, Alexandru
2019-05-03 22:15 ` [PATCH 3/4] staging: iio: ad7150: simplify i2c SMBus return treatment Melissa Wen
2019-05-04 10:36 ` Alexandru Ardelean
2019-05-05 12:59 ` Jonathan Cameron
2019-05-03 22:16 ` [PATCH 4/4] staging: iio: ad7150: clean up of comments Melissa Wen
2019-05-04 11:12 ` [PATCH 0/4] staging: iio: ad7150: improve driver readability Alexandru Ardelean
2019-05-04 14:42 ` Alexandru Ardelean
2019-05-05 13:05 ` Jonathan Cameron
2019-05-07 20:35 ` Melissa Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179d019c34cc69e50f19499a6089ac94740b59f5.camel@analog.com \
--to=alexandru.ardelean@analog.com \
--cc=21cnbao@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=StefanSerban.Popa@analog.com \
--cc=ardeleanalex@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=kernel-usp@googlegroups.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=melissa.srw@gmail.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).