Skip to content
Commit 26aec6e1 authored by Jonathan Cameron's avatar Jonathan Cameron
Browse files

iio:gyro:mpu3050 Treat otp value as a __le64 and use FIELD_GET() to break up



Inspired by Andy Shevchenko's proposal to use get_unaligned_leXX().

The whole one time programable memory is treated as a single 64bit
little endian value.  Thus we can avoid a lot of messy handling
of fields overlapping byte boundaries by just loading and manipulating
it as an __le64 converted to a u64.  That lets us just use FIELD_GET()
and GENMASK() to extract the values desired.

Note only build tested. We need to use GENMASK_ULL and %llX formatters
to account for the larger types used in computing the various fields.

Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201128185156.428327-1-jic23@kernel.org
Link: https://lore.kernel.org/r/20201129184459.647538-1-jic23@kernel.org
parent 1e405bc2
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment