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

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:17:55 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/es1938.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 217beb9376ac..a1ceb49d572c 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1683,11 +1683,11 @@ static int snd_es1938_mixer(struct es1938 *chip)
}


-static int __snd_es1938_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_es1938_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 es1938 *chip;
struct snd_opl3 *opl3;
int idx, err;
@@ -1759,16 +1759,11 @@ static int __snd_es1938_probe(struct pci_dev *pci,
return err;

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

-static int snd_es1938_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id));
-}
-
static struct pci_driver es1938_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_es1938_ids,
--
2.55.0