All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>,
	Arthur Marsh <arthur.marsh@internode.on.net>
Subject: [PATCH v2 17/17] ALSA: emux: simplify snd_sf_list.callback handling
Date: Thu,  4 Apr 2024 12:00:48 +0200	[thread overview]
Message-ID: <20240404100048.819674-18-oswald.buddenhagen@gmx.de> (raw)
In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de>

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>
---
 sound/synth/emux/emux.c      |  6 ++----
 sound/synth/emux/soundfont.c | 12 +++++-------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index a82af9374852..01444fc960d0 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -94,10 +94,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
 	/* create soundfont list */
 	memset(&sf_cb, 0, sizeof(sf_cb));
 	sf_cb.private_data = emu;
-	if (emu->ops.sample_new)
-		sf_cb.sample_new = sf_sample_new;
-	if (emu->ops.sample_free)
-		sf_cb.sample_free = sf_sample_free;
+	sf_cb.sample_new = sf_sample_new;
+	sf_cb.sample_free = sf_sample_free;
 	if (emu->ops.sample_reset)
 		sf_cb.sample_reset = sf_sample_reset;
 	emu->sflist = snd_sf_new(&sf_cb, emu->memhdr);
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 4edc693da8e7..2373ed580bf8 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -1051,7 +1051,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
 	/*
 	 * load wave data
 	 */
-	if (smp->v.size > 0 && sflist->callback.sample_new) {
+	if (smp->v.size > 0) {
 		rc = sflist->callback.sample_new
 			(sflist->callback.private_data, smp, sflist->memhdr,
 			 data, count);
@@ -1416,9 +1416,8 @@ snd_sf_clear(struct snd_sf_list *sflist)
 		}
 		for (sp = sf->samples; sp; sp = nextsp) {
 			nextsp = sp->next;
-			if (sflist->callback.sample_free)
-				sflist->callback.sample_free(sflist->callback.private_data,
-							     sp, sflist->memhdr);
+			sflist->callback.sample_free(sflist->callback.private_data,
+						     sp, sflist->memhdr);
 			kfree(sp);
 		}
 		kfree(sf);
@@ -1520,9 +1519,8 @@ snd_soundfont_remove_unlocked(struct snd_sf_list *sflist)
 			nextsp = sp->next;
 			sf->samples = nextsp;
 			sflist->mem_used -= sp->v.truesize;
-			if (sflist->callback.sample_free)
-				sflist->callback.sample_free(sflist->callback.private_data,
-							     sp, sflist->memhdr);
+			sflist->callback.sample_free(sflist->callback.private_data,
+						     sp, sflist->memhdr);
 			kfree(sp);
 		}
 	}
--
2.42.0.419.g70bf8a5751


  parent reply	other threads:[~2024-04-04 10:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 10:00 [PATCH v2 00/17] ALSA: emu10k1 & emux: fixes related to wavetable playback Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 01/17] ALSA: emux: fix /proc teardown at module unload Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 02/17] ALSA: emux: prune unused parameter from snd_soundfont_load_guspatch() Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 03/17] ALSA: emux: fix validation of snd_emux.num_ports Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 04/17] ALSA: emux: fix init of patch_info.truesize in load_data() Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 05/17] ALSA: emu10k1: prune vestiges of SNDRV_SFNT_SAMPLE_{BIDIR,REVERSE}_LOOP support Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 06/17] ALSA: emux: centralize & improve patch info validation Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 07/17] ALSA: emux: improve patch ioctl data validation Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 08/17] ALSA: emu10k1: move patch loader assertions into low-level functions Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 09/17] ALSA: emu10k1: fix sample signedness issues in wavetable loader Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 10/17] ALSA: emu10k1: fix playback of 8-bit wavetable samples Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 11/17] ALSA: emu10k1: merge conditions in patch loader Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 12/17] ALSA: emu10k1: fix wavetable offset recalculation Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 13/17] ALSA: emu10k1: de-duplicate size calculations for 16-bit samples Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 14/17] ALSA: emu10k1: improve cache behavior documentation Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 15/17] ALSA: emu10k1: fix wavetable playback position and caching, take 2 Oswald Buddenhagen
2024-04-04 10:00 ` [PATCH v2 16/17] ALSA: emu10k1: shrink blank space in front of wavetable samples Oswald Buddenhagen
2024-04-04 10:00 ` Oswald Buddenhagen [this message]
2024-04-05  9:20 ` [PATCH v2 00/17] ALSA: emu10k1 & emux: fixes related to wavetable playback Takashi Iwai
2024-04-05 10:07   ` Oswald Buddenhagen
2024-04-05 10:29     ` Takashi Iwai
2024-04-05 18:38       ` Oswald Buddenhagen
2024-04-06  6:40         ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240404100048.819674-18-oswald.buddenhagen@gmx.de \
    --to=oswald.buddenhagen@gmx.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=arthur.marsh@internode.on.net \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.