Merge branch 'topic/snd_card_new-err' into topic/asoc
authorTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2009 07:08:32 +0000 (08:08 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2009 07:08:32 +0000 (08:08 +0100)
Conflicts:
sound/soc/soc-core.c

111 files changed:
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
drivers/media/video/cx88/cx88-alsa.c
drivers/media/video/em28xx/em28xx-audio.c
drivers/media/video/saa7134/saa7134-alsa.c
drivers/staging/go7007/snd-go7007.c
drivers/usb/gadget/gmidi.c
include/sound/core.h
sound/aoa/core/alsa.c
sound/arm/aaci.c
sound/arm/pxa2xx-ac97.c
sound/arm/sa11xx-uda1341.c
sound/core/init.c
sound/drivers/dummy.c
sound/drivers/ml403-ac97cr.c
sound/drivers/mpu401/mpu401.c
sound/drivers/mtpav.c
sound/drivers/mts64.c
sound/drivers/pcsp/pcsp.c
sound/drivers/portman2x4.c
sound/drivers/serial-u16550.c
sound/drivers/virmidi.c
sound/isa/ad1816a/ad1816a.c
sound/isa/ad1848/ad1848.c
sound/isa/adlib.c
sound/isa/als100.c
sound/isa/azt2320.c
sound/isa/cmi8330.c
sound/isa/cs423x/cs4231.c
sound/isa/cs423x/cs4236.c
sound/isa/dt019x.c
sound/isa/es1688/es1688.c
sound/isa/es18xx.c
sound/isa/gus/gusclassic.c
sound/isa/gus/gusextreme.c
sound/isa/gus/gusmax.c
sound/isa/gus/interwave.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/es968.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/sc6000.c
sound/isa/sgalaxy.c
sound/isa/sscape.c
sound/isa/wavefront/wavefront.c
sound/mips/au1x00.c
sound/mips/hal2.c
sound/mips/sgio2audio.c
sound/parisc/harmony.c
sound/pci/ad1889.c
sound/pci/ali5451/ali5451.c
sound/pci/als300.c
sound/pci/als4000.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/au88x0/au88x0.c
sound/pci/aw2/aw2-alsa.c
sound/pci/azt3328.c
sound/pci/bt87x.c
sound/pci/ca0106/ca0106_main.c
sound/pci/cmipci.c
sound/pci/cs4281.c
sound/pci/cs46xx/cs46xx.c
sound/pci/cs5530.c
sound/pci/cs5535audio/cs5535audio.c
sound/pci/echoaudio/echoaudio.c
sound/pci/emu10k1/emu10k1.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/fm801.c
sound/pci/hda/hda_intel.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/maestro3.c
sound/pci/mixart/mixart.c
sound/pci/nm256/nm256.c
sound/pci/oxygen/oxygen_lib.c
sound/pci/pcxhr/pcxhr.c
sound/pci/riptide/riptide.c
sound/pci/rme32.c
sound/pci/rme96.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/sis7019.c
sound/pci/sonicvibes.c
sound/pci/trident/trident.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222.c
sound/pci/ymfpci/ymfpci.c
sound/pcmcia/pdaudiocf/pdaudiocf.c
sound/pcmcia/vx/vxpocket.c
sound/ppc/powermac.c
sound/ppc/snd_ps3.c
sound/sh/aica.c
sound/soc/soc-core.c
sound/sparc/amd7930.c
sound/sparc/cs4231.c
sound/sparc/dbri.c
sound/spi/at73c213.c
sound/usb/caiaq/caiaq-device.c
sound/usb/usbaudio.c
sound/usb/usx2y/us122l.c
sound/usb/usx2y/usbusx2y.c

index 87a7c07ab6581ecd6a96d354ac5920e633548ea8..320384c1791bc1885bdf9940055a4af0694065f4 100644 (file)
           }
 
           /* (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);
             <programlisting>
 <![CDATA[
   struct snd_card *card;
+  int err;
   ....
-  card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
+  err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
 ]]>
             </programlisting>
           </informalexample>
 
       <para>
         As mentioned above, to create a card instance, call
-      <function>snd_card_new()</function>.
+      <function>snd_card_create()</function>.
 
         <informalexample>
           <programlisting>
 <![CDATA[
   struct snd_card *card;
-  card = snd_card_new(index, id, module, extra_size);
+  int err;
+  err = snd_card_create(index, id, module, extra_size, &card);
 ]]>
           </programlisting>
         </informalexample>
       </para>
 
       <para>
-        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
         <constant>THIS_MODULE</constant>),
-        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-&gt;private_data for the
         chip-specific data.  Note that these data
-        are allocated by <function>snd_card_new()</function>.
+        are allocated by <function>snd_card_create()</function>.
       </para>
     </section>
 
       </para>
 
       <section id="card-management-chip-specific-snd-card-new">
-        <title>1. Allocating via <function>snd_card_new()</function>.</title>
+        <title>1. Allocating via <function>snd_card_create()</function>.</title>
         <para>
           As mentioned above, you can pass the extra-data-length
-         to the 4th argument of <function>snd_card_new()</function>, i.e.
+         to the 4th argument of <function>snd_card_create()</function>, i.e.
 
           <informalexample>
             <programlisting>
 <![CDATA[
-  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);
 ]]>
             </programlisting>
           </informalexample>
 
         <para>
           After allocating a card instance via
-          <function>snd_card_new()</function> (with
-          <constant>NULL</constant> on the 4th arg), call
+          <function>snd_card_create()</function> (with
+          <constant>0</constant> on the 4th arg), call
           <function>kzalloc()</function>. 
 
           <informalexample>
 <![CDATA[
   struct snd_card *card;
   struct mychip *chip;
-  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);
 ]]>
@@ -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 {
       </informalexample>
 
        When you created the chip data with
-       <function>snd_card_new()</function>, it's anyway accessible
+       <function>snd_card_create()</function>, it's anyway accessible
        via <structfield>private_data</structfield> field.
 
       <informalexample>
@@ -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;
           ....
index 66c755c116dcbc8190f7305257b8201e6bc88496..ce98d955231ae4f505b8e018836698d33a3ebde8 100644 (file)
@@ -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;
 
index 94378ccb7505845d157920e4f81d9154eee6f35f..66579508e17569e92dd68de337dff1fd4b38f741 100644 (file)
@@ -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);
index 26194a0ce927c4e414c66c89dbabf29d8a00fdbd..482be1436e9262cb0511da8a3d07bb5232147d0d 100644 (file)
@@ -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");
 
index a7de401f61ab22d1636939ba87ba939ad1f15654..cd19be6c00e09fa1f0256c3657f81989f1f1e4fe 100644 (file)
@@ -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);
index 60d3f9e9b51fdef421f239b3055b09325a30f74a..14e09abbddfcb0463e701a08cc3ec48702686875 100644 (file)
@@ -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;
index f632484bc7439171d1b682788305981b66e074f4..25420c3b551372a3695ee6de69e197785ea0cb13 100644 (file)
@@ -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);
index 617850463582fc682696969659bcda553ec02eb6..0fa3855b4790e30753b7b8ea4fb29644a6e8cd1f 100644 (file)
@@ -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;
index 89096e811a4bc47dbe1458c2faba375220ec5bbb..7d39aac9ec14eafc88681773a2a2b86f69acf2e4 100644 (file)
@@ -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;
index 85cf591d4e11d594d96ac970ec1bed41d473bbb2..7ed100c80a5f752a7768cc11d152eb1e01471a8c 100644 (file)
@@ -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;
index 1dcd51d81d102c1adcd5ea5282933b9ba9f947f5..51d708c31e6586a50414a8ceec47cdec8794f0f4 100644 (file)
@@ -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);
index 0d5520c415d3ad77258221cc4ebbdc25f6799def..dc4b80c7f311b9fc5e15d30fa96da09a11e81462 100644 (file)
@@ -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)
index 73be7e14a603d56208aec9d9bd741b48c5444750..54239d2e0997b7ac88e2e6c2e3898afc79a7c0f9 100644 (file)
@@ -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++) {
index 7783843ca9ae95ce9dd2acee69eb970acd914348..1950ffce2b545cdff262daae280128134259fa20 100644 (file)
@@ -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");
index 5b996f3faba5844c434d693af77fee3bcd3bbba4..149d05a8202d58bf381c3eb059e3302f89e2a188 100644 (file)
@@ -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]);
index 5b89c0883d6081b8d5b8b854d72585ef345f6c55..c3e9833dcfd9af1ffc2d8c53e49a6894a9ed1ef3 100644 (file)
@@ -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);
index 87ba1ddc01151fdfb5bd8f38d80103a68964aa5a..33d9db782e07e4d85ac62c9c89a4ee485a894056 100644 (file)
@@ -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);
index a4049eb94d35a28bafa41072e6e44af726d6f251..aa2ae07a76d563fb5e8d64fdec7606570a0ed569 100644 (file)
@@ -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) {
index b1c047ec19afe6e5ce9e6cf1acb2124c72719d45..60158e2e0eafb529e00013b4a9997d325b1b7fa2 100644 (file)
@@ -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);
index d8aab9da97c29ad8058f5be9751537b25b043500..891d081e4825d780f3ce78e3622477bf2e24060d 100644 (file)
@@ -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)");
index f79e3614079d238aca26df870c863949bbda1e94..6f48711818f33eff1ea78d7ec5cca29b6e6dd835 100644 (file)
@@ -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;
 
index 77524244a846458a7f561f7722e39b1e5e17b971..9660e598232c5614af35aeb6cf17bdf20f4ef060 100644 (file)
@@ -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))) {
index 223a6c038819217a2d5bfb74e81bfd6a56ba1d86..4beeb6f98e0eab9b06d291aa4ac3ea9451f43d95 100644 (file)
@@ -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,
index 374b7177e111d2f806930d84cdb147c1ace28356..7465ae036e0bd9e871ef632e03207e2347bf7b73 100644 (file)
@@ -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);
index f1ce30f379c9d5fa06ef68b62b5643b08596871c..5fd52e4d707998769f317b8dbbaf3d7e0839f9f4 100644 (file)
@@ -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))) {
index 3e74d1a3928e7f8b6067090cb54f13645f6e746b..f7aa637b0d181497fccdf1f48ff7f352b68ad5e2 100644 (file)
@@ -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))) {
index e49aec700a556681ea1e5f05b3e68da7d571852d..24e60902f8ca43e676f19bfc73a53bc8a1080162 100644 (file)
@@ -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);
index f019d449e2d65cd243c9a5aec5b51c35441c5e99..cb9153e75b8228ab75851b42d74900dae4c263e8 100644 (file)
@@ -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);
index 019c9401663eb9839787f63f4b32d0d9f1cba20b..f7845986f467babe1ca09c96d001fd8747e943f7 100644 (file)
@@ -382,16 +382,18 @@ 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;
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE,
-                           sizeof(struct snd_card_cs4236));
-       if (card == NULL)
-               return NULL;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct snd_card_cs4236), &card);
+       if (err < 0)
+               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)
@@ -512,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);
@@ -594,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);
@@ -656,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");
index a0242c3b613ef2a22dabb34531724883cc62e529..80f5b1af9be8e9d3ea908502880660f49200c267 100644 (file)
@@ -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);
index b46377139cf81d4ffc73d1e10572f6996c5ad4c3..d746750410ea93b29864cea00d8ab698d4b3c963 100644 (file)
@@ -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)
index 90498e4ca2601f3c82005a4de4eaafd5e857d935..8cfbff73a8357416ad45a7d51c63cb298e5ba90f 100644 (file)
@@ -2125,10 +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)
 {
-       return snd_card_new(index[dev], id[dev], THIS_MODULE,
-                           sizeof(struct snd_audiodrive));
+       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)
@@ -2197,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);
@@ -2303,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;
@@ -2362,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);
index 426532a4d730cfdcc2fa053db7b7f83d84187581..086b8f0e0f94320fb3763e962918265750eaa1b3 100644 (file)
@@ -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;
index 7ad4c3b41a848092b2c7d4795d3e70aa1ebb0a4a..180a8dea6bd94cbec45ba6bcae82282cfe7119fb 100644 (file)
@@ -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;
index f94c1976e632c2c55314cd8daee9e0f9aeb0f716..f26eac8d8110093aed72bfc51dce0340ca972ee9 100644 (file)
@@ -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;
index 5faecfb602d3bec1a66235e5c1e5951f2ec2a215..50e429a120dab058c6bca76abfb25a06a6dd02e1 100644 (file)
@@ -626,20 +626,22 @@ 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;
+       int err;
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE,
-                           sizeof(struct snd_interwave));
-       if (card == NULL)
-               return NULL;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct snd_interwave), &card);
+       if (err < 0)
+               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)
@@ -778,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) {
@@ -876,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);
index 58c972b2af03821dd1647dba0494cbd15f17a945..645491a53023920ad31f3f982163c0e520abbe75 100644 (file)
@@ -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);
index 440755cc00137c663e39c11e258c76ca5d944bed..02e30d7c6a93b216296ff5298916be79053195ff 100644 (file)
@@ -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;
index 19706b0d84978c5307166826b9aed76a0c40f46e..cd6e60a6a4eafb8cfdd2dec8a76d016704018b72 100644 (file)
@@ -830,15 +830,18 @@ 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;
 
-       card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx));
-       if (! card)
-               return NULL;
+       err = snd_card_create(index, id, THIS_MODULE,
+                             sizeof(struct snd_opti9xx), &card);
+       if (err < 0)
+               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,
@@ -903,9 +906,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);
@@ -950,9 +953,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);
index c8c8e214c843421a6288a30b8634cf5a76138134..cafc3a7316a89c4948deaf4d51e7b53fa3cce1c7 100644 (file)
@@ -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);
index 2c201f78ce50a0abd79238c51d81e8f8b8482952..519c36346dec5e232ed162bb7a9552a777acc068 100644 (file)
@@ -324,14 +324,18 @@ 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 = snd_card_new(index[dev], id[dev], THIS_MODULE,
-                                       sizeof(struct snd_card_sb16));
-       if (card == NULL)
-               return 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 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)
@@ -489,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 */
@@ -610,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) {
index ea06877be4b135fb8256de12ebe416dc9df46901..3cd57ee54660716a8182d9c33e2771b4263500f6 100644 (file)
@@ -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;
 
index ca35924dc3b3d05efa49db7051048c5d7b0d4e36..7a1470376c6dbb7b5f07bab1faaae124028de7b2 100644 (file)
@@ -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);
index 2c7503bf12714ade916d128576e7a2edc6c8300e..6fe27b9d944035a9ab0ec82d54500ec60401f02c 100644 (file)
@@ -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) {
index 48a16d865834b023704eea64b0c27d062bc6dc94..4025fb558c5005d1b5143d8b3f41f679e6f54184 100644 (file)
@@ -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);
 
