Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2172084ybv; Fri, 14 Feb 2020 12:58:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzxJJYNuQdMxBYKUp+nh4tmiB7u+5NNQAymnRf61M7uaeQM6AhMYHyuxpq/VU+VdegAuO18 X-Received: by 2002:a9d:6d1a:: with SMTP id o26mr3617253otp.141.1581713906906; Fri, 14 Feb 2020 12:58:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581713906; cv=none; d=google.com; s=arc-20160816; b=SAqu3vW1Mce6OsvJvQbDJpKQsriYFizyBvtCiKE1uY6gQ4WW+oVeIWaDAI4oRuxPzY 8vN9jMSF+bXdLBT4cxuPGvjawuBRtGxIet2hhJL+M+R7lgbwSQngr8FigpXf/EZHY4pu qflprAoTNYRWMOADPmpC3gL2OuFMptjoUI2kxX8Ntd3zbtaebaOq/1vaUl9hFGAjrviu HSyiq175lbBU9yNv1DSG3dFNmRwYbSrGdGtf2eeHhW06P697/hiG1NBsWjBu9wN+Lbm7 gBltn46IFpEtulOfAojQkK9MRX43i9FT2JldQDJ9CgbLD8gaemsALwHGKTNE0OoqA3Jy V1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:subject:cc:to:from :date; bh=+7ih7QHCCoHATtIHRPam7O+MfN/TS8oaBrVa3UEPj/k=; b=SUiepYLtutW3sRhRFNePBfZlqRMapy3Q72QHpmIzbRl0/4LbL12TfJbmjERIlw09l6 YMhSXsY+O8cdk0BvtFyAoQ8ug3IfrIQHfQc9HirJORdR2m6A+8FcuPjyutxdTotPVwVx /qOYpeYNUa9k1IuCpwgZoFY+rbB8oL1Su7Rx5FXRw/fFM3fob04CnldNaQ+SkJ9RMnDu JmWUgNOlozYJ6Xl6OOP1Tneu74+4Z1xc/SIqx8Bv3p50AutQqBjNP7Lp3sAOoJLgPOpo VC3eUK0N8CuAC/WGFqohJmpsW5zWAdpaYTadNhiml1tdQWgdA1kLnWb6dEdJpqP1T6TP rSNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si3256146otp.260.2020.02.14.12.58.14; Fri, 14 Feb 2020 12:58:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388880AbgBNU4m (ORCPT + 99 others); Fri, 14 Feb 2020 15:56:42 -0500 Received: from foss.arm.com ([217.140.110.172]:45032 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388106AbgBNU4l (ORCPT ); Fri, 14 Feb 2020 15:56:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE26D30E; Fri, 14 Feb 2020 12:56:40 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 624433F68F; Fri, 14 Feb 2020 12:56:40 -0800 (PST) Date: Fri, 14 Feb 2020 20:56:38 +0000 From: Mark Brown To: Jerome Brunet Cc: alsa-devel@alsa-project.org, Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown Subject: Applied "ASoC: core: ensure component names are unique" to the asoc tree In-Reply-To: <20200214134704.342501-1-jbrunet@baylibre.com> Message-Id: X-Patchwork-Hint: ignore Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: core: ensure component names are unique has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From b2354e4009a773c00054b964d937e1b81cb92078 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Fri, 14 Feb 2020 14:47:04 +0100 Subject: [PATCH] ASoC: core: ensure component names are unique Make sure each ASoC component is registered with a unique name. The component is derived from the device name. If a device registers more than one component, the component names will be the same. This usually brings up a warning about the debugfs directory creation of the component since directory already exists. In such case, start numbering the component of the device so the names don't collide anymore. Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20200214134704.342501-1-jbrunet@baylibre.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 03b87427faa7..6a58a8f6e3c4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2446,6 +2446,33 @@ static int snd_soc_register_dais(struct snd_soc_component *component, return ret; } +static char *snd_soc_component_unique_name(struct device *dev, + struct snd_soc_component *component) +{ + struct snd_soc_component *pos; + int count = 0; + char *name, *unique; + + name = fmt_single_name(dev, &component->id); + if (!name) + return name; + + /* Count the number of components registred by the device */ + for_each_component(pos) { + if (dev == pos->dev) + count++; + } + + /* Keep naming as it is for the 1st component */ + if (!count) + return name; + + unique = devm_kasprintf(dev, GFP_KERNEL, "%s-%d", name, count); + devm_kfree(dev, name); + + return unique; +} + static int snd_soc_component_initialize(struct snd_soc_component *component, const struct snd_soc_component_driver *driver, struct device *dev) { @@ -2454,7 +2481,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, INIT_LIST_HEAD(&component->card_list); mutex_init(&component->io_mutex); - component->name = fmt_single_name(dev, &component->id); + component->name = snd_soc_component_unique_name(dev, component); if (!component->name) { dev_err(dev, "ASoC: Failed to allocate name\n"); return -ENOMEM; -- 2.20.1