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: 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>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
138daca3 de8860b1

+1 -1
+1 -1
drivers/iio/adc/sc27xx_adc.c
··· 307 307 308 308 sc27xx_adc_volt_ratio(data, channel, scale, &numerator, &denominator); 309 309 310 - return (volt * denominator + numerator / 2) / numerator; 310 + return DIV_ROUND_CLOSEST(volt * denominator, numerator); 311 311 } 312 312 313 313 static int sc27xx_adc_read_processed(struct sc27xx_adc_data *data,