index 4c095bc7c7291165c91163293b2390ce14d60f46..95898b2b7b5866c9ad303729bb72221a2f634687 100644 (file)
@@ -338,15 +338,16 @@ 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;
+       int err;
 
-       card = snd_card_new (index[dev], id[dev], THIS_MODULE,
-                            sizeof(snd_wavefront_card_t));
-       if (card == NULL)
-               return NULL;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(snd_wavefront_card_t), &card);
+       if (err < 0)
+               return err;
 
        acard = card->private_data;
        acard->wavefront.irq = -1;
@@ -357,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
@@ -567,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);
@@ -616,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) {
index 1881cec11e78d221b55f4132219ec48c0cc9c147..99e1391b2eb42ffce2d7425621afa0c26134e770 100644 (file)
@@ -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;
index db495be01861ffee559d34221ff82a8624214502..c52691c2fc46df746aee9136545f1c4ed6aa1447 100644 (file)
@@ -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) {
index 4c63504348dc4ba155cfd8ab79a4e03347db8d84..66f3b48ceafcdcbedb7e4700a4ae8a341283cd3f 100644 (file)
@@ -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) {
index 41f870f8a11d21390e1caa473326d659274e28fc..6055fd6d3b38ee90ba6d19895363ef33db38f275 100644 (file)
@@ -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)
index a7f38e63303f82120ceffacb4f08daf4b75f889d..d1f242bd0ac544584ad9c7f4349261c7c7f37588 100644 (file)
@@ -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");
index 1a0fd65ec2809478d71f037f310f6a3f36a1823b..b36c551da566de2b73386727487c669c72360eda 100644 (file)
@@ -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)
index 8df6824b51cda258d2627d6eb30cbba1824e50b8..f557c155db482da8e83d163bd6059d9930621ad4 100644 (file)
@@ -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;
 
