Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+6 -22
+6 -22
sound/isa/adlib.c
··· 43 43 return 1; 44 44 } 45 45 46 - static void snd_adlib_free(struct snd_card *card) 47 - { 48 - release_and_free_resource(card->private_data); 49 - } 50 - 51 46 static int snd_adlib_probe(struct device *dev, unsigned int n) 52 47 { 53 48 struct snd_card *card; 54 49 struct snd_opl3 *opl3; 55 50 int error; 56 51 57 - error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); 52 + error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); 58 53 if (error < 0) { 59 54 dev_err(dev, "could not create card\n"); 60 55 return error; 61 56 } 62 57 63 - card->private_data = request_region(port[n], 4, CRD_NAME); 58 + card->private_data = devm_request_region(dev, port[n], 4, CRD_NAME); 64 59 if (!card->private_data) { 65 60 dev_err(dev, "could not grab ports\n"); 66 - error = -EBUSY; 67 - goto out; 61 + return -EBUSY; 68 62 } 69 - card->private_free = snd_adlib_free; 70 63 71 64 strcpy(card->driver, DEV_NAME); 72 65 strcpy(card->shortname, CRD_NAME); ··· 68 75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); 69 76 if (error < 0) { 70 77 dev_err(dev, "could not create OPL\n"); 71 - goto out; 78 + return error; 72 79 } 73 80 74 81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); 75 82 if (error < 0) { 76 83 dev_err(dev, "could not create FM\n"); 77 - goto out; 84 + return error; 78 85 } 79 86 80 87 error = snd_card_register(card); 81 88 if (error < 0) { 82 89 dev_err(dev, "could not register card\n"); 83 - goto out; 90 + return error; 84 91 } 85 92 86 93 dev_set_drvdata(dev, card); 87 94 return 0; 88 - 89 - out: snd_card_free(card); 90 - return error; 91 - } 92 - 93 - static void snd_adlib_remove(struct device *dev, unsigned int n) 94 - { 95 - snd_card_free(dev_get_drvdata(dev)); 96 95 } 97 96 98 97 static struct isa_driver snd_adlib_driver = { 99 98 .match = snd_adlib_match, 100 99 .probe = snd_adlib_probe, 101 - .remove = snd_adlib_remove, 102 100 103 101 .driver = { 104 102 .name = DEV_NAME