1

ALSA: emux: simplify snd_sf_list.callback handling

Both drivers provide both sample_new and sample_free, and it makes no
sense to pretend that they could not. In fact, load_data() would already
crash if sample_new was null. So remove the remaining null checks.

Contrary to that, the emu10k1 driver actually has a null sample_reset,
though I'm not convinced that this inconsistency is justified.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Message-ID: <20240406064830.1029573-18-oswald.buddenhagen@gmx.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Oswald Buddenhagen 2024-04-06 08:48:30 +02:00 committed by Takashi Iwai
parent 62001ad1b4
commit 4c4cbe6682
2 changed files with 7 additions and 11 deletions

View File

@ -94,9 +94,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
/* create soundfont list */ /* create soundfont list */
memset(&sf_cb, 0, sizeof(sf_cb)); memset(&sf_cb, 0, sizeof(sf_cb));
sf_cb.private_data = emu; sf_cb.private_data = emu;
if (emu->ops.sample_new)
sf_cb.sample_new = sf_sample_new; sf_cb.sample_new = sf_sample_new;
if (emu->ops.sample_free)
sf_cb.sample_free = sf_sample_free; sf_cb.sample_free = sf_sample_free;
if (emu->ops.sample_reset) if (emu->ops.sample_reset)
sf_cb.sample_reset = sf_sample_reset; sf_cb.sample_reset = sf_sample_reset;

View File

@ -1051,7 +1051,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
/* /*
* load wave data * load wave data
*/ */
if (smp->v.size > 0 && sflist->callback.sample_new) { if (smp->v.size > 0) {
rc = sflist->callback.sample_new rc = sflist->callback.sample_new
(sflist->callback.private_data, smp, sflist->memhdr, (sflist->callback.private_data, smp, sflist->memhdr,
data, count); data, count);
@ -1416,7 +1416,6 @@ snd_sf_clear(struct snd_sf_list *sflist)
} }
for (sp = sf->samples; sp; sp = nextsp) { for (sp = sf->samples; sp; sp = nextsp) {
nextsp = sp->next; nextsp = sp->next;
if (sflist->callback.sample_free)
sflist->callback.sample_free(sflist->callback.private_data, sflist->callback.sample_free(sflist->callback.private_data,
sp, sflist->memhdr); sp, sflist->memhdr);
kfree(sp); kfree(sp);
@ -1520,7 +1519,6 @@ snd_soundfont_remove_unlocked(struct snd_sf_list *sflist)
nextsp = sp->next; nextsp = sp->next;
sf->samples = nextsp; sf->samples = nextsp;
sflist->mem_used -= sp->v.truesize; sflist->mem_used -= sp->v.truesize;
if (sflist->callback.sample_free)
sflist->callback.sample_free(sflist->callback.private_data, sflist->callback.sample_free(sflist->callback.private_data,
sp, sflist->memhdr); sp, sflist->memhdr);
kfree(sp); kfree(sp);