ALSA: emu10k1: merge common paths in snd_emu10k1_ptr_{read,write}()
Avoids some code duplication. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230514170323.3408798-3-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Родитель
3676cd4bc8
Коммит
2093dcfc04
|
@ -40,6 +40,11 @@ unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, un
|
|||
if (!check_ptr_reg(emu, regptr))
|
||||
return 0;
|
||||
|
||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||
outl(regptr, emu->port + PTR);
|
||||
val = inl(emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
|
||||
if (reg & 0xff000000) {
|
||||
unsigned char size, offset;
|
||||
|
||||
|
@ -47,17 +52,8 @@ unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, un
|
|||
offset = (reg >> 16) & 0x1f;
|
||||
mask = ((1 << size) - 1) << offset;
|
||||
|
||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||
outl(regptr, emu->port + PTR);
|
||||
val = inl(emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
|
||||
return (val & mask) >> offset;
|
||||
} else {
|
||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||
outl(regptr, emu->port + PTR);
|
||||
val = inl(emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +84,12 @@ void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned i
|
|||
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||
outl(regptr, emu->port + PTR);
|
||||
data |= inl(emu->port + DATA) & ~mask;
|
||||
outl(data, emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
} else {
|
||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||
outl(regptr, emu->port + PTR);
|
||||
outl(data, emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
}
|
||||
outl(data, emu->port + DATA);
|
||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(snd_emu10k1_ptr_write);
|
||||
|
|
Загрузка…
Ссылка в новой задаче