From patchwork Wed Feb 12 11:20:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 3637291 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D73C4BF13A for ; Wed, 12 Feb 2014 11:30:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47F32201CD for ; Wed, 12 Feb 2014 11:30:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 663672012B for ; Wed, 12 Feb 2014 11:29:54 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8741A26514A; Wed, 12 Feb 2014 12:29:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 524E5265012; Wed, 12 Feb 2014 12:27:48 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8D7F4265010; Wed, 12 Feb 2014 12:27:46 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9E4342650C1 for ; Wed, 12 Feb 2014 12:20:14 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8D427ABF7 for ; Wed, 12 Feb 2014 11:20:14 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 12 Feb 2014 12:20:12 +0100 Message-Id: <1392204013-12334-3-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1392204013-12334-1-git-send-email-tiwai@suse.de> References: <1392204013-12334-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH 2/3] ALSA: Use static groups for id and number card sysfs attr files X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ... instead of calling device_create_file() manually. No functional change. Signed-off-by: Takashi Iwai --- sound/core/init.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/sound/core/init.c b/sound/core/init.c index 2c0301811828..46a9e7cb1c04 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), } static int snd_card_do_free(struct snd_card *card); +static const struct attribute_group *card_dev_attr_groups[]; static void release_card_device(struct device *dev) { @@ -245,6 +246,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid, card->card_dev.parent = parent; card->card_dev.class = sound_class; card->card_dev.release = release_card_device; + card->card_dev.groups = card_dev_attr_groups; err = kobject_set_name(&card->card_dev.kobj, "card%d", idx); if (err < 0) goto __error; @@ -671,8 +673,7 @@ card_id_store_attr(struct device *dev, struct device_attribute *attr, return count; } -static struct device_attribute card_id_attrs = - __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr); +static DEVICE_ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr); static ssize_t card_number_show_attr(struct device *dev, @@ -682,8 +683,22 @@ card_number_show_attr(struct device *dev, return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1); } -static struct device_attribute card_number_attrs = - __ATTR(number, S_IRUGO, card_number_show_attr, NULL); +static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL); + +static struct attribute *card_dev_attrs[] = { + &dev_attr_id.attr, + &dev_attr_number.attr, + NULL +}; + +static struct attribute_group card_dev_attr_group = { + .attrs = card_dev_attrs, +}; + +static const struct attribute_group *card_dev_attr_groups[] = { + &card_dev_attr_group, + NULL +}; /** * snd_card_register - register the soundcard @@ -737,15 +752,6 @@ int snd_card_register(struct snd_card *card) if (snd_mixer_oss_notify_callback) snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); #endif - if (card->registered) { - err = device_create_file(&card->card_dev, &card_id_attrs); - if (err < 0) - return err; - err = device_create_file(&card->card_dev, &card_number_attrs); - if (err < 0) - return err; - } - return 0; }