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

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:16:21 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/intel8x0.c | 14 +++++---------
sound/pci/intel8x0m.c | 13 ++++---------
2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index e2ea9016a73e..fb021b65729e 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -3167,10 +3167,10 @@ static int check_default_spdif_aclink(struct pci_dev *pci)
return 0;
}

-static int __snd_intel8x0_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_intel8x0_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct intel8x0 *chip;
int err;
struct shortname_table *name;
@@ -3244,13 +3244,9 @@ static int __snd_intel8x0_probe(struct pci_dev *pci,
return err;

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

-static int snd_intel8x0_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_intel8x0_probe(pci, pci_id));
+ return 0;
}

static struct pci_driver intel8x0_driver = {
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 27dbf6125427..a84436d60937 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1218,10 +1218,10 @@ static struct shortname_table {
{ 0 },
};

-static int __snd_intel8x0m_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_intel8x0m_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct intel8x0m *chip;
int err;
struct shortname_table *name;
@@ -1262,15 +1262,10 @@ static int __snd_intel8x0m_probe(struct pci_dev *pci,
if (err < 0)
return err;
pci_set_drvdata(pci, card);
+ card = NULL; /* probe succeeded, don't release as error */
return 0;
}

-static int snd_intel8x0m_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_intel8x0m_probe(pci, pci_id));
-}
-
static struct pci_driver intel8x0m_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_intel8x0m_ids,
--
2.55.0