* [PATCH] ALSA: hda/hdmi: Remove some dead code
@ 2023-04-17 5:41 Christophe JAILLET
2023-04-18 6:01 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2023-04-17 5:41 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, alsa-devel
These snd_BUG_ON() can never trigger, so just remove them to save a few
LoC.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative. Maybe the other "if"s should be removed and the
error code returned instead.
I chose to remove these ones and the corresponding error code, because it
seems that it is already handled this way in hdmi_pcm_open().
I don't know the code enough, so it is only my guess.
Review with care :)
---
sound/pci/hda/patch_hdmi.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 5c6980394dce..ee051bdfaff6 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2104,10 +2104,6 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
goto unlock;
}
- if (snd_BUG_ON(pin_idx < 0)) {
- err = -EINVAL;
- goto unlock;
- }
per_pin = get_pin(spec, pin_idx);
/* Verify pin:cvt selections to avoid silent audio after S3.
@@ -2199,13 +2195,13 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
snd_hda_spdif_ctls_unassign(codec, pcm_idx);
clear_bit(pcm_idx, &spec->pcm_in_use);
pin_idx = hinfo_to_pin_index(codec, hinfo);
+ /*
+ * In such a case, return 0 to match the behavior in
+ * hdmi_pcm_open()
+ */
if (pin_idx < 0)
goto unlock;
- if (snd_BUG_ON(pin_idx < 0)) {
- err = -EINVAL;
- goto unlock;
- }
per_pin = get_pin(spec, pin_idx);
if (spec->dyn_pin_out) {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: hda/hdmi: Remove some dead code
2023-04-17 5:41 [PATCH] ALSA: hda/hdmi: Remove some dead code Christophe JAILLET
@ 2023-04-18 6:01 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2023-04-18 6:01 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Takashi Iwai, linux-kernel, kernel-janitors, alsa-devel
On Mon, 17 Apr 2023 07:41:48 +0200,
Christophe JAILLET wrote:
>
> These snd_BUG_ON() can never trigger, so just remove them to save a few
> LoC.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative. Maybe the other "if"s should be removed and the
> error code returned instead.
>
> I chose to remove these ones and the corresponding error code, because it
> seems that it is already handled this way in hdmi_pcm_open().
>
> I don't know the code enough, so it is only my guess.
>
> Review with care :)
A sanity check is merely a sanity check, and we haven't got report
hitting this, so this should be fine. Let's cross fingers.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-18 6:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-17 5:41 [PATCH] ALSA: hda/hdmi: Remove some dead code Christophe JAILLET
2023-04-18 6:01 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox