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

From: Takashi Iwai

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

diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index f4ec404c0d15..bfd6b023b5aa 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -837,12 +837,12 @@ snd_ad1889_create(struct snd_card *card, struct pci_dev *pci)
}

static int
-__snd_ad1889_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+snd_ad1889_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
int err;
static int devno;
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct snd_ad1889 *chip;

/* (1) */
@@ -892,17 +892,12 @@ __snd_ad1889_probe(struct pci_dev *pci,

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

devno++;
return 0;
}

-static int snd_ad1889_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_ad1889_probe(pci, pci_id));
-}
-
static const struct pci_device_id snd_ad1889_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) },
{ 0, },
--
2.55.0