index ba570053d4d538c74b0c5f8b127ba41c2759acd8..542a0c65a92c52cc39fa3371020eb6dae5cb7940 100644 (file)
@@ -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;
index 226fe8237d31997c445f0337b4effca37f57bf37..9ce8548c03e459a381b1fb2c6fb6fb9706b9480b 100644 (file)
@@ -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");
index 0e6e5cc1c501e36f531baf07c23d31089f4d931a..c3136cccc559e86f90f978d9bb922ae305c5d140 100644 (file)
@@ -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");
index a36d4d1fd419f098e3dabdfa598914d49d92b378..9ec122383eefbab4492fe9d180e6737f7b4f9ed0 100644 (file)
@@ -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) {
index 3f00ddf450f81c287b198cdbdf4c8a17b180c4f8..eefcbf648ee1d95e4d80dae4c4043f75f2aa8fd7 100644 (file)
@@ -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);
index 333007c523a1f876b2deca492a71c59f93de86e4..1df96e76c4832146eec9110be12f4fbe54b8099a 100644 (file)
@@ -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)");
index 1aa1c04025407f2243d11a277f26b2a29da6c740..a299340519dfab53f07e3991124ca18223753c32 100644 (file)
@@ -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)
index 0e62205d4081d3da96606c9b48f7b568d221f7ca..b116456e77071ea75ba27e995c98ca4adb933ca8 100644 (file)
@@ -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)
index 1a74ca62c31484a8b8923f324771c43fcd1491a3..c7899c32aba19d08b945da3e4c4e510d46fa6a8f 100644 (file)
@@ -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:
index 192e7842e181e4cbbe8c3f0be43c7cccb4213964..b9b07f464631ec84da04ebdac6c3a8c19806c10a 100644 (file)
@@ -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);
index e876b3263e462a9060b071e7974f1b0dcb90c583..c9b3e3d48cbcbf819e16e5d0a8535e8029310596 100644 (file)
@@ -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) {
index 6dea5b5cc77419814334addf8b22c06c5bee142c..dc464321d0f3ebda294e8e45de1db429122f4bc7 100644 (file)
@@ -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) {
index 826e6dec2e97cf1e834d08b4c380469cb4717c8a..ac1d72e0a1e4ba1233f1cc2e479e1b0eeae5456f 100644 (file)
@@ -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;
index 8dbc5c4ba421a03dd128050dbd271616efdee3ae..9d015a76eb691c6ed8cba64e58b6d3b8f810d4b8 100644 (file)
@@ -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);
 
