Skip to content

Commit

Permalink
ALSA: aloop: Allocate resources with device-managed APIs
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jul 19, 2021
1 parent de74763 commit b072e65
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions sound/drivers/aloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1712,8 +1712,8 @@ static int loopback_probe(struct platform_device *devptr)
int dev = devptr->id;
int err;

err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
sizeof(struct loopback), &card);
err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
sizeof(struct loopback), &card);
if (err < 0)
return err;
loopback = card->private_data;
Expand All @@ -1730,32 +1730,23 @@ static int loopback_probe(struct platform_device *devptr)

err = loopback_pcm_new(loopback, 0, pcm_substreams[dev]);
if (err < 0)
goto __nodev;
return err;
err = loopback_pcm_new(loopback, 1, pcm_substreams[dev]);
if (err < 0)
goto __nodev;
return err;
err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0);
if (err < 0)
goto __nodev;
return err;
loopback_cable_proc_new(loopback, 0);
loopback_cable_proc_new(loopback, 1);
loopback_timer_source_proc_new(loopback);
strcpy(card->driver, "Loopback");
strcpy(card->shortname, "Loopback");
sprintf(card->longname, "Loopback %i", dev + 1);
err = snd_card_register(card);
if (!err) {
platform_set_drvdata(devptr, card);
return 0;
}
__nodev:
snd_card_free(card);
return err;
}

static int loopback_remove(struct platform_device *devptr)
{
snd_card_free(platform_get_drvdata(devptr));
if (err < 0)
return err;
platform_set_drvdata(devptr, card);
return 0;
}

Expand Down Expand Up @@ -1786,7 +1777,6 @@ static SIMPLE_DEV_PM_OPS(loopback_pm, loopback_suspend, loopback_resume);

static struct platform_driver loopback_driver = {
.probe = loopback_probe,
.remove = loopback_remove,
.driver = {
.name = SND_LOOPBACK_DRIVER,
.pm = LOOPBACK_PM_OPS,
Expand Down

0 comments on commit b072e65

Please sign in to comment.