Skip to contentSkip to conversation

ALSA: emu10k1: fix 64-bit integer division

PATCH In review Arnd Bergmann 2 participants 2 messages May 17, 2023 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: emu10k1: fix 64-bit integer division

From: Arnd Bergmann <[email protected]>

Division of 64-bit values causes a link failure on 32-bit targets, depending on compiler version and target architecture:

ERROR: modpost: "__divdi3" [sound/pci/emu10k1/snd-emu10k1.ko] undefined!
ERROR: modpost: "__udivdi3" [sound/pci/emu10k1/snd-emu10k1.ko] undefined!

Replace these with the safe div_u64() helpers.

Fixes bb5ceb43b7bf ("ALSA: emu10k1: fix non-zero mixer control defaults in highres mode")
---
 sound/pci/emu10k1/emufx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/emu10k1/emufx.c +2 -2
index f64b2b4eb348..7c28789720d1 100644
@@ -1156,7 +1156,7 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
 		ctl->max = 0x7fffffff;
 		ctl->tlv = snd_emu10k1_db_linear;
 		ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
-		defval = defval * 0x80000000LL / 100 - 1;
+		defval = div_u64(defval * 0x80000000LL, 100) - 1;
 	} else {
 		ctl->min = 0;
 		ctl->max = 100;
@@ -1178,7 +1178,7 @@ snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
 		ctl->max = 0x7fffffff;
 		ctl->tlv = snd_emu10k1_db_linear;
 		ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
-		defval = defval * 0x80000000LL / 100 - 1;
+		defval = div_u64(defval * 0x80000000LL, 100) - 1;
 	} else {
 		ctl->min = 0;
 		ctl->max = 100;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Division of 64-bit values causes a link failure on 32-bit targets, depending on compiler version and target architecture:

Quoted 7 lines

ERROR: modpost: "__divdi3" [sound/pci/emu10k1/snd-emu10k1.ko] undefined!
ERROR: modpost: "__udivdi3" [sound/pci/emu10k1/snd-emu10k1.ko] undefined!

Replace these with the safe div_u64() helpers.

Fixes bb5ceb43b7bf ("ALSA: emu10k1: fix non-zero mixer control defaults in highres mode")

Another fix patch was already submitted and merged:
https://lore.kernel.org/r/[email protected]

Let me know if you still hit the issue with that patch.

thanks,

Takashi