Merge tag 'mmc-updates-for-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / sound / core / pcm.c
index 091a05c1d5b30506a788cffe704e9b15c346cab4..43932e8dce669a57a0908ffbd57585a858d1616b 100644 (file)
@@ -338,7 +338,8 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
 
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (! info) {
-               printk(KERN_DEBUG "snd_pcm_proc_info_read: cannot malloc\n");
+               pcm_dbg(substream->pcm,
+                       "snd_pcm_proc_info_read: cannot malloc\n");
                return;
        }
 
@@ -660,7 +661,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        if (substream_count > 0 && !pcm->internal) {
                err = snd_pcm_stream_proc_init(pstr);
                if (err < 0) {
-                       snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
+                       pcm_err(pcm, "Error in snd_pcm_stream_proc_init\n");
                        return err;
                }
        }
@@ -668,7 +669,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        for (idx = 0, prev = NULL; idx < substream_count; idx++) {
                substream = kzalloc(sizeof(*substream), GFP_KERNEL);
                if (substream == NULL) {
-                       snd_printk(KERN_ERR "Cannot allocate PCM substream\n");
+                       pcm_err(pcm, "Cannot allocate PCM substream\n");
                        return -ENOMEM;
                }
                substream->pcm = pcm;
@@ -685,7 +686,8 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
                if (!pcm->internal) {
                        err = snd_pcm_substream_proc_init(substream);
                        if (err < 0) {
-                               snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
+                               pcm_err(pcm,
+                                       "Error in snd_pcm_stream_proc_init\n");
                                if (prev == NULL)
                                        pstr->substream = NULL;
                                else
@@ -724,7 +726,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
                *rpcm = NULL;
        pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
        if (pcm == NULL) {
-               snd_printk(KERN_ERR "Cannot allocate PCM\n");
+               dev_err(card->dev, "Cannot allocate PCM\n");
                return -ENOMEM;
        }
        pcm->card = card;
@@ -1016,8 +1018,20 @@ static ssize_t show_pcm_class(struct device *dev,
         return snprintf(buf, PAGE_SIZE, "%s\n", str);
 }
 
-static struct device_attribute pcm_attrs =
-       __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
+static DEVICE_ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
+static struct attribute *pcm_dev_attrs[] = {
+       &dev_attr_pcm_class.attr,
+       NULL
+};
+
+static struct attribute_group pcm_dev_attr_group = {
+       .attrs  = pcm_dev_attrs,
+};
+
+static const struct attribute_group *pcm_dev_attr_groups[] = {
+       &pcm_dev_attr_group,
+       NULL
+};
 
 static int snd_pcm_dev_register(struct snd_device *device)
 {
@@ -1067,8 +1081,18 @@ static int snd_pcm_dev_register(struct snd_device *device)
                        mutex_unlock(&register_mutex);
                        return err;
                }
-               snd_add_device_sysfs_file(devtype, pcm->card, pcm->device,
-                                         &pcm_attrs);
+
+               dev = snd_get_device(devtype, pcm->card, pcm->device);
+               if (dev) {
+                       err = sysfs_create_groups(&dev->kobj,
+                                                 pcm_dev_attr_groups);
+                       if (err < 0)
+                               dev_warn(dev,
+                                        "pcm %d:%d: cannot create sysfs groups\n",
+                                        pcm->card->number, pcm->device);
+                       put_device(dev);
+               }
+
                for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
                        snd_pcm_timer_init(substream);
        }