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

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:10:58 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/via82xx.c | 13 ++++---------
sound/pci/via82xx_modem.c | 13 ++++---------
2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 58816dea4996..5638d0088fb9 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2428,10 +2428,10 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
return VIA_DXS_48K;
};

-static int __snd_via82xx_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_via82xx_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 via82xx *chip;
int chip_type = 0, card_type;
unsigned int i;
@@ -2536,15 +2536,10 @@ static int __snd_via82xx_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_via82xx_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id));
-}
-
static struct pci_driver via82xx_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_via82xx_ids,
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index b32f84ac17cc..f4475d288a82 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1088,10 +1088,10 @@ static int snd_via82xx_create(struct snd_card *card,
}


-static int __snd_via82xx_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_via82xx_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 via82xx_modem *chip;
int chip_type = 0, card_type;
unsigned int i;
@@ -1139,15 +1139,10 @@ static int __snd_via82xx_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_via82xx_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id));
-}
-
static struct pci_driver via82xx_modem_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_via82xx_modem_ids,
--
2.55.0