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>
This commit is contained in:
parent
854577ac2a
commit
ed539fc342
|
@ -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,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue