summaryrefslogtreecommitdiff
path: root/sound/core/oss/mixer_oss.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2020-12-23 18:22:24 +0100
committerTakashi Iwai <tiwai@suse.de>2020-12-25 09:11:54 +0100
commit6b5edf1dcc6005feb0151e3b6c8465770593d5f8 (patch)
tree7bf3b11e26d49de19f5aa75b25216149312107bf /sound/core/oss/mixer_oss.c
parentaf102a88ade2aca4b5c38843fbdc05d9f85b7723 (diff)
ALSA: oss: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and 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> Link: https://lore.kernel.org/r/20201223172229.781-13-lars@metafoo.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/oss/mixer_oss.c')
-rw-r--r--sound/core/oss/mixer_oss.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index f702c96a7478..af5de08f9819 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -418,7 +418,7 @@ static long snd_mixer_oss_conv(long val, long omin, long omax, long nmin, long n
if (orange == 0)
return 0;
- return ((nrange * (val - omin)) + (orange / 2)) / orange + nmin;
+ return DIV_ROUND_CLOSEST(nrange * (val - omin), orange) + nmin;
}
/* convert from alsa native to oss values (0-100) */