diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2020-12-22 20:16:18 +0100 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-01-09 22:52:46 +0100 |
commit | 138daca30ee9d9c0abc6a10f437dd38746c716e9 (patch) | |
tree | 35367bad2a059f84f3a2ba201dcc65bc88bf7fba /drivers/iio/adc/sc27xx_adc.c | |
parent | iio: magnetometer: Add driver for Yamaha YAS530 (diff) | |
download | linux-138daca30ee9d9c0abc6a10f437dd38746c716e9.tar.xz linux-138daca30ee9d9c0abc6a10f437dd38746c716e9.zip |
iio: sc27xx_adc: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This makes it more clear
what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((x) + ((y) / 2)) / (y)
+DIV_ROUND_CLOSEST(x, y)
// </smpl>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>
Link: https://lore.kernel.org/r/20201222191618.3433-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/sc27xx_adc.c')
-rw-r--r-- | drivers/iio/adc/sc27xx_adc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c index aa32a1f385e2..301cf66de695 100644 --- a/drivers/iio/adc/sc27xx_adc.c +++ b/drivers/iio/adc/sc27xx_adc.c @@ -307,7 +307,7 @@ static int sc27xx_adc_convert_volt(struct sc27xx_adc_data *data, int channel, sc27xx_adc_volt_ratio(data, channel, scale, &numerator, &denominator); - return (volt * denominator + numerator / 2) / numerator; + return DIV_ROUND_CLOSEST(volt * denominator, numerator); } static int sc27xx_adc_read_processed(struct sc27xx_adc_data *data, |