aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-01-29 05:54:10 -0500
committerTakashi Iwai <tiwai@suse.de>2014-02-14 02:14:12 -0500
commit34356dbdb64e9f12cc8ce1bb0d9e38a75b1e4638 (patch)
treeb6a9f9a3747212a3da05e42d44cfad633954ed58 /sound/core
parent8bfb181c17d20956f156e84638912e00e1aaca86 (diff)
ALSA: Use static groups for id and number card sysfs attr files
... instead of calling device_create_file() manually. No functional change. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/init.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index f7875049c5e1..ff96eda898e3 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -157,6 +157,7 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int),
157} 157}
158 158
159static int snd_card_do_free(struct snd_card *card); 159static int snd_card_do_free(struct snd_card *card);
160static const struct attribute_group *card_dev_attr_groups[];
160 161
161static void release_card_device(struct device *dev) 162static void release_card_device(struct device *dev)
162{ 163{
@@ -245,6 +246,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
245 card->card_dev.parent = parent; 246 card->card_dev.parent = parent;
246 card->card_dev.class = sound_class; 247 card->card_dev.class = sound_class;
247 card->card_dev.release = release_card_device; 248 card->card_dev.release = release_card_device;
249 card->card_dev.groups = card_dev_attr_groups;
248 err = kobject_set_name(&card->card_dev.kobj, "card%d", idx); 250 err = kobject_set_name(&card->card_dev.kobj, "card%d", idx);
249 if (err < 0) 251 if (err < 0)
250 goto __error; 252 goto __error;
@@ -679,8 +681,7 @@ card_id_store_attr(struct device *dev, struct device_attribute *attr,
679 return count; 681 return count;
680} 682}
681 683
682static struct device_attribute card_id_attrs = 684static DEVICE_ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr);
683 __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr);
684 685
685static ssize_t 686static ssize_t
686card_number_show_attr(struct device *dev, 687card_number_show_attr(struct device *dev,
@@ -690,8 +691,22 @@ card_number_show_attr(struct device *dev,
690 return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1); 691 return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1);
691} 692}
692 693
693static struct device_attribute card_number_attrs = 694static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL);
694 __ATTR(number, S_IRUGO, card_number_show_attr, NULL); 695
696static struct attribute *card_dev_attrs[] = {
697 &dev_attr_id.attr,
698 &dev_attr_number.attr,
699 NULL
700};
701
702static struct attribute_group card_dev_attr_group = {
703 .attrs = card_dev_attrs,
704};
705
706static const struct attribute_group *card_dev_attr_groups[] = {
707 &card_dev_attr_group,
708 NULL
709};
695 710
696/** 711/**
697 * snd_card_register - register the soundcard 712 * snd_card_register - register the soundcard
@@ -745,15 +760,6 @@ int snd_card_register(struct snd_card *card)
745 if (snd_mixer_oss_notify_callback) 760 if (snd_mixer_oss_notify_callback)
746 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); 761 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
747#endif 762#endif
748 if (card->registered) {
749 err = device_create_file(&card->card_dev, &card_id_attrs);
750 if (err < 0)
751 return err;
752 err = device_create_file(&card->card_dev, &card_number_attrs);
753 if (err < 0)
754 return err;
755 }
756
757 return 0; 763 return 0;
758} 764}
759 765