Skip to content

Commit e922da4

Browse files
ossilatortiwai
authored andcommitted
ALSA: emu10k1: minor optimizations
- In snd_emu10k1_look_for_ctl(), evaluate the cheap condition first - In _snd_emu10k1_{audigy_,}init_efx(), don't use expensive bit setting loops to fill arrays - In snd_emu_proc_ptr_reg_read(), remove useless condition - iobase can be only 0 or 0x20 Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230422121519.1052813-1-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 335927b commit e922da4

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

sound/pci/emu10k1/emufx.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu,
641641
list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) {
642642
kcontrol = ctl->kcontrol;
643643
if (kcontrol->id.iface == id->iface &&
644-
!strcmp(kcontrol->id.name, id->name) &&
645-
kcontrol->id.index == id->index)
644+
kcontrol->id.index == id->index &&
645+
!strcmp(kcontrol->id.name, id->name))
646646
return ctl;
647647
}
648648
return NULL;
@@ -1213,7 +1213,7 @@ static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
12131213

12141214
static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
12151215
{
1216-
int err, i, z, gpr, nctl;
1216+
int err, z, gpr, nctl;
12171217
int bit_shifter16;
12181218
const int playback = 10;
12191219
const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */
@@ -1245,12 +1245,10 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
12451245
icode->code = icode->tram_addr_map + 256;
12461246

12471247
/* clear free GPRs */
1248-
for (i = 0; i < 512; i++)
1249-
set_bit(i, icode->gpr_valid);
1248+
memset(icode->gpr_valid, 0xff, 512 / 8);
12501249

12511250
/* clear TRAM data & address lines */
1252-
for (i = 0; i < 256; i++)
1253-
set_bit(i, icode->tram_valid);
1251+
memset(icode->tram_valid, 0xff, 256 / 8);
12541252

12551253
strcpy(icode->name, "Audigy DSP code for ALSA");
12561254
ptr = 0;
@@ -1886,12 +1884,10 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
18861884
icode->code = icode->tram_addr_map + 160;
18871885

18881886
/* clear free GPRs */
1889-
for (i = 0; i < 256; i++)
1890-
set_bit(i, icode->gpr_valid);
1887+
memset(icode->gpr_valid, 0xff, 256 / 8);
18911888

18921889
/* clear TRAM data & address lines */
1893-
for (i = 0; i < 160; i++)
1894-
set_bit(i, icode->tram_valid);
1890+
memset(icode->tram_valid, 0xff, 160 / 8);
18951891

18961892
strcpy(icode->name, "SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela");
18971893
ptr = 0; i = 0;

sound/pci/emu10k1/emuproc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,7 @@ static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
477477
for(i = offset; i < offset+length; i++) {
478478
snd_iprintf(buffer, "%02X: ",i);
479479
for (j = 0; j < voices; j++) {
480-
if(iobase == 0)
481-
value = snd_ptr_read(emu, 0, i, j);
482-
else
483-
value = snd_ptr_read(emu, 0x20, i, j);
480+
value = snd_ptr_read(emu, iobase, i, j);
484481
snd_iprintf(buffer, "%08lX ", value);
485482
}
486483
snd_iprintf(buffer, "\n");

0 commit comments

Comments
 (0)