index 8354c1a833129c7300b765ef918462a3852537f6..c7f3b994101cef1f335fde62e09a5d53616e4152 100644 (file)
@@ -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)
index 5ff4dbb62dad1412e3f7ca987052427086912944..31542adc6b7e34a34d2ef6dca5758cb1992ad8af 100644 (file)
@@ -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);
index 9bf95367c882b4fbe80558f254aa2b45456f9646..e00614cbceffbec319dbaf6b3ab39829c4d391ed 100644 (file)
@@ -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);
index 4cd9a1faaecc186732b1ad911ebfd74e3c59e77e..34a78afc26d0b33666c7b6cc6c9a3a65fe4a8ec2 100644 (file)
@@ -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)) {
index e9c3794bbcb8a409751cc26ab466764d37fd1698..dc97e8116141645d9d399cf8eee503979c267784 100644 (file)
@@ -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;
index c129f9e2072cb6970a1d5e83ad7b7f3950a4160b..60cdb9e0b68d23d112745c3dbe73354c124c1137 100644 (file)
@@ -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;
index 11e791b965f6a772588ac7dff64437b3ec836e70..f9603443f08679be8a2b3b66aabfaf22eb30256c 100644 (file)
@@ -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);
index 58d7cda03de5827f44b58ab435c602460c909b0f..bab1c700f4976c5e32891f9291cea69e84a50903 100644 (file)
@@ -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");
index bb8d8c766b9d1f5ee5e08f85a8a36694ac1b8058..7ff36d3f0f44f9078da5f08e8be89e8a32b0a485 100644 (file)
@@ -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");
index 19d3391e229f2f7e02615a12344142464dfcb902..671ff65db0298974494d7ca6e362c7a7559dc57e 100644 (file)
@@ -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);
index 93449e464566c019a5a0a3c11677bd8b2654fc56..33a843c193165ddbe7b0aa7b723784b46d2b6cf5 100644 (file)
@@ -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");
index 5f8006b4275019ddd475e55e0ea7c8238b514b47..8b79969034be24853b57afda72a88566ed316d10 100644 (file)
@@ -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);
index 59bbaf8f3e5b9bbe026fe13162e5258408598958..70141548f251236879c6d23765c318648cabca56 100644 (file)
@@ -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:
index f23a73577c2219cb7da2b03317bf1106b7e1f981..bfc19e36c4b698ac3798c91b2567512984b3148e 100644 (file)
@@ -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);
index 50c9f8a05082fa6c5aa67919203d80e030895b18..522a040855d41e7321414cfbd2b5c3e22b0d47a8 100644 (file)
@@ -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:
index 84f481d41efa5910eeda20b0b8840556d6fd6183..9c81e0b051130037bc3dff42de4b05cc7e535815 100644 (file)
@@ -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;
index 27cf2c28d1131eac14cf96ac3b55eb34c51ec543..7f95459c8b1f4e149a1acc7f54c9adb21acf6e39 100644 (file)
@@ -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);
index 3caacfb9d8e005c3382b76ef8a742b798837a77d..6f1034417a0209e6532ba33197f4490583a8ec6b 100644 (file)
@@ -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;
index e7ef3a1a25a89a4643b85c888435f22cb28c34a1..d7b966e7c4cf69270358a6070979e904e072f3d4 100644 (file)
@@ -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;
index 3fdd488d09759afca5389383c76590e57bb4dc63..55fb1c131f5809a1b2b62383c99c3ac6037e90c8 100644 (file)
@@ -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;
index 44d0c15e2b71a150cf2643194a978e6c6fa7ee95..05b3f795a1680167a3d09c3666fc3ea7c8272d82 100644 (file)
@@ -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;
index 71231cf1b2b0ac2c335236d40ba4a5f99543d47b..d4b4e0d0fee81872ba871972331339dc66cdf13a 100644 (file)
@@ -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;
index 2570907134d75cd89067b14865fbd90355749df9..bc539abb210582c01797a4115916e00088f3be92 100644 (file)
@@ -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;
index df2007e3be7cbf63bb18f68c3ee144b6b5a1520b..baf6d8e3dabc3e703f21337c79f5c25fceb6926c 100644 (file)
@@ -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");
index cd408b86c839b1833e6f6a743f3459cc780cf10a..c5601b0ad7cc4b8c52142d5f1da3e1ffad536dbb 100644 (file)
@@ -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)) {
index d94b16ffb38554660a8bd2647ad4d9024be2927f..21cef97d478dc8fb0a127d73453714d886facedf 100644 (file)
@@ -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],
index 1aafe956ee2b348d07d02925b6aa1fdd9ec7f7ee..d8705547dae106fb203193e0a3a8d892bbe48bb5 100644 (file)
@@ -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) {
index 5bd79d2a5a1555d80ba7466eca75baab6804714b..c086b762c150a30cfa651c7ff5b7805ad2c461da 100644 (file)
@@ -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) {
index acc352f4a44182f5f782fae7301d8bdde0eec235..fc9136c3e0d7824a67d88d4bbc5781e4b7ac375d 100644 (file)
@@ -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:
index 2631a554845e66c32ac446c283076061f092cfb3..4af66661f9b020b83956559847848b51647fde97 100644 (file)
@@ -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;
index 819aaaac432f839e5667b986142f6da609416d57..7dea74b71cf1ab8e1485a85b4e3f35b658a7b639 100644 (file)
@@ -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,20 +112,23 @@ 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);
-       if (! pdacf)
-               return -EIO;
+       if (!pdacf) {
+               snd_card_free(card);
+               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));
index 706602a40600718666c3a5e5fb7e957dc901e622..7445cc8a47d380df120dadd3b813aa62baf0ff38 100644 (file)
@@ -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;
 }
 
 
