[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190810150058.3509-1-rodrigorsdc@gmail.com>
Date: Sat, 10 Aug 2019 12:00:58 -0300
From: Rodrigo <rodrigorsdc@...il.com>
To: Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Stefan Popa <stefan.popa@...log.com>,
Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-iio@...r.kernel.org, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org, kernel-usp@...glegroups.com,
Rodrigo Carvalho <rodrigorsdc@...il.com>
Subject: [PATCH] staging: iio: accel: adis16240: Improve readability on write_raw function
From: Rodrigo Carvalho <rodrigorsdc@...il.com>
Improve readability by using GENMASK macro, changing switch statement
by if statement and removing unnecessary local variables.
Signed-off-by: Rodrigo Ribeiro Carvalho <rodrigorsdc@...il.com>
---
drivers/staging/iio/accel/adis16240.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c
index 62f4b3b1b457..68f165501389 100644
--- a/drivers/staging/iio/accel/adis16240.c
+++ b/drivers/staging/iio/accel/adis16240.c
@@ -309,17 +309,15 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
long mask)
{
struct adis *st = iio_priv(indio_dev);
- int bits = 10;
- s16 val16;
+ int m;
u8 addr;
- switch (mask) {
- case IIO_CHAN_INFO_CALIBBIAS:
- val16 = val & ((1 << bits) - 1);
- addr = adis16240_addresses[chan->scan_index][0];
- return adis_write_reg_16(st, addr, val16);
- }
- return -EINVAL;
+ if (mask != IIO_CHAN_INFO_CALIBBIAS)
+ return -EINVAL;
+
+ m = GENMASK(9, 0);
+ addr = adis16240_addresses[chan->scan_index][0];
+ return adis_write_reg_16(st, addr, val & m);
}
static const struct iio_chan_spec adis16240_channels[] = {
--
2.20.1
Powered by blists - more mailing lists