Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2325128rwd; Wed, 14 Jun 2023 00:53:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SAB4/nkhmNIm4t4b7xI1xDDZP+5izsM/2x0TM+JPShhW9OEMjoVREEA8BShPBWd5r2/83 X-Received: by 2002:aa7:c250:0:b0:518:7d79:895f with SMTP id y16-20020aa7c250000000b005187d79895fmr1178447edo.16.1686729227864; Wed, 14 Jun 2023 00:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686729227; cv=none; d=google.com; s=arc-20160816; b=MJANY4y0jvv4mjG9MzJw2SGX8OcY3ov6TMKt1yn1Ygc6gJZvnw5nR5joWp0QhHAVay Pl6NtYfvjlopWDUvv26IcycnXYM65k/L/80SGLK+vX2S6jH8yYco91T8n1sBAmpMideH e1sdY0XpQsd9AbXbHtOqeV7If4GqZ/BadA7c20ZhzHk6ja2fE5Kc+++/jcBxjKSXXQMH A9xzeU8Pb29mUQqDbAz9HF5I+EsL6fvUc8MgB7tz4lU3XVi9SHicIOtlwK0GLedHyae7 TtlFsREHtuEMPlson7rIIbU3+D2JKluOkWLVfIpXk4kiRTNHlo0jDXe+wLHXoMBPWDNu /XWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WiCubefUJT8lqguruRQEQMdku90oEPaE9zL5TkFrvME=; b=hdVQtRzy8kKwOBnpII8nNMFXKM/begZYQ0uuzTmb3cs3mPOlOLRy/W6sBafFZqOFFT 8eGb2ALNya3jqFdCDVIaosWWTKstsRn0CQLgwOO2IFVTkmOyKqFeeWd3dyO1TQyAJ6JO 8kAgPSYcZne3ZoXUok0B3MR7UuLGfDDW1Jv2nUiJ+HRlh5ldGL63UxlHpZ+iZ1zTzkwH OJ5nb7Zh11hWEhbZP6kCdbjvM+W32ArJCK6/8w7zBZxZAoCgG/9MqVIm4qw80sowWkBp AkOjKRI1Vksu1hutORELoKnrBd6xR4erOV39DWJed/Ioj9WCx8mNXQV/oZ6zHx84Ar11 lDvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iFxV+tYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a056402028e00b00518911e62d0si687062edv.26.2023.06.14.00.53.23; Wed, 14 Jun 2023 00:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iFxV+tYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243300AbjFNHvO (ORCPT + 99 others); Wed, 14 Jun 2023 03:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243529AbjFNHt4 (ORCPT ); Wed, 14 Jun 2023 03:49:56 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C32691FF5; Wed, 14 Jun 2023 00:49:48 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686728987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WiCubefUJT8lqguruRQEQMdku90oEPaE9zL5TkFrvME=; b=iFxV+tYN3v2+t2eWuNKrLNLcS4hLiZq1hZLuJfUb3iK26KWVn+Nt9caJC65E6kaAB+2Lz1 3rZvZtWxizsXeo6pJFK/pe2F2lQMmK6poyWtKVC/fvT1t44U6427ld+F3xSENDh+u/88J2 8Ja1yaPjJgkaxg2PxiBchb2yNWLyzjDYCni6HJcKxeoGK8kQthUzSyYWH3bahas36/N3Gj onokN7ojrCLVPqlWeM50bc/Gc2jXiu2LplLah0FfpcI37RZryYm7GakwTK4r8RUSo/AyMs PB7vo8etCUnlP3YbJVuB9+hgpaKoJiROh1cBUVrxtPHFPHY4UIIeU7UDIEQkDg== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id DEECF1C0011; Wed, 14 Jun 2023 07:49:45 +0000 (UTC) From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Andy Shevchenko Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v4 13/13] ASoC: simple-card: Handle additional devices Date: Wed, 14 Jun 2023 09:49:04 +0200 Message-Id: <20230614074904.29085-14-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614074904.29085-1-herve.codina@bootlin.com> References: <20230614074904.29085-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An additional-devs subnode can be present in the simple-card top node. This subnode is used to declared some "virtual" additional devices. Create related devices from this subnode and avoid this subnode presence to interfere with the already supported subnodes analysis. Signed-off-by: Herve Codina --- sound/soc/generic/simple-card.c | 46 +++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6f044cc8357e..ae4a47018278 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -348,6 +348,7 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, struct device *dev = simple_priv_to_dev(priv); struct device_node *top = dev->of_node; struct device_node *node; + struct device_node *add_devs; uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); bool is_top = 0; int ret = 0; @@ -359,6 +360,8 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, is_top = 1; } + add_devs = of_get_child_by_name(top, PREFIX "additional-devs"); + /* loop for all dai-link */ do { struct asoc_simple_data adata; @@ -367,6 +370,12 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, struct device_node *np; int num = of_get_child_count(node); + /* Skip additional-devs node */ + if (node == add_devs) { + node = of_get_next_child(top, node); + continue; + } + /* get codec */ codec = of_get_child_by_name(node, is_top ? PREFIX "codec" : "codec"); @@ -380,12 +389,15 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); - for_each_child_of_node(node, np) + for_each_child_of_node(node, np) { + if (np == add_devs) + continue; simple_parse_convert(dev, np, &adata); + } /* loop for all CPU/Codec node */ for_each_child_of_node(node, np) { - if (plat == np) + if (plat == np || add_devs == np) continue; /* * It is DPCM @@ -427,6 +439,7 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, } while (!is_top && node); error: + of_node_put(add_devs); of_node_put(node); return ret; } @@ -464,6 +477,31 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, return ret; } +static void simple_depopulate_aux(void *data) +{ + struct asoc_simple_priv *priv = data; + + of_platform_depopulate(simple_priv_to_dev(priv)); +} + +static int simple_populate_aux(struct asoc_simple_priv *priv) +{ + struct device *dev = simple_priv_to_dev(priv); + struct device_node *node; + int ret; + + node = of_get_child_by_name(dev->of_node, PREFIX "additional-devs"); + if (!node) + return 0; + + ret = of_platform_populate(node, NULL, NULL, dev); + of_node_put(node); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, simple_depopulate_aux, priv); +} + static int simple_parse_of(struct asoc_simple_priv *priv, struct link_info *li) { struct snd_soc_card *card = simple_priv_to_card(priv); @@ -493,6 +531,10 @@ static int simple_parse_of(struct asoc_simple_priv *priv, struct link_info *li) if (ret < 0) return ret; + ret = simple_populate_aux(priv); + if (ret < 0) + return ret; + ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); return ret; -- 2.40.1