From patchwork Tue Mar 18 08:02:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 3847611 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 1F606BF540 for ; Tue, 18 Mar 2014 08:05:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BFF42037F for ; Tue, 18 Mar 2014 08:05:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0028D20142 for ; Tue, 18 Mar 2014 08:05:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A1F23262634; Tue, 18 Mar 2014 09:05:31 +0100 (CET) Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id BEBE6264EFA; Tue, 18 Mar 2014 09:02:21 +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 E1166264EFA; Tue, 18 Mar 2014 09:02:19 +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 smtp-out-224.synserver.de (smtp-out-230.synserver.de [212.40.185.230]) by alsa0.perex.cz (Postfix) with ESMTP id 1D2B6261AEC for ; Tue, 18 Mar 2014 09:01:47 +0100 (CET) Received: (qmail 31368 invoked by uid 0); 18 Mar 2014 08:01:46 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 30698 Received: from ppp-46-244-130-51.dynamic.mnet-online.de (HELO lars-adi-laptop.fritz.box) [46.244.130.51] by 217.119.54.81 with SMTP; 18 Mar 2014 08:01:45 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Tue, 18 Mar 2014 09:02:11 +0100 Message-Id: <1395129736-11938-9-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1395129736-11938-1-git-send-email-lars@metafoo.de> References: <1395129736-11938-1-git-send-email-lars@metafoo.de> Cc: Brian Austin , Lars-Peter Clausen , patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org, Paul Handrigan , Kuninori Morimoto , Peter Ujfalusi , Maxime Ripard , Charles Keepax Subject: [alsa-devel] [PATCH 08/13] ASoC: Track which components have been registered with snd_soc_register_component() 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 snd_soc_unregister_component() takes the parent device of the component as a parameter and then looks up the component based on this. This is a problem if multiple components are registered for the same parent device. Currently drivers do not do this, but some drivers register a CPU DAI component and a platform for the same parent device. This will become a problem once platforms are also made components. To make sure that snd_soc_unregister_component() will not accidentally unregister the platform in such a case only consider components that were registered with snd_soc_register_component(). This is only meant as short term stopgap solution to be able to continue componentisation. Long term we'll need something different. Signed-off-by: Lars-Peter Clausen --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index a355d0f..f8a79c1 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -662,6 +662,7 @@ struct snd_soc_component { unsigned int active; unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ + unsigned int registered_as_component:1; struct list_head list; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4df9859..1ee3dd6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3885,6 +3885,7 @@ int snd_soc_register_component(struct device *dev, } cmpnt->ignore_pmdown_time = true; + cmpnt->registered_as_component = true; return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL, dai_drv, num_dai, true); @@ -3900,7 +3901,7 @@ void snd_soc_unregister_component(struct device *dev) struct snd_soc_component *cmpnt; list_for_each_entry(cmpnt, &component_list, list) { - if (dev == cmpnt->dev) + if (dev == cmpnt->dev && cmpnt->registered_as_component) goto found; } return;