diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-15 09:59:18 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-19 16:17:16 +0200 |
commit | 5d50e348a499dcf5ba40dd797ac15fa78fe8d06b (patch) | |
tree | 6dd4481038e2ca4053488ccbb41693eb73e284a9 /sound/isa | |
parent | e031577eef6118bd9c4f3ec319f69986531cd32c (diff) |
ALSA: adlib: Allocate resources with device-managed APIs
This patch converts the resource management in ISA adlib driver 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-57-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/adlib.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c index e6cd7c4da38e..f079ba4ef1a0 100644 --- a/sound/isa/adlib.c +++ b/sound/isa/adlib.c @@ -43,30 +43,23 @@ static int snd_adlib_match(struct device *dev, unsigned int n) return 1; } -static void snd_adlib_free(struct snd_card *card) -{ - release_and_free_resource(card->private_data); -} - static int snd_adlib_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_opl3 *opl3; int error; - error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); + error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); if (error < 0) { dev_err(dev, "could not create card\n"); return error; } - card->private_data = request_region(port[n], 4, CRD_NAME); + card->private_data = devm_request_region(dev, port[n], 4, CRD_NAME); if (!card->private_data) { dev_err(dev, "could not grab ports\n"); - error = -EBUSY; - goto out; + return -EBUSY; } - card->private_free = snd_adlib_free; strcpy(card->driver, DEV_NAME); strcpy(card->shortname, CRD_NAME); @@ -75,37 +68,28 @@ static int snd_adlib_probe(struct device *dev, unsigned int n) error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); if (error < 0) { dev_err(dev, "could not create OPL\n"); - goto out; + return error; } error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); if (error < 0) { dev_err(dev, "could not create FM\n"); - goto out; + return error; } error = snd_card_register(card); if (error < 0) { dev_err(dev, "could not register card\n"); - goto out; + return error; } dev_set_drvdata(dev, card); return 0; - -out: snd_card_free(card); - return error; -} - -static void snd_adlib_remove(struct device *dev, unsigned int n) -{ - snd_card_free(dev_get_drvdata(dev)); } static struct isa_driver snd_adlib_driver = { .match = snd_adlib_match, .probe = snd_adlib_probe, - .remove = snd_adlib_remove, .driver = { .name = DEV_NAME |