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: Drop unused defintion(s)

The CALIB_FRAC() is defined and might had been used in
tsl2563_calib_from_sysfs(). But let's just move a comment
from it to the latter function.

CLAIB_FRAC_HALF is used in a single place, i.e. in
tsl2563_calib_to_sysfs(). So, let's just inline it there.

While at it, switch to use DIV_ROUND_CLOSEST().

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-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
bbabf919 b90619c4

+3 -6
+3 -6
drivers/iio/light/tsl2563.c
··· 19 19 #include <linux/interrupt.h> 20 20 #include <linux/irq.h> 21 21 #include <linux/sched.h> 22 + #include <linux/math.h> 22 23 #include <linux/mutex.h> 23 24 #include <linux/delay.h> 24 25 #include <linux/pm.h> ··· 39 38 40 39 /* Bits used for fraction in calibration coefficients.*/ 41 40 #define CALIB_FRAC_BITS 10 42 - /* 0.5 in CALIB_FRAC_BITS precision */ 43 - #define CALIB_FRAC_HALF BIT(CALIB_FRAC_BITS - 1) 44 - /* Make a fraction from a number n that was multiplied with b. */ 45 - #define CALIB_FRAC(n, b) (((n) << CALIB_FRAC_BITS) / (b)) 46 41 /* Decimal 10^(digits in sysfs presentation) */ 47 42 #define CALIB_BASE_SYSFS 1000 48 43 ··· 357 360 358 361 static inline int tsl2563_calib_to_sysfs(u32 calib) 359 362 { 360 - return (int) (((calib * CALIB_BASE_SYSFS) + 361 - CALIB_FRAC_HALF) >> CALIB_FRAC_BITS); 363 + return (int)DIV_ROUND_CLOSEST(calib * CALIB_BASE_SYSFS, BIT(CALIB_FRAC_BITS)); 362 364 } 363 365 364 366 static inline u32 tsl2563_calib_from_sysfs(int value) 365 367 { 368 + /* Make a fraction from a number n that was multiplied with b. */ 366 369 return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS; 367 370 } 368 371