From: Shreeya Patel <shreeya.patel23498@gmail.com>
To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org,
knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, daniel.baluta@gmail.com
Cc: Shreeya Patel <shreeya.patel23498@gmail.com>
Subject: [PATCH v3 4/4] Staging: iio: adis16209: Use sign_extend32 function
Date: Sun, 4 Mar 2018 18:15:06 +0530 [thread overview]
Message-ID: <a2029d242df63f82ca791c99c86963ffeabc849d.1520164945.git.shreeya.patel23498@gmail.com> (raw)
In-Reply-To: <cover.1520164945.git.shreeya.patel23498@gmail.com>
Use sign_extend32 function instead of manually coding
it.
Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
Changes in v3
-After split patch.
drivers/staging/iio/accel/adis16209.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c
index 9cb1ce0..a8453bf 100644
--- a/drivers/staging/iio/accel/adis16209.c
+++ b/drivers/staging/iio/accel/adis16209.c
@@ -212,9 +212,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
ret = adis_read_reg_16(st, addr, &val16);
if (ret)
return ret;
- val16 &= (1 << bits) - 1;
- val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
- *val = val16;
+
+ *val = sign_extend32(val16, bits - 1);
return IIO_VAL_INT;
}
return -EINVAL;
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2018-03-04 12:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-04 12:34 [PATCH v3 0/4] adis16209 driver cleanup Shreeya Patel
2018-03-04 12:36 ` [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions Shreeya Patel
2018-03-04 12:56 ` Himanshu Jha
2018-03-04 13:07 ` Shreeya Patel
2018-03-07 21:02 ` Jonathan Cameron
2018-03-04 12:41 ` [PATCH v3 2/4] Staging: iio: adis16209: Change some macro names Shreeya Patel
2018-03-07 21:06 ` Jonathan Cameron
2018-03-04 12:43 ` [PATCH v3 3/4] Staging: iio: adis16209: Adjust a switch statement Shreeya Patel
2018-03-07 21:07 ` Jonathan Cameron
2018-03-04 12:45 ` Shreeya Patel [this message]
2018-03-07 21:08 ` [PATCH v3 4/4] Staging: iio: adis16209: Use sign_extend32 function Jonathan Cameron
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=a2029d242df63f82ca791c99c86963ffeabc849d.1520164945.git.shreeya.patel23498@gmail.com \
--to=shreeya.patel23498@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=daniel.baluta@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®