From patchwork Sun Feb 8 10:28:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 5797201 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32580BF440 for ; Sun, 8 Feb 2015 10:29:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FC412012E for ; Sun, 8 Feb 2015 10:29:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 03F722012B for ; Sun, 8 Feb 2015 10:29:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 801C2260655; Sun, 8 Feb 2015 11:29:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 0311E260641; Sun, 8 Feb 2015 11:29:10 +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 39F33260646; Sun, 8 Feb 2015 11:29:09 +0100 (CET) Received: from smtp311.phy.lolipop.jp (smtp311.phy.lolipop.jp [210.157.22.79]) by alsa0.perex.cz (Postfix) with ESMTP id 3C1C626063A for ; Sun, 8 Feb 2015 11:29:01 +0100 (CET) Received: from smtp311.phy.lolipop.lan (HELO smtp311.phy.lolipop.jp) (172.17.1.11) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp311.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Sun, 08 Feb 2015 19:28:58 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp311.phy.lolipop.jp (LOLIPOP-Fsecure); Sun, 08 Feb 2015 19:28:56 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 8 Feb 2015 19:28:56 +0900 Message-Id: <1423391336-2167-1-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ALSA: control: fix failure to return numerical ID in event data 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 Currently an instance of control has zero as its member for numerical ID even if any IDs are assigned to. According to this bug, any userspace applications cannot identify controls by the ID when handling any events. On the other hand, the other members such as name are still valid, therefore applications can identify controls without fixing this. This is not preferable because the ID has an advantage to allow userspace applications to distinguish each controls by itself, without any combinations. Signed-off-by: Takashi Sakamoto --- sound/core/control.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 60caba1..d482997 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -352,6 +352,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) if (id.index > UINT_MAX - kcontrol->count) goto error; + /* Any ID numbers are not assigned to this control yet. */ + id.numid = 0; + down_write(&card->controls_rwsem); if (snd_ctl_find_id(card, &id)) { up_write(&card->controls_rwsem); @@ -369,12 +372,17 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) err = -ENOMEM; goto error; } - list_add_tail(&kcontrol->list, &card->controls); - card->controls_count += kcontrol->count; + + /* Now this control is allowed to have ID number. */ kcontrol->id.numid = card->last_numid + 1; card->last_numid += kcontrol->count; - count = kcontrol->count; + card->controls_count += kcontrol->count; + list_add_tail(&kcontrol->list, &card->controls); + up_write(&card->controls_rwsem); + + id = kcontrol->id; + count = kcontrol->count; for (idx = 0; idx < count; idx++, id.index++, id.numid++) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); return 0;