Commit 3e7fb9f7 authored by Takashi Iwai's avatar Takashi Iwai Committed by Takashi Iwai

ALSA: Return proper error code at probe in sound/isa/*

Some drivers in sound/isa/* don't handle the error code properly
from snd_card_create().  This patch fixes these places.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d453379b
......@@ -382,7 +382,7 @@ static void snd_card_cs4236_free(struct snd_card *card)
release_and_free_resource(acard->res_sb_port);
}
static struct snd_card *snd_cs423x_card_new(int dev)
static int snd_cs423x_card_new(int dev, struct snd_card **cardp)
{
struct snd_card *card;
int err;
......@@ -390,9 +390,10 @@ static struct snd_card *snd_cs423x_card_new(int dev)
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_card_cs4236), &card);
if (err < 0)
return NULL;
return err;
card->private_free = snd_card_cs4236_free;
return card;
*cardp = card;
return 0;
}
static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
......@@ -513,9 +514,9 @@ static int __devinit snd_cs423x_isa_probe(struct device *pdev,
struct snd_card *card;
int err;
card = snd_cs423x_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_cs423x_card_new(dev, &card);
if (err < 0)
return err;
snd_card_set_dev(card, pdev);
if ((err = snd_cs423x_probe(card, dev)) < 0) {
snd_card_free(card);
......@@ -595,9 +596,9 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_cs423x_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_cs423x_card_new(dev, &card);
if (err < 0)
return err;
if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) {
printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n");
snd_card_free(card);
......@@ -657,9 +658,9 @@ static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_cs423x_card_new(dev);
if (! card)
return -ENOMEM;
res = snd_cs423x_card_new(dev, &card);
if (res < 0)
return res;
if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) {
printk(KERN_ERR "isapnp detection failed and probing for " IDENT
" is not supported\n");
......
......@@ -2125,13 +2125,10 @@ static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard,
#define is_isapnp_selected(dev) 0
#endif
static struct snd_card *snd_es18xx_card_new(int dev)
static int snd_es18xx_card_new(int dev, struct snd_card **cardp)
{
struct snd_card *card;
if (snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_audiodrive), &card) < 0)
return NULL;
return card;
return snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_audiodrive), cardp);
}
static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
......@@ -2200,9 +2197,9 @@ static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr)
struct snd_card *card;
int err;
card = snd_es18xx_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_es18xx_card_new(dev, &card);
if (err < 0)
return err;
snd_card_set_dev(card, devptr);
if ((err = snd_audiodrive_probe(card, dev)) < 0) {
snd_card_free(card);
......@@ -2306,9 +2303,9 @@ static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_es18xx_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_es18xx_card_new(dev, &card);
if (err < 0)
return err;
if ((err = snd_audiodrive_pnp(dev, card->private_data, pdev)) < 0) {
snd_card_free(card);
return err;
......@@ -2365,9 +2362,9 @@ static int __devinit snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_es18xx_card_new(dev);
if (! card)
return -ENOMEM;
res = snd_es18xx_card_new(dev, &card);
if (res < 0)
return res;
if ((res = snd_audiodrive_pnpc(dev, card->private_data, pcard, pid)) < 0) {
snd_card_free(card);
......
......@@ -626,7 +626,7 @@ static void snd_interwave_free(struct snd_card *card)
free_irq(iwcard->irq, (void *)iwcard);
}
static struct snd_card *snd_interwave_card_new(int dev)
static int snd_interwave_card_new(int dev, struct snd_card **cardp)
{
struct snd_card *card;
struct snd_interwave *iwcard;
......@@ -635,12 +635,13 @@ static struct snd_card *snd_interwave_card_new(int dev)
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_interwave), &card);
if (err < 0)
return NULL;
return err;
iwcard = card->private_data;
iwcard->card = card;
iwcard->irq = -1;
card->private_free = snd_interwave_free;
return card;
*cardp = card;
return 0;
}
static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
......@@ -779,9 +780,9 @@ static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr)
struct snd_card *card;
int err;
card = snd_interwave_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_interwave_card_new(dev, &card);
if (err < 0)
return err;
snd_card_set_dev(card, devptr);
if ((err = snd_interwave_probe(card, dev)) < 0) {
......@@ -877,9 +878,9 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_interwave_card_new(dev);
if (! card)
return -ENOMEM;
res = snd_interwave_card_new(dev, &card);
if (res < 0)
return res;
if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) {
snd_card_free(card);
......
......@@ -830,17 +830,17 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
return snd_card_register(card);
}
static struct snd_card *snd_opti9xx_card_new(void)
static int snd_opti9xx_card_new(struct snd_card **cardp)
{
struct snd_card *card;
int err;
err = snd_card_create(index, id, THIS_MODULE,
sizeof(struct snd_opti9xx), &card);
if (err < 0)
return NULL;
return err;
card->private_free = snd_card_opti9xx_free;
return card;
*cardp = card;
return 0;
}
static int __devinit snd_opti9xx_isa_match(struct device *devptr,
......@@ -905,9 +905,9 @@ static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
}
#endif
card = snd_opti9xx_card_new();
if (! card)
return -ENOMEM;
error = snd_opti9xx_card_new(&card);
if (error < 0)
return error;
if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) {
snd_card_free(card);
......@@ -952,9 +952,9 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
return -EBUSY;
if (! isapnp)
return -ENODEV;
card = snd_opti9xx_card_new();
if (! card)
return -ENOMEM;
error = snd_opti9xx_card_new(&card);
if (error < 0)
return error;
chip = card->private_data;
hw = snd_card_opti9xx_pnp(chip, pcard, pid);
......
......@@ -324,7 +324,7 @@ static void snd_sb16_free(struct snd_card *card)
#define is_isapnp_selected(dev) 0
#endif
static struct snd_card *snd_sb16_card_new(int dev)
static int snd_sb16_card_new(int dev, struct snd_card **cardp)
{
struct snd_card *card;
int err;
......@@ -332,9 +332,10 @@ static struct snd_card *snd_sb16_card_new(int dev)
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_card_sb16), &card);
if (err < 0)
return NULL;
return err;
card->private_free = snd_sb16_free;
return card;
*cardp = card;
return 0;
}
static int __devinit snd_sb16_probe(struct snd_card *card, int dev)
......@@ -492,9 +493,9 @@ static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
struct snd_card *card;
int err;
card = snd_sb16_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_sb16_card_new(dev, &card);
if (err < 0)
return err;
acard = card->private_data;
/* non-PnP FM port address is hardwired with base port address */
......@@ -613,9 +614,9 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
for ( ; dev < SNDRV_CARDS; dev++) {
if (!enable[dev] || !isapnp[dev])
continue;
card = snd_sb16_card_new(dev);
if (! card)
return -ENOMEM;
res = snd_sb16_card_new(dev, &card);
if (res < 0)
return res;
snd_card_set_dev(card, &pcard->card->dev);
if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 ||
(res = snd_sb16_probe(card, dev)) < 0) {
......
......@@ -338,7 +338,7 @@ snd_wavefront_free(struct snd_card *card)
}
}
static struct snd_card *snd_wavefront_card_new(int dev)
static int snd_wavefront_card_new(int dev, struct snd_card **cardp)
{
struct snd_card *card;
snd_wavefront_card_t *acard;
......@@ -347,7 +347,7 @@ static struct snd_card *snd_wavefront_card_new(int dev)
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
sizeof(snd_wavefront_card_t), &card);
if (err < 0)
return NULL;
return err;
acard = card->private_data;
acard->wavefront.irq = -1;
......@@ -358,7 +358,8 @@ static struct snd_card *snd_wavefront_card_new(int dev)
acard->wavefront.card = card;
card->private_free = snd_wavefront_free;
return card;
*cardp = card;
return 0;
}
static int __devinit
......@@ -568,9 +569,9 @@ static int __devinit snd_wavefront_isa_probe(struct device *pdev,
struct snd_card *card;
int err;
card = snd_wavefront_card_new(dev);
if (! card)
return -ENOMEM;
err = snd_wavefront_card_new(dev, &card);
if (err < 0)
return err;
snd_card_set_dev(card, pdev);
if ((err = snd_wavefront_probe(card, dev)) < 0) {
snd_card_free(card);
......@@ -617,9 +618,9 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
if (dev >= SNDRV_CARDS)
return -ENODEV;
card = snd_wavefront_card_new(dev);
if (! card)
return -ENOMEM;
res = snd_wavefront_card_new(dev, &card);
if (res < 0)
return res;
if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
......
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