aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/control.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2020-12-23 18:22:12 +0100
committerTakashi Iwai <tiwai@suse.de>2020-12-25 09:11:46 +0100
commitafcfbcb39fe539ff9a24ca9187bb49e09a14abe5 (patch)
treed28441bb4559bbcb327b358407b67bef0f637567 /sound/core/control.c
parentALSA: usb-audio: Fix UBSAN warnings for MIDI jacks (diff)
downloadlinux-dev-afcfbcb39fe539ff9a24ca9187bb49e09a14abe5.tar.xz
linux-dev-afcfbcb39fe539ff9a24ca9187bb49e09a14abe5.zip
ALSA: core: Use DIV_ROUND_UP() instead of open-coding it
Use DIV_ROUND_UP() 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) - 1) / (y)) +DIV_ROUND_UP(x, y) // </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20201223172229.781-1-lars@metafoo.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 3b44378b9dec..1571c7f7c43b 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -836,7 +836,7 @@ static void fill_remaining_elem_value(struct snd_ctl_elem_value *control,
{
size_t offset = value_sizes[info->type] * info->count;
- offset = (offset + sizeof(u32) - 1) / sizeof(u32);
+ offset = DIV_ROUND_UP(offset, sizeof(u32));
memset32((u32 *)control->value.bytes.data + offset, pattern,
sizeof(control->value) / sizeof(u32) - offset);
}
@@ -928,7 +928,7 @@ static int sanity_check_elem_value(struct snd_card *card,
/* check whether the remaining area kept untouched */
offset = value_sizes[info->type] * info->count;
- offset = (offset + sizeof(u32) - 1) / sizeof(u32);
+ offset = DIV_ROUND_UP(offset, sizeof(u32));
p = (u32 *)control->value.bytes.data + offset;
for (; offset < sizeof(control->value) / sizeof(u32); offset++, p++) {
if (*p != pattern) {