Commit 468778a0 authored by Markus Elfring's avatar Markus Elfring Committed by Takashi Iwai

ALSA: maestro3: Use common error handling code in two functions

Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ee5f38a4
...@@ -2622,22 +2622,18 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2622,22 +2622,18 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
err = request_firmware(&chip->assp_kernel_image, err = request_firmware(&chip->assp_kernel_image,
"ess/maestro3_assp_kernel.fw", &pci->dev); "ess/maestro3_assp_kernel.fw", &pci->dev);
if (err < 0) { if (err < 0)
snd_m3_free(chip); goto free_chip;
return err;
}
err = request_firmware(&chip->assp_minisrc_image, err = request_firmware(&chip->assp_minisrc_image,
"ess/maestro3_assp_minisrc.fw", &pci->dev); "ess/maestro3_assp_minisrc.fw", &pci->dev);
if (err < 0) { if (err < 0)
snd_m3_free(chip); goto free_chip;
return err;
} err = pci_request_regions(pci, card->driver);
if (err < 0)
goto free_chip;
if ((err = pci_request_regions(pci, card->driver)) < 0) {
snd_m3_free(chip);
return err;
}
chip->iobase = pci_resource_start(pci, 0); chip->iobase = pci_resource_start(pci, 0);
/* just to be sure */ /* just to be sure */
...@@ -2655,8 +2651,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2655,8 +2651,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED,
KBUILD_MODNAME, chip)) { KBUILD_MODNAME, chip)) {
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
snd_m3_free(chip); err = -ENOMEM;
return -ENOMEM; goto free_chip;
} }
chip->irq = pci->irq; chip->irq = pci->irq;
...@@ -2666,10 +2662,9 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2666,10 +2662,9 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
dev_warn(card->dev, "can't allocate apm buffer\n"); dev_warn(card->dev, "can't allocate apm buffer\n");
#endif #endif
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
snd_m3_free(chip); if (err < 0)
return err; goto free_chip;
}
if ((err = snd_m3_mixer(chip)) < 0) if ((err = snd_m3_mixer(chip)) < 0)
return err; return err;
...@@ -2699,6 +2694,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2699,6 +2694,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
*chip_ret = chip; *chip_ret = chip;
return 0; return 0;
free_chip:
snd_m3_free(chip);
return err;
} }
/* /*
...@@ -2741,23 +2740,19 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) ...@@ -2741,23 +2740,19 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
break; break;
} }
if ((err = snd_m3_create(card, pci, err = snd_m3_create(card, pci, external_amp[dev], amp_gpio[dev], &chip);
external_amp[dev], if (err < 0)
amp_gpio[dev], goto free_card;
&chip)) < 0) {
snd_card_free(card);
return err;
}
card->private_data = chip; card->private_data = chip;
sprintf(card->shortname, "ESS %s PCI", card->driver); sprintf(card->shortname, "ESS %s PCI", card->driver);
sprintf(card->longname, "%s at 0x%lx, irq %d", sprintf(card->longname, "%s at 0x%lx, irq %d",
card->shortname, chip->iobase, chip->irq); card->shortname, chip->iobase, chip->irq);
if ((err = snd_card_register(card)) < 0) { err = snd_card_register(card);
snd_card_free(card); if (err < 0)
return err; goto free_card;
}
#if 0 /* TODO: not supported yet */ #if 0 /* TODO: not supported yet */
/* TODO enable MIDI IRQ and I/O */ /* TODO enable MIDI IRQ and I/O */
...@@ -2772,6 +2767,10 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) ...@@ -2772,6 +2767,10 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
pci_set_drvdata(pci, card); pci_set_drvdata(pci, card);
dev++; dev++;
return 0; return 0;
free_card:
snd_card_free(card);
return err;
} }
static void snd_m3_remove(struct pci_dev *pci) static void snd_m3_remove(struct pci_dev *pci)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment