@@ -1347,7 +1347,6 @@ static int snd_cs4281_create(struct snd_card *card,
int dual_codec)
{
struct cs4281 *chip;
- unsigned int tmp;
int err;
static struct snd_device_ops ops = {
.dev_free = snd_cs4281_dev_free,
@@ -1359,8 +1358,8 @@ static int snd_cs4281_create(struct snd_card *card,
return err;
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (chip == NULL) {
- pci_disable_device(pci);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto disable_device;
}
spin_lock_init(&chip->reg_lock);
chip->card = card;
@@ -1376,43 +1375,45 @@ static int snd_cs4281_create(struct snd_card *card,
err = pci_request_regions(pci, "CS4281");
if (err < 0) {
kfree(chip);
- pci_disable_device(pci);
- return err;
+ goto disable_device;
}
chip->ba0_addr = pci_resource_start(pci, 0);
chip->ba1_addr = pci_resource_start(pci, 1);
chip->ba0 = pci_ioremap_bar(pci, 0);
chip->ba1 = pci_ioremap_bar(pci, 1);
- if (!chip->ba0 || !chip->ba1) {
- snd_cs4281_free(chip);
- return -ENOMEM;
- }
+ if (!chip->ba0 || !chip->ba1)
+ goto e_nomem;
if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED,
KBUILD_MODNAME, chip)) {
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
- snd_cs4281_free(chip);
- return -ENOMEM;
+ goto e_nomem;
}
chip->irq = pci->irq;
- tmp = snd_cs4281_chip_init(chip);
- if (tmp) {
- snd_cs4281_free(chip);
- return tmp;
- }
+ err = snd_cs4281_chip_init(chip);
+ if (err)
+ goto free_sound_chip;
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
- if (err < 0) {
- snd_cs4281_free(chip);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
snd_cs4281_proc_init(chip);
*rchip = chip;
return 0;
+
+disable_device:
+ pci_disable_device(pci);
+ return err;
+
+e_nomem:
+ err = -ENOMEM;
+free_sound_chip:
+ snd_cs4281_free(chip);
+ return err;
}
static int snd_cs4281_chip_init(struct cs4281 *chip)