[PATCH 11/32] ALSA: cs4281: Use auto-cleanup for probe card error handling
From: Takashi Iwai
Date: Thu Oct 01 2026 - 07:08:54 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/cs4281.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 27ceda6278c5..b55139a8d8bd 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1811,11 +1811,11 @@ static void snd_cs4281_opl3_command(struct snd_opl3 *opl3, unsigned short cmd,
udelay(30);
}
-static int __snd_cs4281_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_cs4281_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 cs4281 *chip;
struct snd_opl3 *opl3;
int err;
@@ -1868,16 +1868,11 @@ static int __snd_cs4281_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_cs4281_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_cs4281_probe(pci, pci_id));
-}
-
/*
* Power Management
*/
--
2.55.0