From patchwork Fri Jul 13 12:50:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10523211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B556602B3 for ; Fri, 13 Jul 2018 12:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0951729963 for ; Fri, 13 Jul 2018 12:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF48A2996E; Fri, 13 Jul 2018 12:51:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 416FF29963 for ; Fri, 13 Jul 2018 12:51:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F1F3267735; Fri, 13 Jul 2018 14:50:57 +0200 (CEST) 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 89782267727; Fri, 13 Jul 2018 14:50:52 +0200 (CEST) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id D97B0267700 for ; Fri, 13 Jul 2018 14:50:50 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id n17-v6so9331462wmh.2 for ; Fri, 13 Jul 2018 05:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5AtKow8jsYotDy005opx8iz+uph+cDuvICmcTFVjXK0=; b=WMnvtPRueVzQbsKfBUU+LK5Ixi05eAUY1sFI674KYh1MnQPtYhvXsf8ho5jcAbP90u u8WhmXv0zXkqZGLX49eNGmQI3+UqAyHtveFQr2+UgSruONUamZTyFcYB64kkpcfLqcGr 6xlEj0ePCFhMD5meLxfhvBPWoqO75uNhZfnH50+CJ5iX58i14mKGO0QOuFI8Ccv5HkCo wN+UXvI7TfvyLeHh9JLus0Z20qH9gLb6BCJIbfTIPCcGHmg8QeSASjhsOQb7RUr26paG +vj7IObMSlS8sVTF/LMvvvy02y2n3wJkagq79rnPu4OdxH5B7p30fk90RrZjDOm2HdDu VP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5AtKow8jsYotDy005opx8iz+uph+cDuvICmcTFVjXK0=; b=uHeGELxAthXENXZWFvE9SDNaUM4QrKGMNkGVixVYgx41hjyfTLKSado13yNS9Vcmko 8GUqHVdXTJ8eNgvD9EHtm7z0MwRMrpPKAww2h1qROp/LmKxF5ItNfEo4ZriCXC85ihPq /NJ9HgYgqXXSuCCXFWY+wWBvUBbb3hwocjqSc4e89msQ4z+mXSlPBBSwcaKh5t8G65nB ANx5zxHypCE/Tl2PlLPprBE7qsc0kwoCW9R0SDcNoD6T0uKtk73sjoAC7Cgyhg+N3z2Q NlSuY1/vOFTQUcoMpW4dNS+6Sfw6eMDpPXlS+1QeAm/mKEJuX/wKMZ93yIVtqxWYhkw4 N35g== X-Gm-Message-State: AOUpUlEMCD408B9ewLUXLxXh/xNggI63CrO+fuJ9YxwgvssHl+FYC9zG aTaK/wvWEsdY5l9892dH4OrqDQ== X-Google-Smtp-Source: AAOMgpdhd0JvZaedIBVko9T6jnOpD365SzRRTa3jXWvaHB/0mXTgPGYnKWcxm2P/Shh6PwMgqIOaFg== X-Received: by 2002:a1c:c904:: with SMTP id f4-v6mr4137276wmb.140.1531486250354; Fri, 13 Jul 2018 05:50:50 -0700 (PDT) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f76-v6sm8541524wme.30.2018.07.13.05.50.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jul 2018 05:50:49 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Date: Fri, 13 Jul 2018 14:50:43 +0200 Message-Id: <20180713125043.13242-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180713125043.13242-1-jbrunet@baylibre.com> References: <20180713125043.13242-1-jbrunet@baylibre.com> Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jerome Brunet Subject: [alsa-devel] [PATCH 2/2] ASoC: allow soc-core to pick up name prefixes from component nodes 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 When the component does not match the configuration table provided by the card, let soc-core check the component node for a name prefix Signed-off-by: Jerome Brunet --- sound/soc/soc-core.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 00bd58d167dd..3be0310d5c81 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1193,15 +1193,27 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); +static void soc_set_of_name_prefix(struct snd_soc_component *component) +{ + struct device_node *component_of_node = component->dev->of_node; + const char *str; + int ret; + + if (!component_of_node && component->dev->parent) + component_of_node = component->dev->parent->of_node; + + ret = of_property_read_string(component_of_node, "sound-name-prefix", + &str); + if (!ret) + component->name_prefix = str; +} + static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_component *component) { int i; - if (card->codec_conf == NULL) - return; - - for (i = 0; i < card->num_configs; i++) { + for (i = 0; i < card->num_configs && card->codec_conf; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; struct device_node *component_of_node = component->dev->of_node; @@ -1213,8 +1225,14 @@ static void soc_set_name_prefix(struct snd_soc_card *card, if (map->dev_name && strcmp(component->name, map->dev_name)) continue; component->name_prefix = map->name_prefix; - break; + return; } + + /* + * If there is no configuration table or no match in the table, + * check if a prefix is provided in the node + */ + soc_set_of_name_prefix(component); } static int soc_probe_component(struct snd_soc_card *card,