diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-02-25 08:30:50 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-02-25 12:12:49 +0100 |
commit | caa751bad444268d756b48ca03d7cceda3430cc8 (patch) | |
tree | 1bca8a78c67dc2d54e6a83c3ec81dbcc302676d0 /sound/core/pcm.c | |
parent | Merge branch 'for-linus' into HEAD (diff) | |
download | linux-caa751bad444268d756b48ca03d7cceda3430cc8.tar.xz linux-caa751bad444268d756b48ca03d7cceda3430cc8.zip |
ALSA: Create sysfs attribute files via groups
Instead of calling each time device_create_file(), create the groups
of sysfs attribute files at once in a normal way. Add a new helper
function, snd_get_device(), to return the associated device object,
so that we can handle the sysfs addition locally.
Since the sysfs file addition is done differently now,
snd_add_device_sysfs_file() helper function is removed.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r-- | sound/core/pcm.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9defdaef520b..43932e8dce66 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1018,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) { @@ -1069,8 +1081,18 @@ static int snd_pcm_dev_register(struct snd_device *device) mutex_unlock(®ister_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); } |