Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

adis: simplify 'adis_update_bits' macros

There's no need to use '__builtin_choose_expr' to choose the right
call to 'adis_update_bits_base()'. We can change the 'BUILD_BUG_ON()'
condition so that it makes sure only the supported sizes are
passed in. With that, we can just use 'sizeof(val)' as the size argument
of 'adis_update_bits_base()'.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220122130905.99-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sá and committed by
Jonathan Cameron
da593677 90e33e1b

+4 -8
+4 -8
include/linux/iio/imu/adis.h
··· 381 381 * @val can lead to undesired behavior if the register to update is 16bit. 382 382 */ 383 383 #define adis_update_bits(adis, reg, mask, val) ({ \ 384 - BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \ 385 - __builtin_choose_expr(sizeof(val) == 4, \ 386 - adis_update_bits_base(adis, reg, mask, val, 4), \ 387 - adis_update_bits_base(adis, reg, mask, val, 2)); \ 384 + BUILD_BUG_ON(sizeof(val) != 2 && sizeof(val) != 4); \ 385 + adis_update_bits_base(adis, reg, mask, val, sizeof(val)); \ 388 386 }) 389 387 390 388 /** ··· 397 399 * @val can lead to undesired behavior if the register to update is 16bit. 398 400 */ 399 401 #define __adis_update_bits(adis, reg, mask, val) ({ \ 400 - BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \ 401 - __builtin_choose_expr(sizeof(val) == 4, \ 402 - __adis_update_bits_base(adis, reg, mask, val, 4), \ 403 - __adis_update_bits_base(adis, reg, mask, val, 2)); \ 402 + BUILD_BUG_ON(sizeof(val) != 2 && sizeof(val) != 4); \ 403 + __adis_update_bits_base(adis, reg, mask, val, sizeof(val)); \ 404 404 }) 405 405 406 406 int adis_enable_irq(struct adis *adis, bool enable);