]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
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

1  2 
sound/pci/hda/hda_intel.c
sound/soc/soc-core.c
sound/usb/caiaq/caiaq-device.c

index 11e791b965f6a772588ac7dff64437b3ec836e70,ad5df2ae6f7d6d638611e7cbf8d60af1105e1e60..f9603443f08679be8a2b3b66aabfaf22eb30256c
@@@ -996,11 -996,10 +996,11 @@@ static irqreturn_t azx_interrupt(int ir
                                spin_unlock(&chip->reg_lock);
                                snd_pcm_period_elapsed(azx_dev->substream);
                                spin_lock(&chip->reg_lock);
 -                      } else {
 +                      } else if (chip->bus && chip->bus->workq) {
                                /* bogus IRQ, process it later */
                                azx_dev->irq_pending = 1;
 -                              schedule_work(&chip->irq_pending_work);
 +                              queue_work(chip->bus->workq,
 +                                         &chip->irq_pending_work);
                        }
                }
        }
@@@ -1742,6 -1741,7 +1742,6 @@@ static void azx_clear_irq_pending(struc
        for (i = 0; i < chip->num_streams; i++)
                chip->azx_dev[i].irq_pending = 0;
        spin_unlock_irq(&chip->reg_lock);
 -      flush_scheduled_work();
  }
  
  static struct snd_pcm_ops azx_pcm_ops = {
@@@ -2335,10 -2335,10 +2335,10 @@@ static int __devinit azx_probe(struct p
                return -ENOENT;
        }
  
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
-       if (!card) {
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       if (err < 0) {
                snd_printk(KERN_ERR SFX "Error creating card!\n");
-               return -ENOMEM;
+               return err;
        }
  
        err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
diff --combined sound/soc/soc-core.c
index f18c7a3e36d1dfb3194cf45b143911ec613b1626,318dfdd54d7f00065002d1d834e382bd827dea07..580a1a534ad03a4e72571e611870d5fcf8570be3
@@@ -234,7 -234,7 +234,7 @@@ static int soc_pcm_open(struct snd_pcm_
                cpu_dai->capture.active = codec_dai->capture.active = 1;
        cpu_dai->active = codec_dai->active = 1;
        cpu_dai->runtime = runtime;
 -      socdev->codec->active++;
 +      card->codec->active++;
        mutex_unlock(&pcm_mutex);
        return 0;
  
@@@ -264,7 -264,7 +264,7 @@@ static void close_delayed_work(struct w
        struct snd_soc_card *card = container_of(work, struct snd_soc_card,
                                                 delayed_work.work);
        struct snd_soc_device *socdev = card->socdev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        struct snd_soc_dai *codec_dai;
        int i;
  
@@@ -319,7 -319,7 +319,7 @@@ static int soc_codec_close(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
  
        mutex_lock(&pcm_mutex);
  
@@@ -387,7 -387,7 +387,7 @@@ static int soc_pcm_prepare(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        int ret = 0;
  
        mutex_lock(&pcm_mutex);
@@@ -553,7 -553,7 +553,7 @@@ static int soc_pcm_hw_free(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
  
        mutex_lock(&pcm_mutex);
  
@@@ -629,7 -629,7 +629,7 @@@ static int soc_suspend(struct platform_
        struct snd_soc_card *card = socdev->card;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        int i;
  
        /* Due to the resume being scheduled into a workqueue we could
@@@ -705,7 -705,7 +705,7 @@@ static void soc_resume_deferred(struct 
        struct snd_soc_device *socdev = card->socdev;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        struct platform_device *pdev = to_platform_device(socdev->dev);
        int i;
  
@@@ -982,8 -982,8 +982,8 @@@ static struct platform_driver soc_drive
  static int soc_new_pcm(struct snd_soc_device *socdev,
        struct snd_soc_dai_link *dai_link, int num)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
 +      struct snd_soc_codec *codec = card->codec;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *codec_dai = dai_link->codec_dai;
        struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
  
        rtd->dai = dai_link;
        rtd->socdev = socdev;
 -      codec_dai->codec = socdev->codec;
 +      codec_dai->codec = card->codec;
  
        /* check client and interface hw capabilities */
        sprintf(new_name, "%s %s-%d", dai_link->stream_name, codec_dai->name,
  }
  
  /* codec register dump */
 -static ssize_t soc_codec_reg_show(struct snd_soc_device *devdata, char *buf)
 +static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
  {
 -      struct snd_soc_codec *codec = devdata->codec;
        int i, step = 1, count = 0;
  
        if (!codec->reg_cache_size)
@@@ -1089,7 -1090,7 +1089,7 @@@ static ssize_t codec_reg_show(struct de
        struct device_attribute *attr, char *buf)
  {
        struct snd_soc_device *devdata = dev_get_drvdata(dev);
 -      return soc_codec_reg_show(devdata, buf);
 +      return soc_codec_reg_show(devdata->card->codec, buf);
  }
  
  static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
@@@ -1106,10 -1107,12 +1106,10 @@@ static ssize_t codec_reg_read_file(stru
  {
        ssize_t ret;
        struct snd_soc_codec *codec = file->private_data;
 -      struct device *card_dev = codec->card->dev;
 -      struct snd_soc_device *devdata = card_dev->driver_data;
        char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 -      ret = soc_codec_reg_show(devdata, buf);
 +      ret = soc_codec_reg_show(codec, buf);
        if (ret >= 0)
                ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
        kfree(buf);
@@@ -1306,19 -1309,19 +1306,19 @@@ EXPORT_SYMBOL_GPL(snd_soc_test_bits)
   */
  int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
-       int ret = 0, i;
 +      struct snd_soc_codec *codec = card->codec;
+       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;
@@@ -1352,8 -1355,8 +1352,8 @@@ EXPORT_SYMBOL_GPL(snd_soc_new_pcms)
   */
  int snd_soc_init_card(struct snd_soc_device *socdev)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
 +      struct snd_soc_codec *codec = card->codec;
        int ret = 0, i, ac97 = 0, err = 0;
  
        for (i = 0; i < card->num_links; i++) {
        if (err < 0)
                printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
  
 -      soc_init_codec_debugfs(socdev->codec);
 +      soc_init_codec_debugfs(codec);
        mutex_unlock(&codec->mutex);
  
  out:
@@@ -1418,14 -1421,14 +1418,14 @@@ EXPORT_SYMBOL_GPL(snd_soc_init_card)
   */
  void snd_soc_free_pcms(struct snd_soc_device *socdev)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = socdev->card->codec;
  #ifdef CONFIG_SND_SOC_AC97_BUS
        struct snd_soc_dai *codec_dai;
        int i;
  #endif
  
        mutex_lock(&codec->mutex);
 -      soc_cleanup_codec_debugfs(socdev->codec);
 +      soc_cleanup_codec_debugfs(codec);
  #ifdef CONFIG_SND_SOC_AC97_BUS
        for (i = 0; i < codec->num_dai; i++) {
                codec_dai = &codec->dai[i];
@@@ -1491,37 -1494,6 +1491,37 @@@ struct snd_kcontrol *snd_soc_cnew(cons
  }
  EXPORT_SYMBOL_GPL(snd_soc_cnew);
  
 +/**
 + * snd_soc_add_controls - add an array of controls to a codec.
 + * Convienience function to add a list of controls. Many codecs were
 + * duplicating this code.
 + *
 + * @codec: codec to add controls to
 + * @controls: array of controls to add
 + * @num_controls: number of elements in the array
 + *
 + * Return 0 for success, else error.
 + */
 +int snd_soc_add_controls(struct snd_soc_codec *codec,
 +      const struct snd_kcontrol_new *controls, int num_controls)
 +{
 +      struct snd_card *card = codec->card;
 +      int err, i;
 +
 +      for (i = 0; i < num_controls; i++) {
 +              const struct snd_kcontrol_new *control = &controls[i];
 +              err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL));
 +              if (err < 0) {
 +                      dev_err(codec->dev, "%s: Failed to add %s\n",
 +                              codec->name, control->name);
 +                      return err;
 +              }
 +      }
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(snd_soc_add_controls);
 +
  /**
   * snd_soc_info_enum_double - enumerated double mixer info callback
   * @kcontrol: mixer control
@@@ -1612,6 -1584,37 +1612,6 @@@ int snd_soc_put_enum_double(struct snd_
  }
  EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
  
 -/**
 - * snd_soc_info_value_enum_double - semi enumerated double mixer info callback
 - * @kcontrol: mixer control
 - * @uinfo: control element information
 - *
 - * Callback to provide information about a double semi enumerated
 - * mixer control.
 - *
 - * Semi enumerated mixer: the enumerated items are referred as values. Can be
 - * used for handling bitfield coded enumeration for example.
 - *
 - * Returns 0 for success.
 - */
 -int snd_soc_info_value_enum_double(struct snd_kcontrol *kcontrol,
 -      struct snd_ctl_elem_info *uinfo)
 -{
 -      struct soc_value_enum *e = (struct soc_value_enum *)
 -                      kcontrol->private_value;
 -
 -      uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
 -      uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
 -      uinfo->value.enumerated.items = e->max;
 -
 -      if (uinfo->value.enumerated.item > e->max - 1)
 -              uinfo->value.enumerated.item = e->max - 1;
 -      strcpy(uinfo->value.enumerated.name,
 -              e->texts[uinfo->value.enumerated.item]);
 -      return 0;
 -}
 -EXPORT_SYMBOL_GPL(snd_soc_info_value_enum_double);
 -
  /**
   * snd_soc_get_value_enum_double - semi enumerated double mixer get callback
   * @kcontrol: mixer control
@@@ -1628,7 -1631,8 +1628,7 @@@ int snd_soc_get_value_enum_double(struc
        struct snd_ctl_elem_value *ucontrol)
  {
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 -      struct soc_value_enum *e = (struct soc_value_enum *)
 -                      kcontrol->private_value;
 +      struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        unsigned short reg_val, val, mux;
  
        reg_val = snd_soc_read(codec, e->reg);
@@@ -1667,7 -1671,8 +1667,7 @@@ int snd_soc_put_value_enum_double(struc
        struct snd_ctl_elem_value *ucontrol)
  {
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 -      struct soc_value_enum *e = (struct soc_value_enum *)
 -                      kcontrol->private_value;
 +      struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        unsigned short val;
        unsigned short mask;
  
index 41c36b055f6b3f980b7c8217ce6b1496efe6bc43,55a9075cb097371e67a86fd3558e80047f128f1d..09aed2363cc94f466aca559730f64f03f5e0ac08
@@@ -42,7 -42,7 +42,7 @@@
  #endif
  
  MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
 -MODULE_DESCRIPTION("caiaq USB audio, version 1.3.9");
 +MODULE_DESCRIPTION("caiaq USB audio, version 1.3.10");
  MODULE_LICENSE("GPL");
  MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
                         "{Native Instruments, RigKontrol3},"
@@@ -336,9 -336,10 +336,10 @@@ static void __devinit setup_card(struc
                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;
  
                        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;
        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 +443,10 @@@ static int __devinit snd_probe(struct u
        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));