From 53fb1e63599438bd5f6fbb852023d80916d83983 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:32:08 +0100 Subject: ALSA: Introduce snd_card_create() Introduced snd_card_create() function as a replacement of snd_card_new(). The new function returns a negative error code so that the probe callback can return the proper error code, while snd_card_new() can give only NULL check. The old snd_card_new() is still provided as an inline function but with __deprecated attribute. It'll be removed soon later. Signed-off-by: Takashi Iwai --- include/sound/core.h | 14 +++++++++++++- sound/core/init.c | 47 +++++++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index f632484..25420c3 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -296,8 +296,20 @@ int snd_card_locked(int card); extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd); #endif +int snd_card_create(int idx, const char *id, + struct module *module, int extra_size, + struct snd_card **card_ret); + +static inline __deprecated struct snd_card *snd_card_new(int idx, const char *id, - struct module *module, int extra_size); + struct module *module, int extra_size) +{ + struct snd_card *card; + if (snd_card_create(idx, id, module, extra_size, &card) < 0) + return NULL; + return card; +} + int snd_card_disconnect(struct snd_card *card); int snd_card_free(struct snd_card *card); int snd_card_free_when_closed(struct snd_card *card); diff --git a/sound/core/init.c b/sound/core/init.c index 0d5520c..dc4b80c 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -121,31 +121,44 @@ static inline int init_info_for_card(struct snd_card *card) #endif /** - * snd_card_new - create and initialize a soundcard structure + * snd_card_create - create and initialize a soundcard structure * @idx: card index (address) [0 ... (SNDRV_CARDS-1)] * @xid: card identification (ASCII string) * @module: top level module for locking * @extra_size: allocate this extra size after the main soundcard structure + * @card_ret: the pointer to store the created card instance * * Creates and initializes a soundcard structure. * - * Returns kmallocated snd_card structure. Creates the ALSA control interface - * (which is blocked until snd_card_register function is called). + * The function allocates snd_card instance via kzalloc with the given + * space for the driver to use freely. The allocated struct is stored + * in the given card_ret pointer. + * + * Returns zero if successful or a negative error code. */ -struct snd_card *snd_card_new(int idx, const char *xid, - struct module *module, int extra_size) +int snd_card_create(int idx, const char *xid, + struct module *module, int extra_size, + struct snd_card **card_ret) { struct snd_card *card; int err, idx2; + if (snd_BUG_ON(!card_ret)) + return -EINVAL; + *card_ret = NULL; + if (extra_size < 0) extra_size = 0; card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); - if (card == NULL) - return NULL; + if (!card) + return -ENOMEM; if (xid) { - if (!snd_info_check_reserved_words(xid)) + if (!snd_info_check_reserved_words(xid)) { + snd_printk(KERN_ERR + "given id string '%s' is reserved.\n", xid); + err = -EBUSY; goto __error; + } strlcpy(card->id, xid, sizeof(card->id)); } err = 0; @@ -202,26 +215,28 @@ struct snd_card *snd_card_new(int idx, const char *xid, #endif /* the control interface cannot be accessed from the user space until */ /* snd_cards_bitmask and snd_cards are set with snd_card_register */ - if ((err = snd_ctl_create(card)) < 0) { - snd_printd("unable to register control minors\n"); + err = snd_ctl_create(card); + if (err < 0) { + snd_printk(KERN_ERR "unable to register control minors\n"); goto __error; } - if ((err = snd_info_card_create(card)) < 0) { - snd_printd("unable to create card info\n"); + err = snd_info_card_create(card); + if (err < 0) { + snd_printk(KERN_ERR "unable to create card info\n"); goto __error_ctl; } if (extra_size > 0) card->private_data = (char *)card + sizeof(struct snd_card); - return card; + *card_ret = card; + return 0; __error_ctl: snd_device_free_all(card, SNDRV_DEV_CMD_PRE); __error: kfree(card); - return NULL; + return err; } - -EXPORT_SYMBOL(snd_card_new); +EXPORT_SYMBOL(snd_card_create); /* return non-zero if a card is already locked */ int snd_card_locked(int card) -- cgit v1.1 From c95eadd2f1afd2ba643e85a8dfc9079a3f03ae47 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:43:35 +0100 Subject: ALSA: Convert to snd_card_create() in sound/isa/* Convert from snd_card_new() to the new snd_card_create() function. Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a.c | 7 ++++--- sound/isa/ad1848/ad1848.c | 6 +++--- sound/isa/adlib.c | 6 +++--- sound/isa/als100.c | 7 ++++--- sound/isa/azt2320.c | 7 ++++--- sound/isa/cmi8330.c | 26 ++++++++++++++------------ sound/isa/cs423x/cs4231.c | 6 +++--- sound/isa/cs423x/cs4236.c | 7 ++++--- sound/isa/dt019x.c | 7 ++++--- sound/isa/es1688/es1688.c | 6 +++--- sound/isa/es18xx.c | 7 +++++-- sound/isa/gus/gusclassic.c | 6 +++--- sound/isa/gus/gusextreme.c | 6 +++--- sound/isa/gus/gusmax.c | 8 ++++---- sound/isa/gus/interwave.c | 7 ++++--- sound/isa/opl3sa2.c | 31 +++++++++++++++++-------------- sound/isa/opti9xx/miro.c | 7 ++++--- sound/isa/opti9xx/opti92x-ad1848.c | 6 ++++-- sound/isa/sb/es968.c | 7 ++++--- sound/isa/sb/sb16.c | 9 ++++++--- sound/isa/sb/sb8.c | 8 ++++---- sound/isa/sc6000.c | 6 +++--- sound/isa/sgalaxy.c | 6 +++--- sound/isa/sscape.c | 16 ++++++++-------- sound/isa/wavefront/wavefront.c | 7 ++++--- 25 files changed, 122 insertions(+), 100 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 7752424..9660e59 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -157,9 +157,10 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard struct snd_ad1816a *chip; struct snd_opl3 *opl3; - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_ad1816a))) == NULL) - return -ENOMEM; + error = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_ad1816a), &card); + if (error < 0) + return error; acard = (struct snd_card_ad1816a *)card->private_data; if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) { diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 223a6c0..4beeb6f 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -91,9 +91,9 @@ static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n) struct snd_pcm *pcm; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) - return -EINVAL; + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) + return error; error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], -1, thinkpad[n] ? WSS_HW_THINKPAD : WSS_HW_DETECT, diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c index 374b717..7465ae0 100644 --- a/sound/isa/adlib.c +++ b/sound/isa/adlib.c @@ -53,10 +53,10 @@ static int __devinit snd_adlib_probe(struct device *dev, unsigned int n) struct snd_opl3 *opl3; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) { + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) { dev_err(dev, "could not create card\n"); - return -EINVAL; + return error; } card->private_data = request_region(port[n], 4, CRD_NAME); diff --git a/sound/isa/als100.c b/sound/isa/als100.c index f1ce30f..5fd52e4 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -163,9 +163,10 @@ static int __devinit snd_card_als100_probe(int dev, struct snd_card_als100 *acard; struct snd_opl3 *opl3; - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_als100))) == NULL) - return -ENOMEM; + error = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_als100), &card); + if (error < 0) + return error; acard = card->private_data; if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index 3e74d1a..f7aa637 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -184,9 +184,10 @@ static int __devinit snd_card_azt2320_probe(int dev, struct snd_wss *chip; struct snd_opl3 *opl3; - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_azt2320))) == NULL) - return -ENOMEM; + error = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_azt2320), &card); + if (error < 0) + return error; acard = (struct snd_card_azt2320 *)card->private_data; if ((error = snd_card_azt2320_pnp(dev, acard, pcard, pid))) { diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index e49aec7..24e6090 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -467,20 +467,22 @@ static int snd_cmi8330_resume(struct snd_card *card) #define PFX "cmi8330: " -static struct snd_card *snd_cmi8330_card_new(int dev) +static int snd_cmi8330_card_new(int dev, struct snd_card **cardp) { struct snd_card *card; struct snd_cmi8330 *acard; + int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_cmi8330)); - if (card == NULL) { + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_cmi8330), &card); + if (err < 0) { snd_printk(KERN_ERR PFX "could not get a new card\n"); - return NULL; + return err; } acard = card->private_data; acard->card = card; - return card; + *cardp = card; + return 0; } static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) @@ -564,9 +566,9 @@ static int __devinit snd_cmi8330_isa_probe(struct device *pdev, struct snd_card *card; int err; - card = snd_cmi8330_card_new(dev); - if (! card) - return -ENOMEM; + err = snd_cmi8330_card_new(dev, &card); + if (err < 0) + return err; snd_card_set_dev(card, pdev); if ((err = snd_cmi8330_probe(card, dev)) < 0) { snd_card_free(card); @@ -628,9 +630,9 @@ static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, if (dev >= SNDRV_CARDS) return -ENODEV; - card = snd_cmi8330_card_new(dev); - if (! card) - return -ENOMEM; + res = snd_cmi8330_card_new(dev, &card); + if (res < 0) + return res; if ((res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid)) < 0) { snd_printk(KERN_ERR PFX "PnP detection failed\n"); snd_card_free(card); diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index f019d44..cb9153e 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -95,9 +95,9 @@ static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n) struct snd_pcm *pcm; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) - return -EINVAL; + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) + return error; error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], dma2[n], WSS_HW_DETECT, 0, &chip); diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 019c940..db83068 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -385,10 +385,11 @@ static void snd_card_cs4236_free(struct snd_card *card) static struct snd_card *snd_cs423x_card_new(int dev) { struct snd_card *card; + int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_cs4236)); - if (card == NULL) + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_cs4236), &card); + if (err < 0) return NULL; card->private_free = snd_card_cs4236_free; return card; diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c index a0242c3..80f5b1a 100644 --- a/sound/isa/dt019x.c +++ b/sound/isa/dt019x.c @@ -150,9 +150,10 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, struct snd_card_dt019x *acard; struct snd_opl3 *opl3; - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_dt019x))) == NULL) - return -ENOMEM; + error = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_dt019x), &card); + if (error < 0) + return error; acard = card->private_data; snd_card_set_dev(card, &pcard->card->dev); diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index b463771..d746750 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -122,9 +122,9 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n) struct snd_pcm *pcm; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) - return -EINVAL; + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) + return error; error = snd_es1688_legacy_create(card, dev, n, &chip); if (error < 0) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 90498e4..c24c632 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -2127,8 +2127,11 @@ static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, static struct snd_card *snd_es18xx_card_new(int dev) { - return snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_audiodrive)); + struct snd_card *card; + if (snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_audiodrive), &card) < 0) + return NULL; + return card; } static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 426532a..086b8f0 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -148,9 +148,9 @@ static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n) struct snd_gus_card *gus; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) - return -EINVAL; + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) + return error; if (pcm_channels[n] < 2) pcm_channels[n] = 2; diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 7ad4c3b..180a8de 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -241,9 +241,9 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n) struct snd_opl3 *opl3; int error; - card = snd_card_new(index[n], id[n], THIS_MODULE, 0); - if (!card) - return -EINVAL; + error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) + return error; if (mpu_port[n] == SNDRV_AUTO_PORT) mpu_port[n] = 0; diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index f94c197..f26eac8 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -214,10 +214,10 @@ static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev) struct snd_wss *wss; struct snd_gusmax *maxcard; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_gusmax)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_gusmax), &card); + if (err < 0) + return err; card->private_free = snd_gusmax_free; maxcard = (struct snd_gusmax *)card->private_data; maxcard->card = card; diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 5faecfb..e040c76 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -630,10 +630,11 @@ static struct snd_card *snd_interwave_card_new(int dev) { struct snd_card *card; struct snd_interwave *iwcard; + int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_interwave)); - if (card == NULL) + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_interwave), &card); + if (err < 0) return NULL; iwcard = card->private_data; iwcard->card = card; diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 58c972b..645491a 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -617,21 +617,24 @@ static void snd_opl3sa2_free(struct snd_card *card) release_and_free_resource(chip->res_port); } -static struct snd_card *snd_opl3sa2_card_new(int dev) +static int snd_opl3sa2_card_new(int dev, struct snd_card **cardp) { struct snd_card *card; struct snd_opl3sa2 *chip; + int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_opl3sa2)); - if (card == NULL) - return NULL; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_opl3sa2), &card); + if (err < 0) + return err; strcpy(card->driver, "OPL3SA2"); strcpy(card->shortname, "Yamaha OPL3-SA2"); chip = card->private_data; spin_lock_init(&chip->reg_lock); chip->irq = -1; card->private_free = snd_opl3sa2_free; - return card; + *cardp = card; + return 0; } static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev) @@ -723,9 +726,9 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, if (dev >= SNDRV_CARDS) return -ENODEV; - card = snd_opl3sa2_card_new(dev); - if (! card) - return -ENOMEM; + err = snd_opl3sa2_card_new(dev, &card); + if (err < 0) + return err; if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { snd_card_free(card); return err; @@ -789,9 +792,9 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, if (dev >= SNDRV_CARDS) return -ENODEV; - card = snd_opl3sa2_card_new(dev); - if (! card) - return -ENOMEM; + err = snd_opl3sa2_card_new(dev, &card); + if (err < 0) + return err; if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { snd_card_free(card); return err; @@ -870,9 +873,9 @@ static int __devinit snd_opl3sa2_isa_probe(struct device *pdev, struct snd_card *card; int err; - card = snd_opl3sa2_card_new(dev); - if (! card) - return -ENOMEM; + err = snd_opl3sa2_card_new(dev, &card); + if (err < 0) + return err; snd_card_set_dev(card, pdev); if ((err = snd_opl3sa2_probe(card, dev)) < 0) { snd_card_free(card); diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 440755c..02e30d7 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -1228,9 +1228,10 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) struct snd_pcm *pcm; struct snd_rawmidi *rmidi; - if (!(card = snd_card_new(index, id, THIS_MODULE, - sizeof(struct snd_miro)))) - return -ENOMEM; + error = snd_card_create(index, id, THIS_MODULE, + sizeof(struct snd_miro), &card); + if (error < 0) + return error; card->private_free = snd_card_miro_free; miro = card->private_data; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 19706b0..5750f38 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -833,9 +833,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) static struct snd_card *snd_opti9xx_card_new(void) { struct snd_card *card; + int err; - card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx)); - if (! card) + err = snd_card_create(index, id, THIS_MODULE, + sizeof(struct snd_opti9xx), &card); + if (err < 0) return NULL; card->private_free = snd_card_opti9xx_free; return card; diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c index c8c8e21..cafc3a7 100644 --- a/sound/isa/sb/es968.c +++ b/sound/isa/sb/es968.c @@ -108,9 +108,10 @@ static int __devinit snd_card_es968_probe(int dev, struct snd_card *card; struct snd_card_es968 *acard; - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_es968))) == NULL) - return -ENOMEM; + error = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_es968), &card); + if (error < 0) + return error; acard = card->private_data; if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { snd_card_free(card); diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 2c201f7..adf4fdd 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -326,9 +326,12 @@ static void snd_sb16_free(struct snd_card *card) static struct snd_card *snd_sb16_card_new(int dev) { - struct snd_card *card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_sb16)); - if (card == NULL) + struct snd_card *card; + int err; + + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_sb16), &card); + if (err < 0) return NULL; card->private_free = snd_sb16_free; return card; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index ea06877..3cd57ee 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -103,10 +103,10 @@ static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev) struct snd_opl3 *opl3; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_sb8)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_sb8), &card); + if (err < 0) + return err; acard = card->private_data; card->private_free = snd_sb8_free; diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c index ca35924..7a14703 100644 --- a/sound/isa/sc6000.c +++ b/sound/isa/sc6000.c @@ -489,9 +489,9 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) char __iomem *vmss_port; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (!card) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if (xirq == SNDRV_AUTO_IRQ) { xirq = snd_legacy_find_free_irq(possible_irqs); diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 2c7503b..6fe27b9 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -243,9 +243,9 @@ static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) struct snd_card *card; struct snd_wss *chip; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 48a16d8..4025fb5 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -1357,10 +1357,10 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) struct soundscape *sscape; int ret; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct soundscape)); - if (!card) - return -ENOMEM; + ret = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct soundscape), &card); + if (ret < 0) + return ret; sscape = get_card_soundscape(card); sscape->type = SSCAPE; @@ -1462,10 +1462,10 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, * Create a new ALSA sound card entry, in anticipation * of detecting our hardware ... */ - card = snd_card_new(index[idx], id[idx], THIS_MODULE, - sizeof(struct soundscape)); - if (!card) - return -ENOMEM; + ret = snd_card_create(index[idx], id[idx], THIS_MODULE, + sizeof(struct soundscape), &card); + if (ret < 0) + return ret; sscape = get_card_soundscape(card); diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 4c095bc..82b8fb7 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -342,10 +342,11 @@ static struct snd_card *snd_wavefront_card_new(int dev) { struct snd_card *card; snd_wavefront_card_t *acard; + int err; - card = snd_card_new (index[dev], id[dev], THIS_MODULE, - sizeof(snd_wavefront_card_t)); - if (card == NULL) + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(snd_wavefront_card_t), &card); + if (err < 0) return NULL; acard = card->private_data; -- cgit v1.1 From e58de7baf7de11f01a675cbbf6ecc8a2758b9ca5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:44:30 +0100 Subject: ALSA: Convert to snd_card_create() in sound/pci/* Convert from snd_card_new() to the new snd_card_create() function in sound/pci/*. Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 6 +++--- sound/pci/ali5451/ali5451.c | 6 +++--- sound/pci/als300.c | 6 +++--- sound/pci/als4000.c | 9 +++++---- sound/pci/atiixp.c | 6 +++--- sound/pci/atiixp_modem.c | 6 +++--- sound/pci/au88x0/au88x0.c | 6 +++--- sound/pci/aw2/aw2-alsa.c | 6 +++--- sound/pci/azt3328.c | 6 +++--- sound/pci/bt87x.c | 6 +++--- sound/pci/ca0106/ca0106_main.c | 6 +++--- sound/pci/cmipci.c | 6 +++--- sound/pci/cs4281.c | 6 +++--- sound/pci/cs46xx/cs46xx.c | 6 +++--- sound/pci/cs5530.c | 6 +++--- sound/pci/cs5535audio/cs5535audio.c | 6 +++--- sound/pci/echoaudio/echoaudio.c | 6 +++--- sound/pci/emu10k1/emu10k1.c | 6 +++--- sound/pci/emu10k1/emu10k1x.c | 6 +++--- sound/pci/ens1370.c | 6 +++--- sound/pci/es1938.c | 6 +++--- sound/pci/es1968.c | 6 +++--- sound/pci/fm801.c | 6 +++--- sound/pci/hda/hda_intel.c | 6 +++--- sound/pci/ice1712/ice1712.c | 6 +++--- sound/pci/ice1712/ice1724.c | 6 +++--- sound/pci/intel8x0.c | 6 +++--- sound/pci/intel8x0m.c | 6 +++--- sound/pci/korg1212/korg1212.c | 6 +++--- sound/pci/maestro3.c | 6 +++--- sound/pci/mixart/mixart.c | 6 +++--- sound/pci/nm256/nm256.c | 6 +++--- sound/pci/oxygen/oxygen_lib.c | 8 ++++---- sound/pci/pcxhr/pcxhr.c | 6 +++--- sound/pci/riptide/riptide.c | 6 +++--- sound/pci/rme32.c | 7 ++++--- sound/pci/rme96.c | 7 ++++--- sound/pci/rme9652/hdsp.c | 6 ++++-- sound/pci/rme9652/hdspm.c | 8 ++++---- sound/pci/rme9652/rme9652.c | 8 ++++---- sound/pci/sis7019.c | 5 ++--- sound/pci/sonicvibes.c | 6 +++--- sound/pci/trident/trident.c | 6 +++--- sound/pci/via82xx.c | 6 +++--- sound/pci/via82xx_modem.c | 6 +++--- sound/pci/vx222/vx222.c | 6 +++--- sound/pci/ymfpci/ymfpci.c | 6 +++--- 47 files changed, 148 insertions(+), 144 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index a7f38e6..d1f242b 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -995,10 +995,10 @@ snd_ad1889_probe(struct pci_dev *pci, } /* (2) */ - card = snd_card_new(index[devno], id[devno], THIS_MODULE, 0); + err = snd_card_create(index[devno], id[devno], THIS_MODULE, 0, &card); /* XXX REVISIT: we can probably allocate chip in this call */ - if (card == NULL) - return -ENOMEM; + if (err < 0) + return err; strcpy(card->driver, "AD1889"); strcpy(card->shortname, "Analog Devices AD1889"); diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 1a0fd65..b36c551 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -2307,9 +2307,9 @@ static int __devinit snd_ali_probe(struct pci_dev *pci, snd_ali_printk("probe ...\n"); - card = snd_card_new(index, id, THIS_MODULE, 0); - if (!card) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_ali_create(card, pci, pcm_channels, spdif, &codec); if (err < 0) diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 8df6824..f557c15 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -812,10 +812,10 @@ static int __devinit snd_als300_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); - if (card == NULL) - return -ENOMEM; + if (err < 0) + return err; chip_type = pci_id->driver_data; diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index ba57005..542a0c6 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -889,12 +889,13 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO); pci_set_master(pci); - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(*acard) /* private_data: acard */); - if (card == NULL) { + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(*acard) /* private_data: acard */, + &card); + if (err < 0) { pci_release_regions(pci); pci_disable_device(pci); - return -ENOMEM; + return err; } acard = card->private_data; diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 226fe82..9ce8548 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1645,9 +1645,9 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, struct atiixp *chip; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); strcpy(card->shortname, "ATI IXP"); diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 0e6e5cc..c3136cc 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1288,9 +1288,9 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, struct atiixp_modem *chip; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "ATIIXP-MODEM"); strcpy(card->shortname, "ATI IXP Modem"); diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index a36d4d1..9ec1223 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -250,9 +250,9 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return -ENOENT; } // (2) - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; // (3) if ((err = snd_vortex_create(card, pci, &chip)) < 0) { diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 3f00ddf..eefcbf6 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -368,9 +368,9 @@ static int __devinit snd_aw2_probe(struct pci_dev *pci, } /* (2) Create card instance */ - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; /* (3) Create main component */ err = snd_aw2_create(card, pci, &chip); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 333007c..1df96e7 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -2216,9 +2216,9 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "AZF3328"); strcpy(card->shortname, "Aztech AZF3328 (PCI168)"); diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 1aa1c04..a299340 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -888,9 +888,9 @@ static int __devinit snd_bt87x_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (!card) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_bt87x_create(card, pci, &chip); if (err < 0) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 0e62205..b116456 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1707,9 +1707,9 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_ca0106_create(dev, card, pci, &chip); if (err < 0) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 1a74ca6..c7899c3 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -3272,9 +3272,9 @@ static int __devinit snd_cmipci_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; switch (pci->device) { case PCI_DEVICE_ID_CMEDIA_CM8738: diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 192e784..b9b07f4 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1925,9 +1925,9 @@ static int __devinit snd_cs4281_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_cs4281_create(card, pci, &chip, dual_codec[dev])) < 0) { snd_card_free(card); diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index e876b32..c9b3e3d 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -88,9 +88,9 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_cs46xx_create(card, pci, external_amp[dev], thinkpad[dev], &chip)) < 0) { diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index 6dea5b5..dc46432 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c @@ -258,10 +258,10 @@ static int __devinit snd_cs5530_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); - if (card == NULL) - return -ENOMEM; + if (err < 0) + return err; err = snd_cs5530_create(card, pci, &chip); if (err < 0) { diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 826e6de..ac1d72e 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -353,9 +353,9 @@ static int __devinit snd_cs5535audio_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0) goto probefail_out; diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 8dbc5c4..9d015a7 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1997,9 +1997,9 @@ static int __devinit snd_echo_probe(struct pci_dev *pci, DE_INIT(("Echoaudio driver starting...\n")); i = 0; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; snd_card_set_dev(card, &pci->dev); diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 8354c1a..c7f3b99 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -114,9 +114,9 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if (max_buffer_size[dev] < 32) max_buffer_size[dev] = 32; else if (max_buffer_size[dev] > 1024) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 5ff4dbb..31542ad 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -1544,9 +1544,9 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_emu10k1x_create(card, pci, &chip)) < 0) { snd_card_free(card); diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 9bf9536..e00614c 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -2409,9 +2409,9 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_ensoniq_create(card, pci, &ensoniq)) < 0) { snd_card_free(card); diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 4cd9a1f..34a78af 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1799,9 +1799,9 @@ static int __devinit snd_es1938_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; for (idx = 0; idx < 5; idx++) { if (pci_resource_start(pci, idx) == 0 || !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) { diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index e9c3794..dc97e81 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2645,9 +2645,9 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (!card) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if (total_bufsize[dev] < 128) total_bufsize[dev] = 128; diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index c129f9e..60cdb9e 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1468,9 +1468,9 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], &chip)) < 0) { snd_card_free(card); return err; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index f04de11..ad5df2a 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2335,10 +2335,10 @@ static int __devinit azx_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (!card) { + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) { snd_printk(KERN_ERR SFX "Error creating card!\n"); - return -ENOMEM; + return err; } err = azx_create(card, pci, dev, pci_id->driver_data, &chip); diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 58d7cda..bab1c70 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2648,9 +2648,9 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "ICE1712"); strcpy(card->shortname, "ICEnsemble ICE1712"); diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index bb8d8c7..7ff36d3 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2456,9 +2456,9 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "ICE1724"); strcpy(card->shortname, "ICEnsemble ICE1724"); diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 19d3391..671ff65 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -3058,9 +3058,9 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, int err; struct shortname_table *name; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; if (spdif_aclink < 0) spdif_aclink = check_default_spdif_aclink(pci); diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 93449e4..33a843c 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1269,9 +1269,9 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, int err; struct shortname_table *name; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "ICH-MODEM"); strcpy(card->shortname, "Intel ICH"); diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 5f8006b..8b79969 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2443,9 +2443,9 @@ snd_korg1212_probe(struct pci_dev *pci, dev++; return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) { snd_card_free(card); diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 59bbaf8..7014154 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2691,9 +2691,9 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; switch (pci->device) { case PCI_DEVICE_ID_ESS_ALLEGRO: diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index f23a735..bfc19e3 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1365,12 +1365,12 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, else idx = index[dev] + i; snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); - card = snd_card_new(idx, tmpid, THIS_MODULE, 0); + err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card); - if (! card) { + if (err < 0) { snd_printk(KERN_ERR "cannot allocate the card %d\n", i); snd_mixart_free(mgr); - return -ENOMEM; + return err; } strcpy(card->driver, CARD_NAME); diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 50c9f8a..522a040 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1668,9 +1668,9 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, } } - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; switch (pci->device) { case PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO: diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 84f481d..9c81e0b 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -459,10 +459,10 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, struct oxygen *chip; int err; - card = snd_card_new(index, id, model->owner, - sizeof *chip + model->model_data_size); - if (!card) - return -ENOMEM; + err = snd_card_create(index, id, model->owner, + sizeof(*chip) + model->model_data_size, &card); + if (err < 0) + return err; chip = card->private_data; chip->card = card; diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 27cf2c2..7f95459 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1510,12 +1510,12 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : card_name, i); - card = snd_card_new(idx, tmpid, THIS_MODULE, 0); + err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card); - if (! card) { + if (err < 0) { snd_printk(KERN_ERR "cannot allocate the card %d\n", i); pcxhr_free(mgr); - return -ENOMEM; + return err; } strcpy(card->driver, DRIVER_NAME); diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 3caacfb..6f10344 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -2102,9 +2102,9 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_riptide_create(card, pci, &chip)) < 0) { snd_card_free(card); return err; diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index e7ef3a1..d7b966e 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1941,9 +1941,10 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return -ENOENT; } - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct rme32))) == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct rme32), &card); + if (err < 0) + return err; card->private_free = snd_rme32_card_free; rme32 = (struct rme32 *) card->private_data; rme32->card = card; diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 3fdd488..55fb1c1 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2348,9 +2348,10 @@ snd_rme96_probe(struct pci_dev *pci, dev++; return -ENOENT; } - if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct rme96))) == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct rme96), &card); + if (err < 0) + return err; card->private_free = snd_rme96_card_free; rme96 = (struct rme96 *)card->private_data; rme96->card = card; diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 44d0c15..05b3f79 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5158,8 +5158,10 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci, return -ENOENT; } - if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct hdsp)))) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct hdsp), &card); + if (err < 0) + return err; hdsp = (struct hdsp *) card->private_data; card->private_free = snd_hdsp_card_free; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 71231cf..d4b4e0d 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -4503,10 +4503,10 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], - THIS_MODULE, sizeof(struct hdspm)); - if (!card) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], + THIS_MODULE, sizeof(struct hdspm), &card); + if (err < 0) + return err; hdspm = card->private_data; card->private_free = snd_hdspm_card_free; diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 2570907..bc539ab 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2594,11 +2594,11 @@ static int __devinit snd_rme9652_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_rme9652)); + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_rme9652), &card); - if (!card) - return -ENOMEM; + if (err < 0) + return err; rme9652 = (struct snd_rme9652 *) card->private_data; card->private_free = snd_rme9652_card_free; diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index df2007e..baf6d8e 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1387,9 +1387,8 @@ static int __devinit snd_sis7019_probe(struct pci_dev *pci, if (!enable) goto error_out; - rc = -ENOMEM; - card = snd_card_new(index, id, THIS_MODULE, sizeof(*sis)); - if (!card) + rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card); + if (rc < 0) goto error_out; strcpy(card->driver, "SiS7019"); diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index cd408b8..c5601b0 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1423,9 +1423,9 @@ static int __devinit snd_sonic_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; for (idx = 0; idx < 5; idx++) { if (pci_resource_start(pci, idx) == 0 || !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) { diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index d94b16f..21cef97 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -89,9 +89,9 @@ static int __devinit snd_trident_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_trident_create(card, pci, pcm_channels[dev], diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 1aafe95..d870554 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2433,9 +2433,9 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, unsigned int i; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; card_type = pci_id->driver_data; switch (card_type) { diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 5bd79d2..c086b76 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1167,9 +1167,9 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, unsigned int i; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; card_type = pci_id->driver_data; switch (card_type) { diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index acc352f..fc9136c 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -204,9 +204,9 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; switch ((int)pci_id->driver_data) { case VX_PCI_VX222_OLD: diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 2631a55..4af6666 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -187,9 +187,9 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; switch (pci_id->device) { case 0x0004: str = "YMF724"; model = "DS-1"; break; -- cgit v1.1 From bd7dd77c2a05c530684eea2e3af16449ae9c5d52 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:45:02 +0100 Subject: ALSA: Convert to snd_card_create() in other sound/* Convert from snd_card_new() to the new snd_card_create() function in other sound subdirectories. Signed-off-by: Takashi Iwai --- sound/aoa/core/alsa.c | 7 ++++--- sound/arm/aaci.c | 7 ++++--- sound/arm/pxa2xx-ac97.c | 7 +++---- sound/arm/sa11xx-uda1341.c | 7 ++++--- sound/drivers/dummy.c | 8 ++++---- sound/drivers/ml403-ac97cr.c | 6 +++--- sound/drivers/mpu401/mpu401.c | 6 +++--- sound/drivers/mtpav.c | 6 +++--- sound/drivers/mts64.c | 6 +++--- sound/drivers/pcsp/pcsp.c | 6 +++--- sound/drivers/portman2x4.c | 6 +++--- sound/drivers/serial-u16550.c | 6 +++--- sound/drivers/virmidi.c | 8 ++++---- sound/mips/au1x00.c | 7 ++++--- sound/mips/hal2.c | 6 +++--- sound/mips/sgio2audio.c | 6 +++--- sound/parisc/harmony.c | 6 +++--- sound/pcmcia/pdaudiocf/pdaudiocf.c | 8 ++++---- sound/pcmcia/vx/vxpocket.c | 8 ++++---- sound/ppc/powermac.c | 6 +++--- sound/ppc/snd_ps3.c | 6 ++---- sound/sh/aica.c | 8 ++++---- sound/soc/soc-core.c | 8 ++++---- sound/sparc/amd7930.c | 7 ++++--- sound/sparc/cs4231.c | 9 +++++---- sound/sparc/dbri.c | 8 ++++---- sound/spi/at73c213.c | 7 +++---- sound/usb/caiaq/caiaq-device.c | 7 ++++--- sound/usb/usbaudio.c | 6 +++--- sound/usb/usx2y/us122l.c | 8 +++++--- sound/usb/usx2y/usbusx2y.c | 7 +++++-- 31 files changed, 111 insertions(+), 103 deletions(-) diff --git a/sound/aoa/core/alsa.c b/sound/aoa/core/alsa.c index 6178504..0fa3855 100644 --- a/sound/aoa/core/alsa.c +++ b/sound/aoa/core/alsa.c @@ -23,9 +23,10 @@ int aoa_alsa_init(char *name, struct module *mod, struct device *dev) /* cannot be EEXIST due to usage in aoa_fabric_register */ return -EBUSY; - alsa_card = snd_card_new(index, name, mod, sizeof(struct aoa_card)); - if (!alsa_card) - return -ENOMEM; + err = snd_card_create(index, name, mod, sizeof(struct aoa_card), + &alsa_card); + if (err < 0) + return err; aoa_card = alsa_card->private_data; aoa_card->alsa_card = alsa_card; alsa_card->dev = dev; diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 89096e8..7d39aac 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -995,10 +995,11 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev) { struct aaci *aaci; struct snd_card *card; + int err; - card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, sizeof(struct aaci)); - if (card == NULL) + err = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, sizeof(struct aaci), &card); + if (err < 0) return NULL; card->private_free = aaci_free_card; diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 85cf591..7ed100c 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -173,10 +173,9 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev) struct snd_ac97_template ac97_template; int ret; - ret = -ENOMEM; - card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, 0); - if (!card) + ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, 0, &card); + if (ret < 0) goto err; card->dev = &dev->dev; diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 1dcd51d..51d708c 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -887,9 +887,10 @@ static int __devinit sa11xx_uda1341_probe(struct platform_device *devptr) struct sa11xx_uda1341 *chip; /* register the soundcard */ - card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(-1, id, THIS_MODULE, + sizeof(struct sa11xx_uda1341), &card); + if (err < 0) + return err; chip = card->private_data; spin_lock_init(&chip->s[0].dma_lock); diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 73be7e1..54239d2 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -588,10 +588,10 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) int idx, err; int dev = devptr->id; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_dummy)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_dummy), &card); + if (err < 0) + return err; dummy = card->private_data; dummy->card = card; for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index 7783843..1950ffc 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -1279,9 +1279,9 @@ static int __devinit snd_ml403_ac97cr_probe(struct platform_device *pfdev) if (!enable[dev]) return -ENOENT; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_ml403_ac97cr_create(card, pfdev, &ml403_ac97cr); if (err < 0) { PDEBUG(INIT_FAILURE, "probe(): create failed!\n"); diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index 5b996f3..149d05a 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -73,9 +73,9 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard) snd_printk(KERN_ERR "the uart_enter option is obsolete; remove it\n"); *rcard = NULL; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "MPU-401 UART"); strcpy(card->shortname, card->driver); sprintf(card->longname, "%s at %#lx, ", card->shortname, port[dev]); diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index 5b89c08..c3e9833 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -696,9 +696,9 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev) int err; struct mtpav *mtp_card; - card = snd_card_new(index, id, THIS_MODULE, sizeof(*mtp_card)); - if (! card) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, sizeof(*mtp_card), &card); + if (err < 0) + return err; mtp_card = card->private_data; spin_lock_init(&mtp_card->spinlock); diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index 87ba1dd..33d9db7 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -957,10 +957,10 @@ static int __devinit snd_mts64_probe(struct platform_device *pdev) if ((err = snd_mts64_probe_port(p)) < 0) return err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) { + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) { snd_printd("Cannot create card\n"); - return -ENOMEM; + return err; } strcpy(card->driver, DRIVER_NAME); strcpy(card->shortname, "ESI " CARD_NAME); diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index a4049eb..aa2ae07 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -98,9 +98,9 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev) hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); pcsp_chip.timer.function = pcsp_do_timer; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (!card) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_pcsp_create(card); if (err < 0) { diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index b1c047e..60158e2 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -746,10 +746,10 @@ static int __devinit snd_portman_probe(struct platform_device *pdev) if ((err = snd_portman_probe_port(p)) < 0) return err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) { + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) { snd_printd("Cannot create card\n"); - return -ENOMEM; + return err; } strcpy(card->driver, DRIVER_NAME); strcpy(card->shortname, CARD_NAME); diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index d8aab9d..891d081 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -936,9 +936,9 @@ static int __devinit snd_serial_probe(struct platform_device *devptr) return -ENODEV; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; strcpy(card->driver, "Serial"); strcpy(card->shortname, "Serial MIDI (UART16550A)"); diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index f79e361..6f48711 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -90,10 +90,10 @@ static int __devinit snd_virmidi_probe(struct platform_device *devptr) int idx, err; int dev = devptr->id; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_virmidi)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_virmidi), &card); + if (err < 0) + return err; vmidi = (struct snd_card_virmidi *)card->private_data; vmidi->card = card; diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index 1881cec..99e1391b 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -636,9 +636,10 @@ au1000_init(void) struct snd_card *card; struct snd_au1000 *au1000; - card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(struct snd_au1000)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(-1, "AC97", THIS_MODULE, + sizeof(struct snd_au1000), &card); + if (err < 0) + return err; card->private_free = snd_au1000_free; au1000 = card->private_data; diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index db495be..c52691c 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -878,9 +878,9 @@ static int __devinit hal2_probe(struct platform_device *pdev) struct snd_hal2 *chip; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; err = hal2_create(card, &chip); if (err < 0) { diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 4c63504..66f3b48 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -936,9 +936,9 @@ static int __devinit snd_sgio2audio_probe(struct platform_device *pdev) struct snd_sgio2audio *chip; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_sgio2audio_create(card, &chip); if (err < 0) { diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 41f870f..6055fd6 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -975,9 +975,9 @@ snd_harmony_probe(struct parisc_device *padev) struct snd_card *card; struct snd_harmony *h; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; err = snd_harmony_create(card, padev, &h); if (err < 0) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 819aaaa..183f661 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -91,7 +91,7 @@ static int snd_pdacf_dev_free(struct snd_device *device) */ static int snd_pdacf_probe(struct pcmcia_device *link) { - int i; + int i, err; struct snd_pdacf *pdacf; struct snd_card *card; static struct snd_device_ops ops = { @@ -112,10 +112,10 @@ static int snd_pdacf_probe(struct pcmcia_device *link) return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ - card = snd_card_new(index[i], id[i], THIS_MODULE, 0); - if (card == NULL) { + err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card); + if (err < 0) { snd_printk(KERN_ERR "pdacf: cannot create a card instance\n"); - return -ENOMEM; + return err; } pdacf = snd_pdacf_create(card); diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 706602a..087ded8 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -292,7 +292,7 @@ static int vxpocket_probe(struct pcmcia_device *p_dev) { struct snd_card *card; struct snd_vxpocket *vxp; - int i; + int i, err; /* find an empty slot from the card list */ for (i = 0; i < SNDRV_CARDS; i++) { @@ -307,10 +307,10 @@ static int vxpocket_probe(struct pcmcia_device *p_dev) return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ - card = snd_card_new(index[i], id[i], THIS_MODULE, 0); - if (card == NULL) { + err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card); + if (err < 0) { snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); - return -ENOMEM; + return err; } vxp = snd_vxpocket_new(card, ibl[i], p_dev); diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index c936225..2e18ed0 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -58,9 +58,9 @@ static int __init snd_pmac_probe(struct platform_device *devptr) char *name_ext; int err; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) + return err; if ((err = snd_pmac_new(card, &chip)) < 0) goto __error; diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index 8f9e385..ef2c3f4 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -969,11 +969,9 @@ static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev) } /* create card instance */ - the_card.card = snd_card_new(index, id, THIS_MODULE, 0); - if (!the_card.card) { - ret = -ENXIO; + ret = snd_card_create(index, id, THIS_MODULE, 0, &the_card.card); + if (ret < 0) goto clean_irq; - } strcpy(the_card.card->driver, "PS3"); strcpy(the_card.card->shortname, "PS3"); diff --git a/sound/sh/aica.c b/sound/sh/aica.c index 7c920f3..f551233 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -609,11 +609,11 @@ static int __devinit snd_aica_probe(struct platform_device *devptr) dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL); if (unlikely(!dreamcastcard)) return -ENOMEM; - dreamcastcard->card = - snd_card_new(index, SND_AICA_DRIVER, THIS_MODULE, 0); - if (unlikely(!dreamcastcard->card)) { + err = snd_card_create(index, SND_AICA_DRIVER, THIS_MODULE, 0, + &dreamcastcard->card); + if (unlikely(err < 0)) { kfree(dreamcastcard); - return -ENODEV; + return err; } strcpy(dreamcastcard->card->driver, "snd_aica"); strcpy(dreamcastcard->card->shortname, SND_AICA_DRIVER); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6cbe7e8..318dfdd 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1311,17 +1311,17 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) { struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; - int ret = 0, i; + int ret, i; mutex_lock(&codec->mutex); /* register a sound card */ - codec->card = snd_card_new(idx, xid, codec->owner, 0); - if (!codec->card) { + ret = snd_card_create(idx, xid, codec->owner, 0, &codec->card); + if (ret < 0) { printk(KERN_ERR "asoc: can't create sound card for codec %s\n", codec->name); mutex_unlock(&codec->mutex); - return -ENODEV; + return ret; } codec->card->dev = socdev->dev; diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index f87933e..ba38912 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -1018,9 +1018,10 @@ static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_de return -ENOENT; } - card = snd_card_new(index[dev_num], id[dev_num], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev_num], id[dev_num], THIS_MODULE, 0, + &card); + if (err < 0) + return err; strcpy(card->driver, "AMD7930"); strcpy(card->shortname, "Sun AMD7930"); diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 41c3875..7d93fa7 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1563,6 +1563,7 @@ static int __init cs4231_attach_begin(struct snd_card **rcard) { struct snd_card *card; struct snd_cs4231 *chip; + int err; *rcard = NULL; @@ -1574,10 +1575,10 @@ static int __init cs4231_attach_begin(struct snd_card **rcard) return -ENOENT; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_cs4231)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_cs4231), &card); + if (err < 0) + return err; strcpy(card->driver, "CS4231"); strcpy(card->shortname, "Sun CS4231"); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 23ed6f0..af95ff1 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2612,10 +2612,10 @@ static int __devinit dbri_probe(struct of_device *op, const struct of_device_id return -ENODEV; } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_dbri)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_dbri), &card); + if (err < 0) + return err; strcpy(card->driver, "DBRI"); strcpy(card->shortname, "Sun DBRI"); diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 09802e8..4c7b051 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -965,12 +965,11 @@ static int __devinit snd_at73c213_probe(struct spi_device *spi) return PTR_ERR(board->dac_clk); } - retval = -ENOMEM; - /* Allocate "card" using some unused identifiers. */ snprintf(id, sizeof id, "at73c213_%d", board->ssc_id); - card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct snd_at73c213)); - if (!card) + retval = snd_card_create(-1, id, THIS_MODULE, + sizeof(struct snd_at73c213), &card); + if (retval < 0) goto out; chip = card->private_data; diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index a62500e..63a2c1d 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c @@ -339,6 +339,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) static struct snd_card* create_card(struct usb_device* usb_dev) { int devnum; + int err; struct snd_card *card; struct snd_usb_caiaqdev *dev; @@ -349,9 +350,9 @@ static struct snd_card* create_card(struct usb_device* usb_dev) if (devnum >= SNDRV_CARDS) return NULL; - card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, - sizeof(struct snd_usb_caiaqdev)); - if (!card) + err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, + sizeof(struct snd_usb_caiaqdev), &card); + if (err < 0) return NULL; dev = caiaqdev(card); diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index c709b95..eec32e1 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -3463,10 +3463,10 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, return -ENXIO; } - card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); - if (card == NULL) { + err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card); + if (err < 0) { snd_printk(KERN_ERR "cannot create card instance %d\n", idx); - return -ENOMEM; + return err; } chip = kzalloc(sizeof(*chip), GFP_KERNEL); diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 73e59f4..b21bb47 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -482,14 +482,16 @@ static struct snd_card *usx2y_create_card(struct usb_device *device) { int dev; struct snd_card *card; + int err; + for (dev = 0; dev < SNDRV_CARDS; ++dev) if (enable[dev] && !snd_us122l_card_used[dev]) break; if (dev >= SNDRV_CARDS) return NULL; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct us122l)); - if (!card) + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct us122l), &card); + if (err < 0) return NULL; snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 11639bd..b848a18 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -337,13 +337,16 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device) { int dev; struct snd_card * card; + int err; + for (dev = 0; dev < SNDRV_CARDS; ++dev) if (enable[dev] && !snd_usX2Y_card_used[dev]) break; if (dev >= SNDRV_CARDS) return NULL; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev)); - if (!card) + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct usX2Ydev), &card); + if (err < 0) return NULL; snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; card->private_free = snd_usX2Y_card_private_free; -- cgit v1.1 From d453379bc5d34d7f55b55931245de5ac1896fd8d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:45:34 +0100 Subject: ALSA: Update description of snd_card_create() in documents Signed-off-by: Takashi Iwai --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 87a7c07a..320384c 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -492,9 +492,9 @@ } /* (2) */ - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + if (err < 0) + return err; /* (3) */ err = snd_mychip_create(card, pci, &chip); @@ -590,8 +590,9 @@ @@ -809,26 +810,28 @@ As mentioned above, to create a card instance, call - snd_card_new(). + snd_card_create(). - The function takes four arguments, the card-index number, the + The function takes five arguments, the card-index number, the id string, the module pointer (usually THIS_MODULE), - and the size of extra-data space. The last argument is used to + the size of extra-data space, and the pointer to return the + card instance. The extra_size argument is used to allocate card->private_data for the chip-specific data. Note that these data - are allocated by snd_card_new(). + are allocated by snd_card_create(). @@ -915,15 +918,16 @@
- 1. Allocating via <function>snd_card_new()</function>. + 1. Allocating via <function>snd_card_create()</function>. As mentioned above, you can pass the extra-data-length - to the 4th argument of snd_card_new(), i.e. + to the 4th argument of snd_card_create(), i.e. @@ -952,8 +956,8 @@ After allocating a card instance via - snd_card_new() (with - NULL on the 4th arg), call + snd_card_create() (with + 0 on the 4th arg), call kzalloc(). @@ -961,7 +965,7 @@ @@ -5750,8 +5754,9 @@ struct _snd_pcm_runtime { .... struct snd_card *card; struct mychip *chip; + int err; .... - card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL); + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); .... chip = kzalloc(sizeof(*chip), GFP_KERNEL); .... @@ -5763,7 +5768,7 @@ struct _snd_pcm_runtime { When you created the chip data with - snd_card_new(), it's anyway accessible + snd_card_create(), it's anyway accessible via private_data field. @@ -5775,9 +5780,10 @@ struct _snd_pcm_runtime { .... struct snd_card *card; struct mychip *chip; + int err; .... - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct mychip)); + err = snd_card_create(index[dev], id[dev], THIS_MODULE, + sizeof(struct mychip), &card); .... chip = card->private_data; .... -- cgit v1.1 From 3e7fb9f7ec00fd7cefd0d8e83df0cff86ce12515 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:47:30 +0100 Subject: 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: Takashi Iwai --- sound/isa/cs423x/cs4236.c | 25 +++++++++++++------------ sound/isa/es18xx.c | 27 ++++++++++++--------------- sound/isa/gus/interwave.c | 19 ++++++++++--------- sound/isa/opti9xx/opti92x-ad1848.c | 20 ++++++++++---------- sound/isa/sb/sb16.c | 19 ++++++++++--------- sound/isa/wavefront/wavefront.c | 19 ++++++++++--------- 6 files changed, 65 insertions(+), 64 deletions(-) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index db83068..f784598 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -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"); diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index c24c632..8cfbff7 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -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); diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index e040c76..50e429a 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -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); diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 5750f38..87a4feb 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -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); diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index adf4fdd..519c363 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -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) { diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 82b8fb7..95898b2 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -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) { -- cgit v1.1 From 51721f70acaca5aa056b07c5cbe58e62662c068c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:55:08 +0100 Subject: ALSA: Return proper error code at probe in sound/usb/* Some drivers in soudn/usb/* don't handle the error code properly from snd_card_create(). This patch fixes these places. Signed-off-by: Takashi Iwai --- sound/usb/caiaq/caiaq-device.c | 15 +++++++------ sound/usb/usx2y/us122l.c | 51 +++++++++++++++++++++++++----------------- sound/usb/usx2y/usbusx2y.c | 45 +++++++++++++++++++++++-------------- 3 files changed, 67 insertions(+), 44 deletions(-) diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index 63a2c1d..55a9075 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c @@ -336,7 +336,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) log("Unable to set up control system (ret=%d)\n", ret); } -static struct snd_card* create_card(struct usb_device* usb_dev) +static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) { int devnum; int err; @@ -348,12 +348,12 @@ static struct snd_card* create_card(struct usb_device* usb_dev) break; if (devnum >= SNDRV_CARDS) - return NULL; + return -ENODEV; err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, sizeof(struct snd_usb_caiaqdev), &card); if (err < 0) - return NULL; + return err; dev = caiaqdev(card); dev->chip.dev = usb_dev; @@ -363,7 +363,8 @@ static struct snd_card* create_card(struct usb_device* usb_dev) spin_lock_init(&dev->spinlock); snd_card_set_dev(card, &usb_dev->dev); - return card; + *cardp = card; + return 0; } static int __devinit init_card(struct snd_usb_caiaqdev *dev) @@ -442,10 +443,10 @@ static int __devinit snd_probe(struct usb_interface *intf, struct snd_card *card; struct usb_device *device = interface_to_usbdev(intf); - card = create_card(device); + ret = create_card(device, &card); - if (!card) - return -ENOMEM; + if (ret < 0) + return ret; usb_set_intfdata(intf, card); ret = init_card(caiaqdev(card)); diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index b21bb47..98276aa 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -478,7 +478,7 @@ static bool us122l_create_card(struct snd_card *card) return true; } -static struct snd_card *usx2y_create_card(struct usb_device *device) +static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) { int dev; struct snd_card *card; @@ -488,11 +488,11 @@ static struct snd_card *usx2y_create_card(struct usb_device *device) if (enable[dev] && !snd_us122l_card_used[dev]) break; if (dev >= SNDRV_CARDS) - return NULL; + return -ENODEV; err = snd_card_create(index[dev], id[dev], THIS_MODULE, sizeof(struct us122l), &card); if (err < 0) - return NULL; + return err; snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; US122L(card)->chip.dev = device; @@ -511,46 +511,57 @@ static struct snd_card *usx2y_create_card(struct usb_device *device) US122L(card)->chip.dev->devnum ); snd_card_set_dev(card, &device->dev); - return card; + *cardp = card; + return 0; } -static void *us122l_usb_probe(struct usb_interface *intf, - const struct usb_device_id *device_id) +static int us122l_usb_probe(struct usb_interface *intf, + const struct usb_device_id *device_id, + struct snd_card **cardp) { struct usb_device *device = interface_to_usbdev(intf); - struct snd_card *card = usx2y_create_card(device); + struct snd_card *card; + int err; - if (!card) - return NULL; + err = usx2y_create_card(device, &card); + if (err < 0) + return err; - if (!us122l_create_card(card) || - snd_card_register(card) < 0) { + if (!us122l_create_card(card)) { snd_card_free(card); - return NULL; + return -EINVAL; + } + + err = snd_card_register(card); + if (err < 0) { + snd_card_free(card); + return err; } usb_get_dev(device); - return card; + *cardp = card; + return 0; } static int snd_us122l_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct snd_card *card; + int err; + snd_printdd(KERN_DEBUG"%p:%i\n", intf, intf->cur_altsetting->desc.bInterfaceNumber); if (intf->cur_altsetting->desc.bInterfaceNumber != 1) return 0; - card = us122l_usb_probe(usb_get_intf(intf), id); - - if (card) { - usb_set_intfdata(intf, card); - return 0; + err = us122l_usb_probe(usb_get_intf(intf), id, &card); + if (err < 0) { + usb_put_intf(intf); + return err; } - usb_put_intf(intf); - return -EIO; + usb_set_intfdata(intf, card); + return 0; } static void snd_us122l_disconnect(struct usb_interface *intf) diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index b848a18..af8b849 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -333,7 +333,7 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = { { /* terminator */ } }; -static struct snd_card *usX2Y_create_card(struct usb_device *device) +static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) { int dev; struct snd_card * card; @@ -343,11 +343,11 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device) if (enable[dev] && !snd_usX2Y_card_used[dev]) break; if (dev >= SNDRV_CARDS) - return NULL; + return -ENODEV; err = snd_card_create(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev), &card); if (err < 0) - return NULL; + return err; snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; card->private_free = snd_usX2Y_card_private_free; usX2Y(card)->chip.dev = device; @@ -365,26 +365,36 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device) usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum ); snd_card_set_dev(card, &device->dev); - return card; + *cardp = card; + return 0; } -static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) +static int usX2Y_usb_probe(struct usb_device *device, + struct usb_interface *intf, + const struct usb_device_id *device_id, + struct snd_card **cardp) { int err; struct snd_card * card; + + *cardp = NULL; if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && - le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428) || - !(card = usX2Y_create_card(device))) - return NULL; + le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428)) + return -EINVAL; + + err = usX2Y_create_card(device, &card); + if (err < 0) + return err; if ((err = usX2Y_hwdep_new(card, device)) < 0 || (err = snd_card_register(card)) < 0) { snd_card_free(card); - return NULL; + return err; } - return card; + *cardp = card; + return 0; } /* @@ -392,13 +402,14 @@ static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *in */ static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id) { - void *chip; - chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id); - if (chip) { - usb_set_intfdata(intf, chip); - return 0; - } else - return -EIO; + struct snd_card *card; + int err; + + err = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id, &card); + if (err < 0) + return err; + dev_set_drvdata(&intf->dev, card); + return 0; } static void snd_usX2Y_disconnect(struct usb_interface *intf) -- cgit v1.1 From aa3d75d80de464cf23af1d068a5e22f1527b6957 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:59:41 +0100 Subject: ALSA: pdaudiocf - Fix missing free in the error path Added the missing snd_card_free() in the error path of probe callback. Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 183f661..ec51569 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -119,8 +119,10 @@ static int snd_pdacf_probe(struct pcmcia_device *link) } pdacf = snd_pdacf_create(card); - if (! pdacf) + if (!pdacf) { + snd_card_free(card); return -EIO; + } if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops) < 0) { kfree(pdacf); -- cgit v1.1 From 2fa51107c9aa80ae95b4524198442cdea82d08a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 17:03:56 +0100 Subject: ALSA: Return proper error code at probe in sound/pcmcia/* Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 7 ++++--- sound/pcmcia/vx/vxpocket.c | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index ec51569..7dea74b 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -121,13 +121,14 @@ static int snd_pdacf_probe(struct pcmcia_device *link) pdacf = snd_pdacf_create(card); if (!pdacf) { snd_card_free(card); - return -EIO; + return -ENOMEM; } - if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops) < 0) { + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops); + if (err < 0) { kfree(pdacf); snd_card_free(card); - return -ENODEV; + return err; } snd_card_set_dev(card, &handle_to_dev(link)); diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 087ded8..7445cc8 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -130,23 +130,26 @@ static struct snd_vx_hardware vxp440_hw = { /* * create vxpocket instance */ -static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl, - struct pcmcia_device *link) +static int snd_vxpocket_new(struct snd_card *card, int ibl, + struct pcmcia_device *link, + struct snd_vxpocket **chip_ret) { struct vx_core *chip; struct snd_vxpocket *vxp; static struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; + int err; chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, sizeof(struct snd_vxpocket) - sizeof(struct vx_core)); - if (! chip) - return NULL; + if (!chip) + return -ENOMEM; - if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops) < 0) { + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); + if (err < 0) { kfree(chip); - return NULL; + return err; } chip->ibl.size = ibl; @@ -169,7 +172,8 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl, link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; - return vxp; + *chip_ret = vxp; + return 0; } @@ -313,10 +317,10 @@ static int vxpocket_probe(struct pcmcia_device *p_dev) return err; } - vxp = snd_vxpocket_new(card, ibl[i], p_dev); - if (! vxp) { + err = snd_vxpocket_new(card, ibl[i], p_dev, &vxp); + if (err < 0) { snd_card_free(card); - return -ENODEV; + return err; } card->private_data = vxp; -- cgit v1.1 From 758021bfa9ea25c58e62d2f68512628b19502ce7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2009 15:17:09 +0100 Subject: drivers/media: Convert to snd_card_create() Convert from snd_card_new() to the new snd_card_create() function. Signed-off-by: Takashi Iwai --- drivers/media/video/cx88/cx88-alsa.c | 7 ++++--- drivers/media/video/em28xx/em28xx-audio.c | 7 ++++--- drivers/media/video/saa7134/saa7134-alsa.c | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 66c755c..ce98d95 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c @@ -803,9 +803,10 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, return (-ENOENT); } - card = snd_card_new(index[devno], id[devno], THIS_MODULE, sizeof(snd_cx88_card_t)); - if (!card) - return (-ENOMEM); + err = snd_card_create(index[devno], id[devno], THIS_MODULE, + sizeof(snd_cx88_card_t), &card); + if (err < 0) + return err; card->private_free = snd_cx88_dev_free; diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 94378cc..6657950 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c @@ -438,9 +438,10 @@ static int em28xx_audio_init(struct em28xx *dev) printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " "Rechberger\n"); - card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0, + &card); + if (err < 0) + return err; spin_lock_init(&adev->slock); err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index 26194a0..482be14 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c @@ -990,10 +990,10 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) if (!enable[devnum]) return -ENODEV; - card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t)); - - if (card == NULL) - return -ENOMEM; + err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, + sizeof(snd_card_saa7134_t), &card); + if (err < 0) + return err; strcpy(card->driver, "SAA7134"); -- cgit v1.1 From 6ff1871617a3ea1eeaf88b42f652f9a311826bad Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2009 15:18:28 +0100 Subject: drivers/staging: Convert to snd_card_create() for go7007 Convert from snd_card_new to the new snd_card_create() for go7007. Signed-off-by: Takashi Iwai --- drivers/staging/go7007/snd-go7007.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/go7007/snd-go7007.c b/drivers/staging/go7007/snd-go7007.c index a7de401..cd19be6 100644 --- a/drivers/staging/go7007/snd-go7007.c +++ b/drivers/staging/go7007/snd-go7007.c @@ -248,10 +248,11 @@ int go7007_snd_init(struct go7007 *go) spin_lock_init(&gosnd->lock); gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0; gosnd->capturing = 0; - gosnd->card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (gosnd->card == NULL) { + ret = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, + &gosnd->card); + if (ret < 0) { kfree(gosnd); - return -ENOMEM; + return ret; } ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go, &go7007_snd_device_ops); -- cgit v1.1 From 183c6e0fb4e39c860960de4abd7541bd260491bb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2009 15:19:08 +0100 Subject: drivers/usb/gadget: Convert to snd_card_create() Convert from snd_card_new() to the new snd_card_create() function for gmidi. Signed-off-by: Takashi Iwai --- drivers/usb/gadget/gmidi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 60d3f9e..14e09ab 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -1099,10 +1099,9 @@ static int gmidi_register_card(struct gmidi_device *dev) .dev_free = gmidi_snd_free, }; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (!card) { - ERROR(dev, "snd_card_new failed\n"); - err = -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) { + ERROR(dev, "snd_card_create failed\n"); goto fail; } dev->card = card; -- cgit v1.1 From b1a0aac05f044e78a589bfd7a9e2334aa640eb45 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 14 Jan 2009 09:34:06 +0100 Subject: ALSA: opti9xx - Fix build breakage by snd_card_create() conversion Add a missing variable declaration. Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/opti92x-ad1848.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 87a4feb..cd6e60a 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -833,6 +833,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) 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); -- cgit v1.1