Skip to content

Commit

Permalink
ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()
Browse files Browse the repository at this point in the history
Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
elfring authored and tiwai committed Aug 22, 2017
1 parent e8a91ae commit 2cded8c
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions sound/drivers/pcsp/pcsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,32 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
return err;

err = snd_pcsp_create(card);
if (err < 0) {
snd_card_free(card);
return err;
}
if (err < 0)
goto free_card;

if (!nopcm) {
err = snd_pcsp_new_pcm(&pcsp_chip);
if (err < 0) {
snd_card_free(card);
return err;
}
if (err < 0)
goto free_card;
}
err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
if (err < 0) {
snd_card_free(card);
return err;
}
if (err < 0)
goto free_card;

strcpy(card->driver, "PC-Speaker");
strcpy(card->shortname, "pcsp");
sprintf(card->longname, "Internal PC-Speaker at port 0x%x",
pcsp_chip.port);

err = snd_card_register(card);
if (err < 0) {
snd_card_free(card);
return err;
}
if (err < 0)
goto free_card;

return 0;

free_card:
snd_card_free(card);
return err;
}

static int alsa_card_pcsp_init(struct device *dev)
Expand Down

0 comments on commit 2cded8c

Please sign in to comment.