diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-15 10:59:14 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-19 17:17:12 +0300 |
commit | d6fb54e87869ce91e3dc8b9ee58ed17ee9030c3c (patch) | |
tree | 70b826eb7291beb907e654b34799ad519fafbb0b /sound/isa/ad1816a/ad1816a.c | |
parent | c6e6bb5eab7457a938c0405d5ccf319d3ee735c1 (diff) | |
download | linux-d6fb54e87869ce91e3dc8b9ee58ed17ee9030c3c.tar.xz |
ALSA: ad1816a: Allocate resources with device-managed APIs
This patch converts the resource management in ISA ad1816a driver with
devres as a clean up. Each manual resource management is converted
with the corresponding devres helper, and the card object release is
managed now via card->private_free instead of a lowlevel snd_device.
This should give no user-visible functional changes.
Link: https://lore.kernel.org/r/20210715075941.23332-53-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa/ad1816a/ad1816a.c')
-rw-r--r-- | sound/isa/ad1816a/ad1816a.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index fa5bed0d5a6f..9ac873773129 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -124,28 +124,24 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, struct snd_ad1816a *chip; struct snd_opl3 *opl3; - error = snd_card_new(&pcard->card->dev, - index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_ad1816a), &card); + error = snd_devm_card_new(&pcard->card->dev, + index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_ad1816a), &card); if (error < 0) return error; chip = card->private_data; error = snd_card_ad1816a_pnp(dev, pcard, pid); - if (error) { - snd_card_free(card); + if (error) return error; - } error = snd_ad1816a_create(card, port[dev], irq[dev], dma1[dev], dma2[dev], chip); - if (error) { - snd_card_free(card); + if (error) return error; - } if (clockfreq[dev] >= 5000 && clockfreq[dev] <= 100000) chip->clock_freq = clockfreq[dev]; @@ -155,22 +151,16 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); error = snd_ad1816a_pcm(chip, 0); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } error = snd_ad1816a_mixer(chip); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } error = snd_ad1816a_timer(chip, 0); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } if (mpu_port[dev] > 0) { if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, @@ -186,18 +176,14 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx.\n", fm_port[dev], fm_port[dev] + 2); } else { error = snd_opl3_hwdep_new(opl3, 0, 1, NULL); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } } } error = snd_card_register(card); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } pnp_set_card_drvdata(pcard, card); return 0; } @@ -223,12 +209,6 @@ static int snd_ad1816a_pnp_detect(struct pnp_card_link *card, return -ENODEV; } -static void snd_ad1816a_pnp_remove(struct pnp_card_link *pcard) -{ - snd_card_free(pnp_get_card_drvdata(pcard)); - pnp_set_card_drvdata(pcard, NULL); -} - #ifdef CONFIG_PM static int snd_ad1816a_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) @@ -255,7 +235,6 @@ static struct pnp_card_driver ad1816a_pnpc_driver = { .name = "ad1816a", .id_table = snd_ad1816a_pnpids, .probe = snd_ad1816a_pnp_detect, - .remove = snd_ad1816a_pnp_remove, #ifdef CONFIG_PM .suspend = snd_ad1816a_pnp_suspend, .resume = snd_ad1816a_pnp_resume, |