[PATCH 13/32] ALSA: echoaudio: Use auto-cleanup for probe card error handling

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:25:04 EST


Instead of the manual call of snd_card_free_on_error(), use the
auto-cleanup feature.

Merely a code cleanup, and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/pci/echoaudio/echoaudio.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 8b4637231deb..93faeea688de 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1934,11 +1934,11 @@ static int snd_echo_create(struct snd_card *card,
}

/* constructor */
-static int __snd_echo_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_echo_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
static int dev;
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct echoaudio *chip;
char *dsp;
int err;
@@ -2097,17 +2097,11 @@ static int __snd_echo_probe(struct pci_dev *pci,
dev_info(card->dev, "Card registered: %s\n", card->longname);

pci_set_drvdata(pci, chip);
+ card = NULL; /* probe succeeded, don't release as error */
dev++;
return 0;
}

-static int snd_echo_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_echo_probe(pci, pci_id));
-}
-
-
static int snd_echo_suspend(struct device *dev)
{
struct echoaudio *chip = dev_get_drvdata(dev);
--
2.55.0