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

From: Takashi Iwai

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

diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 383def1f2af7..be402b94da17 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -798,11 +798,11 @@ static int snd_bt87x_detect_card(struct pci_dev *pci)
return SND_BT87X_BOARD_UNKNOWN;
}

-static int __snd_bt87x_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_bt87x_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 snd_bt87x *chip;
int err;
enum snd_bt87x_boardid boardid;
@@ -878,16 +878,11 @@ static int __snd_bt87x_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_bt87x_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_bt87x_probe(pci, pci_id));
-}
-
/* default entries for all Bt87x cards - it's not exported */
/* driver_data is set to 0 to call detection */
static const struct pci_device_id snd_bt87x_default_ids[] = {
--
2.55.0