ALSA: mips: hal2: Use devres card management

The hal2 driver's remove callback is nothing but a simple
snd_card_free() call, so let's use the devres for managing the card,
for simplifying the handling.

Now the card is created via snd_devm_card_new() that is auto-cleaned
up at probe for errors.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261003105719.1070427-2-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2026-10-03 12:57:08 +02:00
parent 6541871e8e
commit 07188c32ad

View File

@ -837,30 +837,24 @@ static int hal2_create(struct snd_card *card, struct snd_hal2 **rchip)
static int hal2_probe(struct platform_device *pdev)
{
struct snd_card *card;
struct snd_card *card __free(snd_card_free) = NULL;
struct snd_hal2 *chip;
int err;
err = snd_card_new(&pdev->dev, index, id, THIS_MODULE, 0, &card);
err = snd_devm_card_new(&pdev->dev, index, id, THIS_MODULE, 0, &card);
if (err < 0)
return err;
err = hal2_create(card, &chip);
if (err < 0) {
snd_card_free(card);
if (err < 0)
return err;
}
err = hal2_pcm_create(chip);
if (err < 0) {
snd_card_free(card);
if (err < 0)
return err;
}
err = hal2_mixer_create(chip);
if (err < 0) {
snd_card_free(card);
if (err < 0)
return err;
}
strscpy(card->driver, "SGI HAL2 Audio");
strscpy(card->shortname, "SGI HAL2 Audio");
@ -869,24 +863,16 @@ static int hal2_probe(struct platform_device *pdev)
SGI_HPCDMA_IRQ);
err = snd_card_register(card);
if (err < 0) {
snd_card_free(card);
if (err < 0)
return err;
}
platform_set_drvdata(pdev, card);
card = NULL; /* probe succeeded, don't release as error */
return 0;
}
static void hal2_remove(struct platform_device *pdev)
{
struct snd_card *card = platform_get_drvdata(pdev);
snd_card_free(card);
}
static struct platform_driver hal2_driver = {
.probe = hal2_probe,
.remove = hal2_remove,
.driver = {
.name = "sgihal2",
}