@@ -292,7 +296,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,16 +311,16 @@ 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);
-       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;
 
index c936225771ba0cd8381686c3c6b7424f288b051a..2e18ed0ea899f893e04c939d891b5010759e4afc 100644 (file)
@@ -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;
index 8f9e3859c37ca70f802fdb5c3f8f25ed75731b8d..ef2c3f417175aaec7b2cd656e43866f28f9289db 100644 (file)
@@ -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");
index 7c920f3e7fe35e4a917597d92b736011e8a62ba4..f551233c5a08d6958c14caebe24a1e227257e829 100644 (file)
@@ -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);
index f18c7a3e36d1dfb3194cf45b143911ec613b1626..580a1a534ad03a4e72571e611870d5fcf8570be3 100644 (file)
@@ -1308,17 +1308,17 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
 {
        struct snd_soc_card *card = socdev->card;
        struct snd_soc_codec *codec = card->codec;
-       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;
index f87933e48812d8c7aba976d64fd9477912c85e41..ba38912614b4f90fca9444611ddb2fa1944e87bc 100644 (file)
@@ -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");
index 41c387587474c9ccaef6ae1c228ad1dffde14977..7d93fa705ccf493135b36cefff7ea242812ca11b 100644 (file)
@@ -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");
index 23ed6f04a718c30d30db22e577974c4ee54f8190..af95ff1e126cc39a83d0e833fb0d126c334e6278 100644 (file)
@@ -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");
index 09802e8a6fb834419f8c752ac8edb7c68405de88..4c7b051f9d17705bfc9827113e4fc8f74792e7c7 100644 (file)
@@ -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;
index 41c36b055f6b3f980b7c8217ce6b1496efe6bc43..09aed2363cc94f466aca559730f64f03f5e0ac08 100644 (file)
@@ -336,9 +336,10 @@ 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;
        struct snd_card *card;
        struct snd_usb_caiaqdev *dev;
 
@@ -347,12 +348,12 @@ static struct snd_card* create_card(struct usb_device* usb_dev)
                        break;
 
        if (devnum >= SNDRV_CARDS)
-               return NULL;
+               return -ENODEV;
 
-       card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, 
-                                       sizeof(struct snd_usb_caiaqdev));
-       if (!card)
-               return NULL;
+       err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, 
+                             sizeof(struct snd_usb_caiaqdev), &card);
+       if (err < 0)
+               return err;
 
        dev = caiaqdev(card);
        dev->chip.dev = usb_dev;
@@ -362,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)
@@ -441,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));
index c709b9563226c0b343f98588f4bc91345c5bf185..eec32e1a3020ccfe23798e005e0a97a636676b2b 100644 (file)
@@ -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);
index 73e59f4403a483b16a041a9bba9f767e6b021c60..98276aafefe605040d7c18cd367fa4aa8096bd5a 100644 (file)
@@ -478,19 +478,21 @@ 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;
+       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)
-               return NULL;
+               return -ENODEV;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct us122l), &card);
+       if (err < 0)
+               return err;
        snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
 
        US122L(card)->chip.dev = device;
@@ -509,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)
index 11639bd72a518fe340f54236ccecf6c2667f7f67..af8b84954054a12aee12eb95c5732a99616544e1 100644 (file)
@@ -333,18 +333,21 @@ 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;
+       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)
-               return NULL;
+               return -ENODEV;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct usX2Ydev), &card);
+       if (err < 0)
+               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;
@@ -362,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;
 }
 
 /*
@@ -389,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)