From patchwork Tue Aug 6 04:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13754408 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011038.outbound.protection.outlook.com [52.101.125.38]) (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 5D01E1BB686; Tue, 6 Aug 2024 04:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722920331; cv=fail; b=INfEhhV+iFt54E6csIerCNLt5H7vX+mpM6SdBQi9fohEFHhtnzONJvRYKvtfMqpY43bucZwZTzVDKo77oa0Y+MkWaxeKkzb+VHADBYb4BbxcwEysiKgcw+LFxxLTVCZVQXe7xYacO6oBGy6kr5q7wanKWLRlo+Fv5rmHOpKNR1w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722920331; c=relaxed/simple; bh=Jpyd2sABwD6y0Ge7HAK9+6+aL68kXmkBCwDQ/qp2ctQ=; h=Message-ID:To:In-Reply-To:References:Content-Type:From:Subject: Date:MIME-Version; b=B0HlIVHneK08vgj2MaWK+VtzmXjISid4GNuZI2A0cvER2KoHbshngy20FwLNC1I805l8OqgWSN0Ryc+X8fEGfQdr6qYzztKBWkRCExlASQJWmvMa062flEHTIO5NzT4r2pAsXimkFDfQycKkiK3+ru12FjGJQFwFIO0V/LPa4Pc= 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=pIuzppeR; arc=fail smtp.client-ip=52.101.125.38 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="pIuzppeR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AKYwB64VlEtCa66veKklIGoZITxsJBvQP6CwwG2tlzkplqSu6xsDkXL6VzQ9qhX+x7iDWsQ2tDd/QMsNfBcySMioL88vid9THt9l1CwUxXW+AUbF5ihtKIOlQzAneuQuORe7BFtsDhcThHVjoKG3svnjlZzhCT36jkOM73Es6ZCJrtyaLAv3Hio1ui+EDcYvdQehwfnkKpLAPxTGO1MmgDYRi5ZIiRiiggyJdZG/0A32Du2Mdpz/2OTPebFiYdc5FkO3bLqnxCPvLhih4fL2vTQFPnptvf13epjG//IqDI6V6Vrk3lX/YgF1AIYFiMYyjLJqcAgATYLbAu62bjmUPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=C6vhNpqKxKB/lCSNHdn73b8TlT9nVKAcgSe0Mpx3IFw=; b=C21NtZHjK2gVq4qt1Uk+qM5VXcKGRgkxdwWjfBdz9xnH/IynE4unZa9dNyuBrgPTTq8zslxGYEQd25gTUH+tCxdXg+8o7M4onHtMVpiKNQopMmA57Msc5abkWkFkEXftP4NfyxslYxMRZGCe8DKtIXl/y1Mg1w1ZyYj2sOHQn8L9FsK7pNN3OrmVbUC6SY0gqEQN2231sJr00ytbeM2RK/VD6UE+OI58Bo7hJn9NgWD9u+enSio4Al6PT/TEMpa6bD/ZlNCW6immDrke7Id770Yc7RMnQ0Pnzy33MW3ofAn/EenmJni0UWFmF7VpcEMauMKSvDfUi1Urv9cQ0v9MLA== 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=C6vhNpqKxKB/lCSNHdn73b8TlT9nVKAcgSe0Mpx3IFw=; b=pIuzppeRDh+rVhiHkd0tJxEuTGLvhxm2EnPFVXxajjEnEqwLuSdM3kufZgPVNS65PGe+shJ+9Pn3b5lCreGcQtVEJX0vFk1qXx+RjHtFz+sAaq7PX9SDmtFcOph+gBLsld6YZ9/OguAPxLwc33CXO5X46Epp5HE4RY5Kp0GpMuY= 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 TYWPR01MB10409.jpnprd01.prod.outlook.com (2603:1096:400:24d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.24; Tue, 6 Aug 2024 04:58:46 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%5]) with mapi id 15.20.7828.023; Tue, 6 Aug 2024 04:58:46 +0000 Message-ID: <87ed72w8l5.wl-kuninori.morimoto.gx@renesas.com> To: Daniel Vetter , David Airlie , Helge Deller , Jaroslav Kysela , Laurent Pinchart , Liam Girdwood , Maarten Lankhorst , Mark Brown , Mauro Carvalho Chehab , Maxime Ripard , Michal Simek , Rob Herring , Saravana Kannan , Takashi Iwai , Thomas Zimmermann , Tomi Valkeinen , , , , , , , , Daniel Vetter , David Airlie , Helge Deller , Jaroslav Kysela , Laurent Pinchart , Liam Girdwood , Maarten Lankhorst , Mark Brown , Mauro Carvalho Chehab , Maxime Ripard , Michal Simek , Rob Herring , Saravana Kannan , Takashi Iwai , Thomas Zimmermann , Tomi Valkeinen , , , , , , , In-Reply-To: <87mslqw8mj.wl-kuninori.morimoto.gx@renesas.com> References: <87mslqw8mj.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 6/9] ASoC: audio-graph-card2: use new of_graph functions Date: Tue, 6 Aug 2024 04:58:46 +0000 X-ClientProxiedBy: TYCPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:405:7a::9) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYWPR01MB10409:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fdc0338-5770-406c-144e-08dcb5d47436 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|366016|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: 5Zhg3s3yekk6KWB9tcNoOuPuZ08ig9TUnzxwKkgr9mRAdHV0d3xpT7VWuACY+rQVG0hg9u4Okwx68/9DR/nMo/ZLajH9e7Db4I/jTPFOZFfL76KSteD4O7yY03cS/ghrqOZI90Jyx8LIhpEVuMoyeH/Gbj/P7P6J0XtMhK1iWYvmEugWRFb8rpW8jSZXsR6jOIIBKDSwc15yACRGJoeLaAQgoz2In8JIRW9YTUAOEbHaQS9YnRWoTc+HHB+B3I0TVQYIwT1eSlHkDzi7c3mrrenoK3IV8owXwhViyn/bJe7MIFRahzN799LD/k8krX/MS/qRgSM0ZoVhfK6ZEVx+rXQCkTJsts67ERYacrpk/Ofh7UY+sWAifg/IudRPSwG6a2iFjVwdHixPJfDNe2PbhCOrUm7GAXQRDeRH5TgCec6rJvmGPzHRMvSiOQJ/LS6hoaf6a7CvGJ9UTqRF3k9v5I86F8ehnxDaBqe/ijc2blDBPJBNqXqmH6CY+33EeO0KIDMFAqx1eL5sOTeTglUC+HITZG82hrGYkrs08y2HCCu8LIwYNCwbjVgQysoJvQAdd+tgPEclqgf5HLmKX1xND/0VQFlr0U3aLccdqOxYKWpUDG0rbLhzFIMoa26puRMtw+y03WyaWA9ReZHb6hcJWX+KDAzdGRili6lYjYrtq5S1LPHnHS/9BCSrZsuH7EnIi0fGwkozjZenGl/2gb3Jh94cOsq4nB9INl8IO3WBmysJVk5NrVDOmFog/vlB3XZWCIikuuwCo3uSD9ohUNV2D3yu4lyhkDfenmDRfxajI/zyAH6iMBSVxVeLqvMNVDdAfMpVS/paRjll94Aef0uic/i2sFWXU/LJsDZUwlgSmJYvIgDNY7ovjahPtLrgIXNqJAgyZz8uu25CJyQ/ih0A3KFp8lUpIlYL6TL87pP6LhBCxljQn5ubus9eW+EFv7+HZpE9CsLcLgTfREuAW3Pj5g27WqVV/yj4jQPk7CfTbV9VPQEXE7aJYsWfB7Ire25mzMONWGJDN0blBT5jvAcFP3pTtvr3W7rW3H4f4PgnVMQE4HgWZ53Zdp908iKjPDGAvcFTFCKsIH2uOIgbsge4mxyEO5sKQ4gbLL+Fcencv7c3rhPwHyaaDyh9m1Ngk6w2u5VEqlmuhjhCDAh3oPxvPpLU8Nnt8QQmNLAZwltm90bi4cRQjiNH+tL8c2f2i2cooWjceRoTeQYW4+iz3sehvM1x7lopzPGB4NQVUxzGBePYFAMjnj7PPsW0A4ckiIxHDWDUUNIzTzwUR92tj7R8qpoPrh1al3/Ls1b+FcM/XYKoHfEeGzdCtK2T5pMkKRGd90G6N5w/cUR4cvi0sp6Y8q5aXRPBgx6WjpGybtIxN0B7xxMqmUGEZqe+0xqOVfYCDF4ki1FCzwrnHhSijr7R9OTMZzTB5MpJcZuBvQHz6LU= 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:(13230040)(52116014)(7416014)(366016)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3ANPHsE3E+im0BEnvDYp/LTM/lnBxVMPLxbZI6yrhgrYNBdPaHmwAvVUX1ya6Yeq5cETWOuXfoFmr3x94KcLMVdk3r8LUyOGzy1AFDu/BuzVxMFB9JtZwskZQ5nNdHjz02x63AVJxkNDYH8YMa6r3hLOQPCRXPzPDkAMyzhCIndCVYLiDWjANHbP8ZKMmukh3rEkYl9f+BOD0qGgMSCUCll3vbe6GxR90LI5R6VplgslYSXxc4DIQ1xZwaA3cB2PAwly6duOjp6bktx8xSK3EDCz5LSarf0SSxkviPNTRO/dmISdbxujk3nPWME3vwZsYsOtTrifqTbKPo5Yq6jBRkVdy5qnr9rDAsCqp8F186iuxwCkHd7mnaVzuoEWDoLWCFzFo0N8LYknyBEwFoa7kwBJdz3GOOtgw6XciqFQje3v1IQTjgBzn2MpJ40kE61z53Dd5VidMcYHSlgXgedZ2XmktlYc25d4SO/aFvI4dRrJbiYCqid1NoC4hoNN9O//DTKvhQ5If5SPNRDxySxEYsPxyDqb2vuCciuhfrWa24SshN1iigcuApgZs6cbaDc2S/nOSw16ClzUbfXwzJhrNaWr1UD3qVu1XTpjnv6rQQ+y5sgyar+VTcvsKcydHT/fDaLMA/xcoS0xdbyZVEeBkDDoeJpIpteLoaajEJHYEqeEUyHMue7xAIDU0hrCtiFV83IxCakxTvOyl8eQopFnQWGXzC/sKdZyEsCDQpaoOg74h148fxC3CLcwZcEmXtg3fdSktTMkPftzBOpt5jXYF7ATngci9RuJFy3TnE0DNvQLrcsrLqK01irJDSnswQMuIEMwhoSaYdBaF0+DR0Os3z58rWyPiYqObGVsA0Y2xUh6eQltGVs5q/2/gtX5Ni953xbXLLAt5RW8MQzRpROmTAioYVV+6f19ARkbfd8ubWskHq0TcHBnc59yC9eWB9OJHTDLD4UkEWb1G5fzYooxUTZYZsGnBg1+ovFqoImW85SEJg2+1odIaFQuOKvsOs35F5r3HoNKNFyt2fayMBRDuiIRS5l982JVqxCaEH2ondR2xJ5e6vXjYBz7eEItCPe7smttz6nHynghuhg/PlGcRMDgQQiDIWEQtO6XdnXEB+A/jRGJ49GFjvA6sjqTezAE1lHsfdEJZflcTLm4Q9HatBdk3imFio4p+fR/Hd8VvoEFUD5vOI5E8iH5tsIkw9QA0x7WsxD6R9I+C/zXCczV37hqnWuOnRZFfNAGFAN7cflSLkDUYOIQ6xmN/52SvowNCEBnJkaDh0ssICTKdoFbKJtpKUwchyjPLAuh59i/Otd2w6nYKrIktV8CRtdzFxdyBD8BcNuqAMsPIdHSJOAAJwg2YkfSr01Dqtx5akVXq8BBQmEb4iecwH3YhCQ3UDIgF7+b6ZhuI9DBiWV3VpfZfL9xDOm8OR/4HmLxunEuxBp0LrEb14oFAGPJmoFpWdjXjRyOxvC4aQLry7pSidyYSIJWpBMcGwSaV6NBKhJ3B1BzTcx9UYJP0Cn4k8XCMC4nx23a+k7eHWF9+vK9+/7o66RH9PsCmQavpEDWvg9lyvqn+1enRpJCQKzI8LinmEsEqkQwDof+/wpcFi8HKe5kVZipQF5KdlRuc03ZQFDC9QU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fdc0338-5770-406c-144e-08dcb5d47436 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 04:58:46.8013 (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: 7bjDyqxpZeETSzPKBPCuIh6My0BwovrHAgmiWGWVDWO6gdkU69nzpYxNQSgjJJtACJ6er0LGxwUG7IXio0WndbTcfUa9x17xYJu+wck1mo4i+qTNu+j/navJ6wzxRC0o X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB10409 Now we can use new port related functions for port parsing. Use it. Signed-off-by: Kuninori Morimoto Acked-by: Mark Brown --- sound/soc/generic/audio-graph-card2.c | 111 ++++++++++++-------------- 1 file changed, 49 insertions(+), 62 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 56f7f946882e..e8ea201dbca3 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -234,8 +234,6 @@ enum graph_type { #define GRAPH_NODENAME_DPCM "dpcm" #define GRAPH_NODENAME_C2C "codec2codec" -#define port_to_endpoint(port) of_get_child_by_name(port, "endpoint") - #define ep_to_port(ep) of_get_parent(ep) static struct device_node *port_to_ports(struct device_node *port) { @@ -351,14 +349,9 @@ 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); + ep = of_graph_get_next_port_endpoint(*port, NULL); rep = of_graph_get_remote_endpoint(ep); } @@ -530,67 +523,70 @@ 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(port_to_ports(mcpu_port), NULL); - struct device_node *mcpu_ep_top = port_to_endpoint(mcpu_port_top); + struct device_node *mcpu_ep_n; + struct device_node *mcpu_ep = of_graph_get_next_port_endpoint(mcpu_port, NULL); + struct device_node *mcpu_ports = port_to_ports(mcpu_port); + struct device_node *mcpu_port_top = of_graph_get_next_port(mcpu_ports, NULL); + struct device_node *mcpu_ep_top = of_graph_get_next_port_endpoint(mcpu_port_top, NULL); struct device_node *mcodec_ep_top = of_graph_get_remote_endpoint(mcpu_ep_top); struct device_node *mcodec_port_top = ep_to_port(mcodec_ep_top); struct device_node *mcodec_ports = port_to_ports(mcodec_port_top); int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); - int ret = -EINVAL; + int ret = 0; - if (cpu_idx > dai_link->num_cpus) + if (cpu_idx > dai_link->num_cpus) { + ret = -EINVAL; goto mcpu_err; + } - while (1) { + for_each_of_graph_port_endpoint(mcpu_port, mcpu_ep_n) { struct device_node *mcodec_ep_n; struct device_node *mcodec_port_i; struct device_node *mcodec_port; int codec_idx; - if (*nm_idx > nm_max) - break; + /* ignore 1st ep which is for element */ + if (mcpu_ep_n == mcpu_ep) + continue; - mcpu_ep_n = of_get_next_child(mcpu_port, mcpu_ep_n); - if (!mcpu_ep_n) { - ret = 0; + if (*nm_idx > nm_max) break; - } mcodec_ep_n = of_graph_get_remote_endpoint(mcpu_ep_n); mcodec_port = ep_to_port(mcodec_ep_n); - if (mcodec_ports != port_to_ports(mcodec_port)) + if (mcodec_ports != port_to_ports(mcodec_port)) { + ret = -EINVAL; goto mcpu_err; + } codec_idx = 0; - mcodec_port_i = of_get_next_child(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); + ret = -EINVAL; + for_each_of_graph_port(mcodec_ports, mcodec_port_i) { - if (!mcodec_port_i) - goto mcodec_err; + /* ignore 1st port which is for pair connection */ + if (mcodec_port_top == mcodec_port_i) + continue; - if (mcodec_port_i == mcodec_port) + if (codec_idx > dai_link->num_codecs) break; + if (mcodec_port_i == mcodec_port) { + dai_link->ch_maps[*nm_idx].cpu = cpu_idx; + dai_link->ch_maps[*nm_idx].codec = codec_idx; + + (*nm_idx)++; + ret = 0; + break; + } codec_idx++; } - - dai_link->ch_maps[*nm_idx].cpu = cpu_idx; - dai_link->ch_maps[*nm_idx].codec = codec_idx; - - (*nm_idx)++; - of_node_put(mcodec_port_i); -mcodec_err: of_node_put(mcodec_port); of_node_put(mcpu_ep_n); of_node_put(mcodec_ep_n); + if (ret < 0) + break; } mcpu_err: of_node_put(mcpu_ep); @@ -674,7 +670,7 @@ static int graph_parse_node_single(struct simple_util_priv *priv, struct device_node *port, struct link_info *li, int is_cpu) { - struct device_node *ep = port_to_endpoint(port); + struct device_node *ep = of_graph_get_next_port_endpoint(port, NULL); int ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); of_node_put(ep); @@ -769,7 +765,7 @@ static void graph_link_init(struct simple_util_priv *priv, of_node_put(port_cpu); port_cpu = ep_to_port(ep_cpu); } else { - ep_cpu = port_to_endpoint(port_cpu); + ep_cpu = of_graph_get_next_port_endpoint(port_cpu, NULL); } ports_cpu = port_to_ports(port_cpu); @@ -779,7 +775,7 @@ static void graph_link_init(struct simple_util_priv *priv, of_node_put(port_cpu); port_codec = ep_to_port(ep_codec); } else { - ep_codec = port_to_endpoint(port_codec); + ep_codec = of_graph_get_next_port_endpoint(port_codec, NULL); } ports_codec = port_to_ports(port_codec); @@ -850,7 +846,7 @@ int audio_graph2_link_normal(struct simple_util_priv *priv, struct link_info *li) { struct device_node *cpu_port = lnk; - struct device_node *cpu_ep = port_to_endpoint(cpu_port); + struct device_node *cpu_ep = of_graph_get_next_port_endpoint(cpu_port, NULL); struct device_node *codec_port = of_graph_get_remote_port(cpu_ep); int ret; @@ -883,7 +879,7 @@ int audio_graph2_link_dpcm(struct simple_util_priv *priv, struct device_node *lnk, struct link_info *li) { - struct device_node *ep = port_to_endpoint(lnk); + struct device_node *ep = of_graph_get_next_port_endpoint(lnk, NULL); struct device_node *rep = of_graph_get_remote_endpoint(ep); struct device_node *cpu_port = NULL; struct device_node *codec_port = NULL; @@ -1009,7 +1005,7 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, of_node_get(lnk); port0 = lnk; ports = port_to_ports(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. @@ -1039,8 +1035,8 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, dai_link->num_c2c_params = 1; } - ep0 = port_to_endpoint(port0); - ep1 = port_to_endpoint(port1); + ep0 = of_graph_get_next_port_endpoint(port0, NULL); + ep1 = of_graph_get_next_port_endpoint(port1, NULL); codec0_port = of_graph_get_remote_port(ep0); codec1_port = of_graph_get_remote_port(ep1); @@ -1141,21 +1137,12 @@ static int graph_counter(struct device_node *lnk) */ if (graph_lnk_is_multi(lnk)) { struct device_node *ports = port_to_ports(lnk); - struct device_node *port = NULL; - int cnt = 0; /* * CPU/Codec = N:M case has many endpoints. * We can't use of_graph_get_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 @@ -1169,7 +1156,7 @@ static int graph_count_normal(struct simple_util_priv *priv, struct link_info *li) { struct device_node *cpu_port = lnk; - struct device_node *cpu_ep = port_to_endpoint(cpu_port); + struct device_node *cpu_ep = of_graph_get_next_port_endpoint(cpu_port, NULL); struct device_node *codec_port = of_graph_get_remote_port(cpu_ep); /* @@ -1197,7 +1184,7 @@ static int graph_count_dpcm(struct simple_util_priv *priv, struct device_node *lnk, struct link_info *li) { - struct device_node *ep = port_to_endpoint(lnk); + struct device_node *ep = of_graph_get_next_port_endpoint(lnk, NULL); struct device_node *rport = of_graph_get_remote_port(ep); /* @@ -1239,9 +1226,9 @@ static int graph_count_c2c(struct simple_util_priv *priv, { struct device_node *ports = port_to_ports(lnk); struct device_node *port0 = lnk; - struct device_node *port1 = of_get_next_child(ports, of_node_get(lnk)); - struct device_node *ep0 = port_to_endpoint(port0); - struct device_node *ep1 = port_to_endpoint(port1); + struct device_node *port1 = of_graph_get_next_port(ports, of_node_get(port0)); + struct device_node *ep0 = of_graph_get_next_port_endpoint(port0, NULL); + struct device_node *ep1 = of_graph_get_next_port_endpoint(port1, NULL); struct device_node *codec0 = of_graph_get_remote_port(ep0); struct device_node *codec1 = of_graph_get_remote_port(ep1);