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

Configure Feed

Select the types of activity you want to include in your feed.

iio: light: tsl2563: Make use of the macros from bits.h

Make use of BIT() and GENMASK() where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Ferry Toth <ftoth@exalondelft.nl>
Link: https://lore.kernel.org/r/20221207190348.9347-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
b90619c4 aca68c02

+9 -8
+9 -8
drivers/iio/light/tsl2563.c
··· 11 11 * Amit Kucheria <amit.kucheria@verdurent.com> 12 12 */ 13 13 14 + #include <linux/bits.h> 14 15 #include <linux/module.h> 15 16 #include <linux/mod_devicetable.h> 16 17 #include <linux/property.h> ··· 34 33 #define ADC_FRAC_BITS 14 35 34 36 35 /* Given number of 1/10000's in ADC_FRAC_BITS precision. */ 37 - #define FRAC10K(f) (((f) * (1L << (ADC_FRAC_BITS))) / (10000)) 36 + #define FRAC10K(f) (((f) * BIT(ADC_FRAC_BITS)) / (10000)) 38 37 39 38 /* Bits used for fraction in calibration coefficients.*/ 40 39 #define CALIB_FRAC_BITS 10 41 40 /* 0.5 in CALIB_FRAC_BITS precision */ 42 - #define CALIB_FRAC_HALF (1 << (CALIB_FRAC_BITS - 1)) 41 + #define CALIB_FRAC_HALF BIT(CALIB_FRAC_BITS - 1) 43 42 /* Make a fraction from a number n that was multiplied with b. */ 44 43 #define CALIB_FRAC(n, b) (((n) << CALIB_FRAC_BITS) / (b)) 45 44 /* Decimal 10^(digits in sysfs presentation) */ 46 45 #define CALIB_BASE_SYSFS 1000 47 46 48 - #define TSL2563_CMD 0x80 49 - #define TSL2563_CLEARINT 0x40 47 + #define TSL2563_CMD BIT(7) 48 + #define TSL2563_CLEARINT BIT(6) 50 49 51 50 #define TSL2563_REG_CTRL 0x00 52 51 #define TSL2563_REG_TIMING 0x01 ··· 59 58 60 59 #define TSL2563_CMD_POWER_ON 0x03 61 60 #define TSL2563_CMD_POWER_OFF 0x00 62 - #define TSL2563_CTRL_POWER_MASK 0x03 61 + #define TSL2563_CTRL_POWER_MASK GENMASK(1, 0) 63 62 64 63 #define TSL2563_TIMING_13MS 0x00 65 64 #define TSL2563_TIMING_100MS 0x01 66 65 #define TSL2563_TIMING_400MS 0x02 67 - #define TSL2563_TIMING_MASK 0x03 66 + #define TSL2563_TIMING_MASK GENMASK(1, 0) 68 67 #define TSL2563_TIMING_GAIN16 0x10 69 68 #define TSL2563_TIMING_GAIN1 0x00 70 69 71 70 #define TSL2563_INT_DISABLED 0x00 72 71 #define TSL2563_INT_LEVEL 0x10 73 - #define TSL2563_INT_MASK 0x30 74 - #define TSL2563_INT_PERSIST(n) ((n) & 0x0F) 72 + #define TSL2563_INT_MASK GENMASK(5, 4) 73 + #define TSL2563_INT_PERSIST(n) ((n) & GENMASK(3, 0)) 75 74 76 75 struct tsl2563_gainlevel_coeff { 77 76 u8 gaintime;