From patchwork Mon Feb 15 12:19:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Agarwal X-Patchwork-Id: 8314081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 68E559F6E4 for ; Mon, 15 Feb 2016 12:20:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BCC720303 for ; Mon, 15 Feb 2016 12:20:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 52787201FE for ; Mon, 15 Feb 2016 12:20:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 65040265182; Mon, 15 Feb 2016 13:20:50 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F901261B14; Mon, 15 Feb 2016 13:19:55 +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 8701B261B14; Mon, 15 Feb 2016 13:19:54 +0100 (CET) Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by alsa0.perex.cz (Postfix) with ESMTP id B878326063A for ; Mon, 15 Feb 2016 13:19:48 +0100 (CET) Received: by mail-pf0-f175.google.com with SMTP id e127so86964051pfe.3 for ; Mon, 15 Feb 2016 04:19:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xZHUSds3oxInw27wKjHVdyxUaxaJEBEyXk6VeKTvBZY=; b=V+N7cXuW/zHFyiy3l4DA5Zhd8P4XQFMz1R4oZJnpsiUnOuAJXCxiX2C2DEo1QD89M/ tohJD4ocQYk2+Kd5bAo/oUuJ5LkKRPLH8M3N+tFXm9nhxI3dNXabJeELbjKgL/miA5je n5UdWKPVN7Vk/CpeQNyxUSnJZbq13VcYjp5cI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xZHUSds3oxInw27wKjHVdyxUaxaJEBEyXk6VeKTvBZY=; b=DQT1fIr7VTZiiSxIUbhlblqnWE7r2qFyjtDfL/ZVXKf+eH6/2pI85r55yMzN0Kd18N i9eCc4i5hy2nZEYfx0vKJoFB9FjIJT6TkdSR1x9esmc59n9j3p/bPLJ+app5Fyq1d0tn +7hZccWt3aYBS3uCrJB55udbH0SNScPclvebCeSOeRrGinCPmpI7VmXVnLG9VWNiFfbc zv7LpdUD+r0nLdWQhp1pLJlA5bLREFhJEdyxhLj1OUgb1lFz2Mv+YNj30T2KdKa56JIc Er2Viq29WLIQfa74gdTkUh5UvBthXzN8UbHSrR3wFWyA9xattxS+ZuiD6NJcjKDxA49Y q22A== X-Gm-Message-State: AG10YOTH8818EoGMoS8qBOZmsv1hOFTv4nZgi9VeI1852CsOQ222s25Bx4Va4xEvxsWq4plw X-Received: by 10.98.74.202 with SMTP id c71mr22930351pfj.25.1455538787364; Mon, 15 Feb 2016 04:19:47 -0800 (PST) Received: from localhost.localdomain ([122.167.245.244]) by smtp.googlemail.com with ESMTPSA id yh5sm38359848pab.13.2016.02.15.04.19.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Feb 2016 04:19:46 -0800 (PST) From: Vaibhav Agarwal To: alsa-devel@alsa-project.org Date: Mon, 15 Feb 2016 17:49:30 +0530 Message-Id: <1455538772-24926-3-git-send-email-vaibhav.agarwal@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455538772-24926-1-git-send-email-vaibhav.agarwal@linaro.org> References: <1455538772-24926-1-git-send-email-vaibhav.agarwal@linaro.org> Cc: liam.r.girdwood@linux.intel.com, mengdong.lin@linux.intel.com, vinod.koul@intel.com, Vaibhav Agarwal , peter.ujfalusi@ti.com, broonie@kernel.org Subject: [alsa-devel] [RFC 2/4] alsa: add locked variant for snd_ctl_remove_id 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 While removing kcontrols due to dynamic dai_link/codec removal, mutex/semaphore for soc-card/sound card is already acquired. Thus, added lock already acquired variant for ctl_remove_id. Signed-off-by: Vaibhav Agarwal --- include/sound/control.h | 1 + sound/core/control.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/sound/control.h b/include/sound/control.h index 21d047f..8faea10 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -125,6 +125,7 @@ int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace); int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); +int snd_ctl_remove_id_locked(struct snd_card *card, struct snd_ctl_elem_id *id); int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id); int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, int active); diff --git a/sound/core/control.c b/sound/core/control.c index a85d455..dca1998 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -530,6 +530,29 @@ int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) EXPORT_SYMBOL(snd_ctl_remove_id); /** + * snd_ctl_remove_id_locked - remove the control of the given id and release it + * @card: the card instance + * @id: the control id to remove + * + * Finds the control instance with the given id, removes it from the + * card list and releases it. + * + * Return: 0 if successful, or a negative error code on failure. + */ +int snd_ctl_remove_id_locked(struct snd_card *card, struct snd_ctl_elem_id *id) +{ + struct snd_kcontrol *kctl; + int ret; + + kctl = snd_ctl_find_id(card, id); + if (kctl == NULL) + return -ENOENT; + ret = snd_ctl_remove(card, kctl); + return ret; +} +EXPORT_SYMBOL(snd_ctl_remove_id_locked); + +/** * snd_ctl_remove_user_ctl - remove and release the unlocked user control * @file: active control handle * @id: the control id to remove