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

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:10:08 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/oxygen/oxygen_lib.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 6b096d654f9f..9d48cfbf4c23 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -572,7 +572,7 @@ static void oxygen_card_free(struct snd_card *card)
mutex_destroy(&chip->mutex);
}

-static int __oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
+int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
struct module *owner,
const struct pci_device_id *ids,
int (*get_model)(struct oxygen *chip,
@@ -580,7 +580,7 @@ static int __oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
)
)
{
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct oxygen *chip;
const struct pci_device_id *pci_id;
int err;
@@ -695,18 +695,9 @@ static int __oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
return err;

pci_set_drvdata(pci, card);
+ card = NULL; /* probe succeeded, don't release as error */
return 0;
}
-
-int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
- struct module *owner,
- const struct pci_device_id *ids,
- int (*get_model)(struct oxygen *chip,
- const struct pci_device_id *id))
-{
- return snd_card_free_on_error(&pci->dev,
- __oxygen_pci_probe(pci, index, id, owner, ids, get_model));
-}
EXPORT_SYMBOL(oxygen_pci_probe);

static int oxygen_pci_suspend(struct device *dev)
--
2.55.0