Commit ba2186e4 authored by Markus Elfring's avatar Markus Elfring Committed by Takashi Iwai

ALSA: ymfpci: Use common error handling code in snd_ymfpci_create()

* 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.

* The script "checkpatch.pl" pointed information out like the following.

  ERROR: do not use assignment in if condition

  Thus fix a few source code places.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 1f5ca8ec
...@@ -2399,59 +2399,60 @@ int snd_ymfpci_create(struct snd_card *card, ...@@ -2399,59 +2399,60 @@ int snd_ymfpci_create(struct snd_card *card,
dev_err(chip->card->dev, dev_err(chip->card->dev,
"unable to grab memory region 0x%lx-0x%lx\n", "unable to grab memory region 0x%lx-0x%lx\n",
chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1);
snd_ymfpci_free(chip); err = -EBUSY;
return -EBUSY; goto free_chip;
} }
if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED,
KBUILD_MODNAME, chip)) { KBUILD_MODNAME, chip)) {
dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
snd_ymfpci_free(chip); err = -EBUSY;
return -EBUSY; goto free_chip;
} }
chip->irq = pci->irq; chip->irq = pci->irq;
snd_ymfpci_aclink_reset(pci); snd_ymfpci_aclink_reset(pci);
if (snd_ymfpci_codec_ready(chip, 0) < 0) { if (snd_ymfpci_codec_ready(chip, 0) < 0) {
snd_ymfpci_free(chip); err = -EIO;
return -EIO; goto free_chip;
} }
err = snd_ymfpci_request_firmware(chip); err = snd_ymfpci_request_firmware(chip);
if (err < 0) { if (err < 0) {
dev_err(chip->card->dev, "firmware request failed: %d\n", err); dev_err(chip->card->dev, "firmware request failed: %d\n", err);
snd_ymfpci_free(chip); goto free_chip;
return err;
} }
snd_ymfpci_download_image(chip); snd_ymfpci_download_image(chip);
udelay(100); /* seems we need a delay after downloading image.. */ udelay(100); /* seems we need a delay after downloading image.. */
if (snd_ymfpci_memalloc(chip) < 0) { if (snd_ymfpci_memalloc(chip) < 0) {
snd_ymfpci_free(chip); err = -EIO;
return -EIO; goto free_chip;
} }
if ((err = snd_ymfpci_ac3_init(chip)) < 0) { err = snd_ymfpci_ac3_init(chip);
snd_ymfpci_free(chip); if (err < 0)
return err; goto free_chip;
}
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32), chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32),
GFP_KERNEL); GFP_KERNEL);
if (chip->saved_regs == NULL) { if (chip->saved_regs == NULL) {
snd_ymfpci_free(chip); err = -ENOMEM;
return -ENOMEM; goto free_chip;
} }
#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_ymfpci_free(chip); if (err < 0)
return err; goto free_chip;
}
snd_ymfpci_proc_init(card, chip); snd_ymfpci_proc_init(card, chip);
*rchip = chip; *rchip = chip;
return 0; return 0;
free_chip:
snd_ymfpci_free(chip);
return err;
} }
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