On Sat, Nov 28, 2020 at 7:54 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote: > From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > > 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. > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Are there any specific prerequisites? linux-next? When I apply this and try to compile for an ARMv7 target I get a lot of noise and an error: In file included from <command-line>:0:0: ../drivers/iio/gyro/mpu3050-core.c: In function ‘mpu3050_hw_init’: ../include/linux/bits.h:36:11: warning: right shift count is negative [-Wshift-count-negative] (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) ^ ./../include/linux/compiler_types.h:299:9: note: in definition of macro ‘__compiletime_assert’ if (!(condition)) \ ^~~~~~~~~ ./../include/linux/compiler_types.h:319:2: note: in expansion of macro ‘_compiletime_assert’ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ ../include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’ #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ ../include/linux/bitfield.h:46:3: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ ^~~~~~~~~~~~~~~~ ../include/linux/bitfield.h:108:3: note: in expansion of macro ‘__BF_FIELD_CHECK’ __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ ^~~~~~~~~~~~~~~~ ../include/linux/dev_printk.h:118:33: note: in expansion of macro ‘FIELD_GET’ _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~ ../include/linux/bits.h:38:31: note: in expansion of macro ‘__GENMASK’ (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) ^~~~~~~~~ ../include/linux/dev_printk.h:118:33: note: in expansion of macro ‘GENMASK’ _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~ ../drivers/iio/gyro/mpu3050-core.c:830:2: note: in expansion of macro ‘dev_info’ dev_info(mpu3050->dev, ^~~~~~~~ ../include/linux/bits.h:36:11: warning: right shift count is negative [-Wshift-count-negative] (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) ^ ./../include/linux/compiler_types.h:299:9: note: in definition of macro ‘__compiletime_assert’ if (!(condition)) \ ^~~~~~~~~ ./../include/linux/compiler_types.h:319:2: note: in expansion of macro ‘_compiletime_assert’ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ ../include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’ #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ ../include/linux/bitfield.h:48:3: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ BUILD_BUG_ON_MSG((_mask) == 0, _pfx "mask is zero"); \ ^~~~~~~~~~~~~~~~ ../include/linux/bitfield.h:108:3: note: in expansion of macro ‘__BF_FIELD_CHECK’ __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ ^~~~~~~~~~~~~~~~ ../include/linux/dev_printk.h:118:33: note: in expansion of macro ‘FIELD_GET’ _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~ (...) Yours, Linus Walleij