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