Skip to content

Commit

Permalink
ALSA: dummy: 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 b072e65 commit ed16a22
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions sound/drivers/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1078,26 +1078,17 @@ 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);

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;
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ed16a22

Please sign in to comment.