ALSA: emu10k1: optimize mask calculation in snd_emu10k1_ptr_read()
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Sun, 14 May 2023 17:03:23 +0000 (19:03 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 15 May 2023 20:00:56 +0000 (22:00 +0200)
Unlike in snd_emu10k1_ptr_write(), we don't need to keep the value's
bits in place, so we can save one shift.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230514170323.3408798-4-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/emu10k1/io.c

index 2d6bbb7..59b0f4d 100644 (file)
@@ -50,9 +50,9 @@ unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, un
                
                size = (reg >> 24) & 0x3f;
                offset = (reg >> 16) & 0x1f;
-               mask = ((1 << size) - 1) << offset;
+               mask = (1 << size) - 1;
                
-               return (val & mask) >> offset;
+               return (val >> offset) & mask;
        } else {
                return val;
        }