diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-15 09:59:35 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-19 16:17:28 +0200 |
commit | ed539fc3428c6901e668e9d71ce1ca78f28cc03f (patch) | |
tree | 8bcfd549779d6a4e8a34c1249c688ef09adaee47 /sound/drivers | |
parent | 854577ac2aea5cf4d8f48a841fd26e04cbac2b77 (diff) | |
download | linux-ed539fc3428c6901e668e9d71ce1ca78f28cc03f.tar.gz linux-ed539fc3428c6901e668e9d71ce1ca78f28cc03f.tar.bz2 linux-ed539fc3428c6901e668e9d71ce1ca78f28cc03f.zip |
ALSA: virmidi: Allocate resources with device-managed APIs
This patch converts the card object management with devres as a clean
up. The remove callback gets reduced by that.
This should give no user-visible functional changes.
Link: https://lore.kernel.org/r/20210715075941.23332-74-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/drivers')
-rw-r--r-- | sound/drivers/virmidi.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 4206d93ab47e..7f7eed6faaae 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -75,8 +75,8 @@ static int snd_virmidi_probe(struct platform_device *devptr) int idx, err; int dev = devptr->id; - err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_virmidi), &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_virmidi), &card); if (err < 0) return err; vmidi = card->private_data; @@ -94,7 +94,7 @@ static int snd_virmidi_probe(struct platform_device *devptr) err = snd_virmidi_new(card, idx, &rmidi); if (err < 0) - goto __nodev; + return err; rdev = rmidi->private_data; vmidi->midi[idx] = rmidi; strcpy(rmidi->name, "Virtual Raw MIDI"); @@ -106,18 +106,10 @@ static int snd_virmidi_probe(struct platform_device *devptr) sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); err = snd_card_register(card); - if (!err) { - platform_set_drvdata(devptr, card); - return 0; - } -__nodev: - snd_card_free(card); - return err; -} + if (err) + return err; -static int snd_virmidi_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, card); return 0; } @@ -125,7 +117,6 @@ static int snd_virmidi_remove(struct platform_device *devptr) static struct platform_driver snd_virmidi_driver = { .probe = snd_virmidi_probe, - .remove = snd_virmidi_remove, .driver = { .name = SND_VIRMIDI_DRIVER, }, |