diff options
author | Takashi Iwai | 2021-07-15 09:59:40 +0200 |
---|---|---|
committer | Takashi Iwai | 2021-07-19 16:17:32 +0200 |
commit | ed16a22b09002fe1bef302242a0ac4a00f44b20d (patch) | |
tree | 37002e05e6a29381e5c79478d99cdd2f8e7365fd /sound/drivers | |
parent | b072e65aadd683e75518150c609ae29b5d33fe0c (diff) |
ALSA: dummy: Allocate resources with device-managed APIs
Use the new snd_devm_card_new() for the card object allocation, and
clean up the superfluous remove callback.
Link: https://lore.kernel.org/r/20210715075941.23332-79-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/drivers')
-rw-r--r-- | sound/drivers/dummy.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 01a3eab50d7b..2a7fc49c1a7c 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -1025,8 +1025,8 @@ static int snd_dummy_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_dummy), &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_dummy), &card); if (err < 0) return err; dummy = card->private_data; @@ -1047,7 +1047,7 @@ static int snd_dummy_probe(struct platform_device *devptr) pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]); if (err < 0) - goto __nodev; + return err; } dummy->pcm_hw = dummy_pcm_hardware; @@ -1078,7 +1078,7 @@ static int snd_dummy_probe(struct platform_device *devptr) err = snd_card_dummy_new_mixer(dummy); if (err < 0) - goto __nodev; + return err; strcpy(card->driver, "Dummy"); strcpy(card->shortname, "Dummy"); sprintf(card->longname, "Dummy %i", dev + 1); @@ -1086,18 +1086,9 @@ static int snd_dummy_probe(struct platform_device *devptr) dummy_proc_init(dummy); err = snd_card_register(card); - if (err == 0) { - platform_set_drvdata(devptr, card); - return 0; - } - __nodev: - snd_card_free(card); - return err; -} - -static int snd_dummy_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); + if (err < 0) + return err; + platform_set_drvdata(devptr, card); return 0; } @@ -1128,7 +1119,6 @@ static SIMPLE_DEV_PM_OPS(snd_dummy_pm, snd_dummy_suspend, snd_dummy_resume); static struct platform_driver snd_dummy_driver = { .probe = snd_dummy_probe, - .remove = snd_dummy_remove, .driver = { .name = SND_DUMMY_DRIVER, .pm = SND_DUMMY_PM_OPS, |