linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH v1] iio: gyro: mpu3050: Use get_unaligned_leXX()
Date: Mon, 26 Oct 2020 19:53:40 +0200	[thread overview]
Message-ID: <20201026175340.19570-1-andriy.shevchenko@linux.intel.com> (raw)

This makes the driver code slightly easier to read.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/gyro/mpu3050-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index 00e58060968c..42b6ccb13568 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -827,15 +827,15 @@ static int mpu3050_hw_init(struct mpu3050 *mpu3050)
 		 "die ID: %04X, wafer ID: %02X, A lot ID: %04X, "
 		 "W lot ID: %03X, WP ID: %01X, rev ID: %02X\n",
 		 /* Die ID, bits 0-12 */
-		 (otp[1] << 8 | otp[0]) & 0x1fff,
+		 get_unaligned_le16(&otp[0]) & GENMASK(12, 0),
 		 /* Wafer ID, bits 13-17 */
-		 ((otp[2] << 8 | otp[1]) & 0x03e0) >> 5,
+		 (get_unaligned_le16(&otp[1]) & GENMASK(9, 5)) >> 5,
 		 /* A lot ID, bits 18-33 */
-		 ((otp[4] << 16 | otp[3] << 8 | otp[2]) & 0x3fffc) >> 2,
+		 (get_unaligned_le24(&otp[2]) & GENMASK(17, 2)) >> 2,
 		 /* W lot ID, bits 34-45 */
-		 ((otp[5] << 8 | otp[4]) & 0x3ffc) >> 2,
+		 (get_unaligned_le16(&otp[4]) & GENMASK(13, 2)) >> 2,
 		 /* WP ID, bits 47-49 */
-		 ((otp[6] << 8 | otp[5]) & 0x0380) >> 7,
+		 (get_unaligned_le16(&otp[5]) & GENMASK(9, 7)) >> 7,
 		 /* rev ID, bits 50-55 */
 		 otp[6] >> 2);
 
-- 
2.28.0


             reply	other threads:[~2020-10-26 17:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 17:53 Andy Shevchenko [this message]
2020-10-28 13:24 ` [PATCH v1] iio: gyro: mpu3050: Use get_unaligned_leXX() Linus Walleij
2020-10-29 15:04 ` Jonathan Cameron
2020-10-29 17:10   ` Andy Shevchenko
2020-11-05 14:23     ` Linus Walleij
2020-11-05 15:07       ` Andy Shevchenko

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=20201026175340.19570-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).