diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-15 09:59:27 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-19 16:17:22 +0200 |
commit | 5b88da3c800f21a76b9fd755c604402c15b10855 (patch) | |
tree | 40a0a02b63d7548233aafc2069fd1de63fae8758 /sound/isa/gus/gusmax.c | |
parent | 35a245ec06192629b6c4210b93aaebcfab62a09e (diff) | |
download | lwn-5b88da3c800f21a76b9fd755c604402c15b10855.tar.gz lwn-5b88da3c800f21a76b9fd755c604402c15b10855.zip |
ALSA: gus: Allocate resources with device-managed APIs
This patch converts the resource management in ISA gus drivers with
devres as a clean up. Each manual resource management is converted
with the corresponding devres helper. The remove callback became
superfluous and dropped.
This should give no user-visible functional changes.
Link: https://lore.kernel.org/r/20210715075941.23332-66-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa/gus/gusmax.c')
-rw-r--r-- | sound/isa/gus/gusmax.c | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index ad118d462142..6834c0560064 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -179,16 +179,6 @@ static int snd_gusmax_mixer(struct snd_wss *chip) return 0; } -static void snd_gusmax_free(struct snd_card *card) -{ - struct snd_gusmax *maxcard = card->private_data; - - if (maxcard == NULL) - return; - if (maxcard->irq >= 0) - free_irq(maxcard->irq, (void *)maxcard); -} - static int snd_gusmax_match(struct device *pdev, unsigned int dev) { return enable[dev]; @@ -204,11 +194,10 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) struct snd_wss *wss; struct snd_gusmax *maxcard; - err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_gusmax), &card); + err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_gusmax), &card); if (err < 0) return err; - card->private_free = snd_gusmax_free; maxcard = card->private_data; maxcard->card = card; maxcard->irq = -1; @@ -218,8 +207,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) xirq = snd_legacy_find_free_irq(possible_irqs); if (xirq < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; + return -EBUSY; } } xdma1 = dma1[dev]; @@ -227,8 +215,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) xdma1 = snd_legacy_find_free_dma(possible_dmas); if (xdma1 < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; + return -EBUSY; } } xdma2 = dma2[dev]; @@ -236,8 +223,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) xdma2 = snd_legacy_find_free_dma(possible_dmas); if (xdma2 < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; + return -EBUSY; } } @@ -267,29 +253,28 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) } } if (err < 0) - goto _err; + return err; err = snd_gusmax_detect(gus); if (err < 0) - goto _err; + return err; maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_gusmax_init(dev, card, gus); err = snd_gus_initialize(gus); if (err < 0) - goto _err; + return err; if (!gus->max_flag) { snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); - err = -ENODEV; - goto _err; + return -ENODEV; } - if (request_irq(xirq, snd_gusmax_interrupt, 0, "GUS MAX", (void *)maxcard)) { + if (devm_request_irq(card->dev, xirq, snd_gusmax_interrupt, 0, + "GUS MAX", (void *)maxcard)) { snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); - err = -EBUSY; - goto _err; + return -EBUSY; } maxcard->irq = xirq; card->sync_irq = maxcard->irq; @@ -303,32 +288,32 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) WSS_HWSHARE_DMA2, &wss); if (err < 0) - goto _err; + return err; err = snd_wss_pcm(wss, 0); if (err < 0) - goto _err; + return err; err = snd_wss_mixer(wss); if (err < 0) - goto _err; + return err; err = snd_wss_timer(wss, 2); if (err < 0) - goto _err; + return err; if (pcm_channels[dev] > 0) { err = snd_gf1_pcm_new(gus, 1, 1); if (err < 0) - goto _err; + return err; } err = snd_gusmax_mixer(wss); if (err < 0) - goto _err; + return err; err = snd_gf1_rawmidi_new(gus, 0); if (err < 0) - goto _err; + return err; sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); if (xdma2 >= 0) @@ -336,22 +321,13 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) err = snd_card_register(card); if (err < 0) - goto _err; + return err; maxcard->gus = gus; maxcard->wss = wss; dev_set_drvdata(pdev, card); return 0; - - _err: - snd_card_free(card); - return err; -} - -static void snd_gusmax_remove(struct device *devptr, unsigned int dev) -{ - snd_card_free(dev_get_drvdata(devptr)); } #define DEV_NAME "gusmax" @@ -359,7 +335,6 @@ static void snd_gusmax_remove(struct device *devptr, unsigned int dev) static struct isa_driver snd_gusmax_driver = { .match = snd_gusmax_match, .probe = snd_gusmax_probe, - .remove = snd_gusmax_remove, /* FIXME: suspend/resume */ .driver = { .name = DEV_NAME |