From patchwork Wed Jan 31 05:07:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 768727 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2091.outbound.protection.outlook.com [40.107.114.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9195C3E47E; Wed, 31 Jan 2024 05:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.114.91 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706677633; cv=fail; b=EjD8Y1MTOyAlDMSTRou3ZrVOKvOzg8lySrMZym7EY/uxcHIZQJTLJb4o8DslJpuiLH2bPX9UOfGpJVD40VuHZG/jE6/NoD6VOhdqb8597idwQVDi1R+jVTVxm5389FjT2Ckmg/nX64OrTKQ84Nc3RA0aAo82shQq33sbNjSJ3kw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706677633; c=relaxed/simple; bh=6BMFkJe8i8VjU9MhJT+34F3ymHHgGfX8MxkXNQtcXZI=; h=Message-ID:From:To:Cc:In-Reply-To:References:Subject:Content-Type: Date:MIME-Version; b=Y1VJJLUnuhmVjZLQRE7BNa6IXno1KIjMVr8hfAzSDUKxgEDxym58OKo8p1VZzU3Y0680ou6tLCvYMhdvS+P8PonsXpXZmH4sFBFDVWv5zKn8OuVqGUBzeLS/Oq2RtCrRHjfH0tYxXS5Su6b2XwzvyQaJOr2f3jh1HZQq3/+zH8k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b=onzDHZPp; arc=fail smtp.client-ip=40.107.114.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="onzDHZPp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pdi5a5p15GrAON0rR3kEVdIifpLQlF998eORzr8qU2cvNmhw+UkY5J32FjtM0L2s7hnky85MDp18JAYencPnR+0NeJ1of6tOT0nwcQgy3nzMP03Wi2lF84TTAJCWNo7laj4OfLKSGHnFDH9n1RZhOZ3ploP5cHTxdY0oojE1GVN2oEAzZrfnuN0ZY/NoBjXamRk/8XdmlGXekqVCnvB2Nwh8GN9WDVQBtNMTokiGz9paxsZr7B72NrlRXuDzoZU2I+ohcJkzaBpVj+YD/53SA3mdiwBJPeDl74dKCEYOPbgdvI+5D62EV+QFRwkAD5348Rbhwke8DaYzqyA7tGscrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=keKwTFkoFFCwDKS5RleLLCGuiGWf9iU7c4Kky//CX4A=; b=KUFOVHGK6MRm2G+OZmxoN86WIfm55spWNmjzOHk3Kt5tkoTnUUykyV+29gRsOnsCWj+uBvqujvH3Pi5korpKqyUbifFiL0bW0AdWtPfqpbc/vOmZVVVNvVVZ+krU3wGnF167v3bHTexFhv+SNBCaeim7wgJMnoA0W0oGoDMgB4Tg7ZG9IY1izn5ZFE64g6+uwjQV3xBdZoyCeD1xQrxvDNrEPr7ZMbiBfmcntvvUVZWwHaIECbwCrMinhuAb2U9plqYLV5icVOpajekLGo/SxSsmiI2ZP5hL7PVVtYDXP6Lxmze2Fwx2lS334Z3N4LO82JDmWhPXL7Nc76IuWQgXsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=keKwTFkoFFCwDKS5RleLLCGuiGWf9iU7c4Kky//CX4A=; b=onzDHZPpDUjs/k8IPUCab9byzI1rf95KOzBK8AeXB/RuurkKE1MdlO+DhiCsawUrKgoAil5BnabYQXhvQ3sOz99JlrCBTqGRAnZt2McqtMOjmkTAKCmXZxpWzCTtTLxnxObz7e/y1/9aUnsXyyto4SEyQMe+nl6Y2NcRGR0Lj9s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by OSZPR01MB8896.jpnprd01.prod.outlook.com (2603:1096:604:158::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.23; Wed, 31 Jan 2024 05:07:07 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::ce8:8f5e:99a0:aba4]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::ce8:8f5e:99a0:aba4%2]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 05:07:07 +0000 Message-ID: <87y1c65bwl.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: "Bryan O'Donoghue" , "Lad, Prabhakar" , =?iso-8859-1?q?=22Niklas_S=C3=B6d?= =?iso-8859-1?q?erlund=22?= , =?iso-8859-1?q?=22Uwe_Kleine-K=C3=B6nig=22?= , Abhinav Kumar , Alexander Shishkin , Alexander Stein , Alexandre Belloni , Alexandre Torgue , Alexey Brodkin , Andrzej Hajda , Andy Gross , Biju Das , Bjorn Andersson , Claudiu Beznea , Daniel Vetter , Dave Stevenson , David Airlie , Dmitry Baryshkov , Dmitry Torokhov , Emma Anholt , Eugen Hristev , Florian Fainelli , Frank Rowand , Greg Kroah-Hartman , Hans Verkuil , Helge Deller , Hugues Fruchet , Jacopo Mondi , Jacopo Mondi , James Clark , Jaroslav Kysela , Jonathan Hunter , Kevin Hilman , Kieran Bingham , Kieran Bingham , Konrad Dybcio , Krzysztof Kozlowski , Laurent Pinchart , Laurent Pinchart , Liam Girdwood , Liu Ying , Luca Ceresoli , Maarten Lankhorst , Marek Vasut , Mark Brown , Mauro Carvalho Chehab , Maxime Coquelin , Maxime Ripard , Michael Tretter , Michal Simek , Miguel Ojeda , Nathan Chancellor , Neil Armstrong , Nick Desaulniers , Nicolas Ferre , Philipp Zabel , Philippe Cornu , Raphael Gallais-Pou , Rob Clark , Rob Herring , Robert Foss , Russell King , Sakari Ailus , Saravana Kannan , Sascha Hauer , Shawn Guo , Sowjanya Komatineni , Stefan Agner , Suzuki K Poulose , Sylwester Nawrocki , Takashi Iwai , Thierry Reding , Thomas Zimmermann , Tim Harvey , Todor Tomov , Tomi Valkeinen , Yannick Fertre Cc: Alim Akhtar , Fabio Estevam , Jacopo Mondi , Jernej Skrabec , Jerome Brunet , Jessica Zhang , Jonas Karlman , Laurent Pinchart , Leo Yan , Marijn Suijten , Martin Blumenstingl , Mike Leach , Sam Ravnborg , Sean Paul , Tom Rix , coresight@lists.linaro.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sound@vger.kernel.org, linux-staging@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, llvm@lists.linux.dev In-Reply-To: <87o7d26qla.wl-kuninori.morimoto.gx@renesas.com> References: <87o7d26qla.wl-kuninori.morimoto.gx@renesas.com> Subject: [PATCH v3 18/24] ASoC: audio-graph-card2: use of_graph_get_next_port() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 Date: Wed, 31 Jan 2024 05:07:06 +0000 X-ClientProxiedBy: TYAPR01CA0161.jpnprd01.prod.outlook.com (2603:1096:404:7e::29) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-omap@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB8896:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a708cf9-7b5d-4841-5e72-08dc221a7925 X-LD-Processed: 53d82571-da19-47e4-9cb4-625a166a4a2a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dDfmbD5IWzH6ULqTTmlnRgCNofg/m4m77G/TibYrjfndqOmWylPQ6b8K2Cvn2MQVZNu22waFN80bkMih1BYYNPocVUB2rWgtjmdehOjHI3TPdDIzBP3t79ZSX96PLb/XMRhHcIgqrHTpqAc1bZ++3pSGDqF0AnQaTcy8w8thnFlPhQUGaRI45h11jiY2QP6Csd1Bz9idDj55UUHdKYl/i1vyJtGLAC33JkBLCJvpo5qJdGQhuV9+YS8ZdQ6Z2MP9ar88oVB+3nYAUPJ+Yl0t+PlS2nvYmX+SrEBU8TiRBVIyyDaklZblQ1RMToZX+O6PB77nmNVOLwwHkhZRM/KbkKkAXhRopnseqLF0L2RYJShgf41GnXLLIjuNux5utKinEhEYhm0APTMaPYDs52YekRpyZtWgzRnJXxeVbTj/alUE4QXklzIhxIv7PJ2Zm9/0CGGreHUIalKPNP6nCRbHwkYoxWBofbKtTtByzYrgHqyenIO4fZcNgK8rCaKCkeugz1NqlsmKMPSxHKjzpnxP6W81RJb5rGHEb5QAQabW48KP8KwOhwffaJh04bINpi8eBY+Ec1hUTmfoBR6m4pGk/KL5JqsV2W80rJ98b2Uyxxc8MFIKo5C6Jofqq+83Bv55/g4kzHjqmDEa8vr6vWXQi5CyopTCEUKGaBCpuqT6gjk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCPR01MB10914.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(366004)(136003)(346002)(396003)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(36756003)(7336002)(7366002)(7276002)(52116002)(7406005)(7416002)(6506007)(38100700002)(6512007)(5660300002)(86362001)(83380400001)(38350700005)(41300700001)(2906002)(2616005)(478600001)(6486002)(26005)(1191002)(921011)(2013699003)(66476007)(66946007)(66556008)(54906003)(110136005)(8936002)(8676002)(316002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qkeRLIWNbcxPXoa/1qbknCQ/6BZEVxeWbReU2MQHiFdNNea9SwHJR0cH/JYfuILx2N/QYPwExjR06UrafMBinPtbQ9PHd80XmhquJClm3jhU3eIZQrp2cq/pdxyjnlRnvXyd92zunzYtDwyA8cMdFIeQlGXI4YTmhMEJSvb1/b/lYFkp37XTviAkUbK5bm3UH4saEBUsjuFofNt5ZjKhzcln/GXcMSf62YVhbz6xxHVbCOlhIEcMZ9qx0/c2b9/LG0ZzXNoSxtlSCpFHxzXZ8dtxWYHU5tGowbcrkD6n2hAqyCWj6lRxXRn1arah0KPXf7b6bokHvs6pXA9sGStnq0MeMGSuHyRvTHmR5bkgEMXL/zAgDfbGVJIUVO7hmZ9PVBHGxwmhg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q4Yzdl/ONkLEz8pDcyIfGvuUlYOrL9l5iGdYItvLPTs62J9BQV4WCqdZKJHbKVqt9oVaYWQq7loeSQScRO+ArH2iuAwnUVS4aq2oGQxj+07bpc8inxVT/M+DlvBnCSqSLTc58zCa2wWQ1tGNPGbJPCIl0u2AIpM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a708cf9-7b5d-4841-5e72-08dc221a7925 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 05:07:07.8144 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S9D7Ey+0fBJPlS0Zfg20QTVQ9EOaFa518Nz9w2j6xO/EK+xkp4Dqj7LUPA3PihG5g0E8xIoGjunMKI4ZYHhsJwjg6hjhqzEX4druSUY233KV8GWg+Fg6QvNdf0S5uPXp X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB8896 Now we can use of_graph_get_next_port() for port parsing. Use it on audio-graph-card2 driver. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 29 ++++++++------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index c3763719a69f..b2bd5b70a712 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -339,12 +339,7 @@ static struct device_node *graph_get_next_multi_ep(struct device_node **port) * port@1 { rep1 }; * }; */ - do { - *port = of_get_next_child(ports, *port); - if (!*port) - break; - } while (!of_node_name_eq(*port, "port")); - + *port = of_graph_get_next_port(ports, *port); if (*port) { ep = port_to_endpoint(*port); rep = of_graph_get_remote_endpoint(ep); @@ -539,7 +534,8 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, */ struct device_node *mcpu_ep = port_to_endpoint(mcpu_port); struct device_node *mcpu_ep_n = mcpu_ep; - struct device_node *mcpu_port_top = of_get_next_child(of_get_parent(mcpu_port), NULL); + struct device_node *mcpu_ports = of_get_parent(mcpu_port); + struct device_node *mcpu_port_top = of_graph_get_next_port(mcpu_ports, NULL); struct device_node *mcpu_ep_top = port_to_endpoint(mcpu_port_top); struct device_node *mcodec_ep_top = of_graph_get_remote_endpoint(mcpu_ep_top); struct device_node *mcodec_port_top = of_get_parent(mcodec_ep_top); @@ -572,12 +568,12 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, goto mcpu_err; codec_idx = 0; - mcodec_port_i = of_get_next_child(mcodec_ports, NULL); + mcodec_port_i = of_graph_get_next_port(mcodec_ports, NULL); while (1) { if (codec_idx > dai_link->num_codecs) goto mcodec_err; - mcodec_port_i = of_get_next_child(mcodec_ports, mcodec_port_i); + mcodec_port_i = of_graph_get_next_port(mcodec_ports, mcodec_port_i); if (!mcodec_port_i) goto mcodec_err; @@ -967,7 +963,7 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, of_node_get(lnk); port0 = lnk; ports = of_get_parent(port0); - port1 = of_get_next_child(ports, lnk); + port1 = of_graph_get_next_port(ports, port0); /* * Card2 can use original Codec2Codec settings if DT has. @@ -1099,21 +1095,12 @@ static int graph_counter(struct device_node *lnk) */ if (graph_lnk_is_multi(lnk)) { struct device_node *ports = of_get_parent(lnk); - struct device_node *port = NULL; - int cnt = 0; /* * CPU/Codec = N:M case has many endpoints. * We can't use of_graph_get_device_endpoint_count() here */ - while(1) { - port = of_get_next_child(ports, port); - if (!port) - break; - cnt++; - } - - return cnt - 1; + return of_graph_get_port_count(ports) - 1; } /* * Single CPU / Codec @@ -1197,7 +1184,7 @@ static int graph_count_c2c(struct simple_util_priv *priv, { struct device_node *ports = of_get_parent(lnk); struct device_node *port0 = lnk; - struct device_node *port1 = of_get_next_child(ports, lnk); + struct device_node *port1 = of_graph_get_next_port(ports, port0); struct device_node *ep0 = port_to_endpoint(port0); struct device_node *ep1 = port_to_endpoint(port1); struct device_node *codec0 = of_graph_get_remote_port(ep0);