From patchwork Wed Sep 4 06:11:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13789773 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010057.outbound.protection.outlook.com [52.101.229.57]) (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 A87DE84E0A; Wed, 4 Sep 2024 06:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725430299; cv=fail; b=hMBSz6WExU5OZUx+6LdHPZFxRzPfK0rzxVxlgXnWn1gJye3UjFZLlm7wmK0CQA12TSO3SiEkGZHY+qXfpfVYGbZxHRv4xUMUgW3Oj4l+Khwg+smdvO5oyiuEcDrCUZ13ylyMEMPueDu3avqCLGBsSS6bX6ilXzJHgwmKsMjOrNg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725430299; c=relaxed/simple; bh=5qD4LPklMp/SOzWG1FB5EjL5PfFnM1YTZdxSHcJWAAk=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=TPR7sgC/L3kxNzM3tV2Z3F/Utqxe6KuGFsy2nE0efiUvE/l9WPZ5WbVYUhgw7O9TIjibeamXG77MpEQS9bIzxlpivQinK4U7Tb4PrayFTEwqj8H3fHdOFfyXd+AXtTJpXAkhm7R/DwIHWh0AMgQEz7sYjhy6+dqAeXBG/rQvvN0= 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=CHRcpr6s; arc=fail smtp.client-ip=52.101.229.57 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="CHRcpr6s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y7H61GiuOP+Wd68XOH/XYbeWgz5Bm/QtKNalKJyNkVKzNrJtVgZR8kNrPoZCsZavoHrFpKCiAbz+bCNE2aic2n50Qbk/7AGR1itcFT/vT2WkaUISP67mhGS6rPN65ZV8VnjQJT/eL44SHaL/iak0VEm7e/yUEBP+KVlm1yyDrGW7pHl2kHzh9rT0UKz6LxxpGWVNkeEhzq67UUC0v4pAtFjK1J9XpTtfyBeTnsTbz+qg4CMmhFft1W5hjfAtgpEP71t1NdWgcgmIvaRslBCtE4w18fOyWa/AcVpA6a/1d70a6aygBTTYgU2zLL0BY7V15p4KFuCTpPDqErpQHBnCNw== 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=Hp4n9zD26Pjr3suPV3xZ/lwMpWsgUaeqizfk9RGR8Ns=; b=Y4OSKSWh0j6sApmdgoza3gtAkUY/NDHag5zvjCtrUl3PAAHfZ80H7kcEnvKvHB8CEkuOWDWQWcYXH3SQy13aC/n5QVasyJ83MVY7BCcIOe9jVGHXD7kUm+ZY2GS8Q4U0k12xmTOXbxOPyFcoThBCm6N0Afbl4HA0JuXh7paj5D9uJJCCG+DCA3EQB0hoGHK8vcI1N13jYHIbwytOFdIL3TuvWpd9KaeHE6pc+U2izALx8ewEfxPls6dUYbxPL3Z7wmKSdpbltqyk8p1IyCrjvpsdsBCiI2KvGbiG4sT3tuF7sb39pAwB66rxMg4J3jKkr+mdLF1IORxt3fZeXLBJLQ== 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=Hp4n9zD26Pjr3suPV3xZ/lwMpWsgUaeqizfk9RGR8Ns=; b=CHRcpr6sKZcptMUQX84B04W2sIw0C7n0+bbzI30qCWE4Pcy6/YdM0Nq3CNHVMrVWgFMKlbApFthlLYT8FtRFiTyqHTwrjWDyd0zJfRKflVKWPJEeg5aYROVH+afRAzavBKeqR6xC5zuJ0h5dnCS+efcttOAbGgBXBZRpOkIxfDU= 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 OS3PR01MB7309.jpnprd01.prod.outlook.com (2603:1096:604:11e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Wed, 4 Sep 2024 06:11:35 +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.7918.024; Wed, 4 Sep 2024 06:11:35 +0000 Message-ID: <87ikvc6j8p.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 , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linux-omap@vger.kernel.org, linux-sound@vger.kernel.org, Sakari Ailus In-Reply-To: <87r0a06ja1.wl-kuninori.morimoto.gx@renesas.com> References: <87r0a06ja1.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 6/9] ASoC: audio-graph-card2: use new of_graph functions User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 Date: Wed, 4 Sep 2024 06:11:34 +0000 X-ClientProxiedBy: TYCP301CA0067.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:7d::20) 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_|OS3PR01MB7309:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e4d3e85-ba83-4a01-f7e8-08dccca86e04 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: o0q7Gv5Uz4CGyhRIkSwHx57Ix7/IEPLoDEf1h7oW9OuUpxttCHdwUYbWrrAqsLy0dtNvjTYW5+YCxiVts7Aqka+xCeoEAprqTR4e4DJ30ATcuAlahHeoZuvSThBTd3J1Zw+VNVYGS9ymIq6oVkXifoSOs4du5k7L/viG3HZrPsR8BJ7CjG27VqZ6Wc0NE4NRRsS6y5qcuK6Z0D6BdWJj1SzbLXqqNDx67APJ6rF4B/mzSw/f2e6667lEcEMlalHR4iWipLYjIdCYh7OP/nvnCIfTRiL/1WIIrfDTXKek5zykKuj7+Ai/L3mNcIASotLpJqfvovVD38xRDTfYapO73pmW7uDCn/0cP6Ee77zuRDIOoERqyL8cOniBNPmmusJhjtHfB+ODEAcMtHyixLL0aLPJFEP3hmfazHg+3XJCs7ucFpI8au2/lx7jqo+1Yknq9RTONqpx4ksay8H5r3XHqaEeXlNCidn0URJkS8fhKvqMVCmUTxC/SqtJI78rZxQiVgHZcc0KGhWCwRlGpBwLUnrDHO82RDHyAmRnNp+jbRFZPbzzWHKMu6M0lW07Ajffo52t4RrLsYX8kV2KANMb+2dBMCcObQJDO5QujYau+K+NvdaLR7Kza6Gswa4EAMBzsrCl7pJPSx8mbnFW9iHnZ1S9Vd5I7ac6JasfHPlkEVkn/myodVqO3xy4iDXVygY05u9oiopYBrSsD92NGj3BLB7xELkeZhuNAOgsRK7PCw1fa0PwVIDTDSib9Al/fD5KfF5FToOv1pC8nf3c+1kcIIJOZ0xoVG29nJApPx5VxG44TYI0ekxaptAOcAobv9ozZGdqbhrCay7p+8ezBpQh9m/0nCCDQDGk9lMLPeqdieUNaVASia5UoMW8/IvcbKQKbjAyvx6cfd6msaBTgsdCroMIJUAjlddzCLKusowX3J13+0qkxZB3X8st47lkahf/mYyA1oPjeSnXD9EVUu+FQ4kI0f5nRhgQ9vnbnmlb8H8/pBzeK3c+uOUPMOCIPMGPIkkXft91MyaxJh9AYb4lQTcYBoBUiEfJ3vXEjSxLadW6/4jtQ4T9AEyKu3OV6nb340UJjlVYYIeUfL/CnSP9mh7jNWKR5UUi7EU1NQamzbJWjOAzp/BBSxKqtLUaBj/I8mtkd8IdT0ahDhjgCyT8k4yicBBWc30g2KTatC75/mE+T6+Dfc/CBBGHJQO+Bfy9f7uWDVudhrWMSsPO5dCgBoEgGCeN5LXGuaA40THeQoZgzd5EFifyD3W3X3JsWYyza0frRbzFnsVjAeIXQAHUQEYC5Hug84G26+EZTmE8GMq2C3j+c8CuvWWyKBQQJdowxEuBHREi9lATQMGA2kJ1zEkG+9Rmj1hvekSMovn70B0TVssg7MQScUpOEL3Ftb2WkYqyvfl2WEhJUk98GyVzJfbN+fT7jNXMnL93GMI5af0= 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)(366016)(1800799024)(376014)(52116014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W95IqluxMr9g0MgguYHUctcAmu6dJLoC+sQn7Y/HSthspwN/qPBZG3ptYjaLEPaDJ+Qg8rHX4ugh0vFAu3HuiNEvKX1rYM/zMInmbU6oe3u8icNK7dyRarSWQ1XZ2SVLf7kuVXMjI0Qy3PV21THexUJyd+5V+aazYDrfHrbahjgTgCb2zoFz7b4EKbXNBVKxru3pjbbVPYM/mdl1CT/YBuG+K+fIl90zzV41ZFpCEee7MIBZ5t2pshrx9bCZaBg9adE/2VIyLKtfU30CMH51qYYFQNKSWU03XXqdPq7TsJaFP3D/kJAB7fCtPjd9X2/VtwBhlWV01EZkKYWVsZut39LOZ8J7nVN+vLklPlNRKwU6IyoT/4xNLyqOa5rqMWc6vRRle/HX5euB9MapMA269sw3cv+iNWjvxbFnTye1jacY7SemjXb2pw5LdnP5b0XkcVVu4yz6YJrKP3CZb+18v3FUK17nQ3O/a7pn4yYgDOHJ2aiXYVtI5vbuMebdvVr8azmTcUHKBVcYbkO/114XYzvnEETn1S3eZczxyI+SrHNb8E3zNMvliC1CD6bIMyL89ew4cn+I7AiKhPDT2nO/gVGGsX61kd9BrVkzVKmD8Ogfx8S7yx33AE5+lLutbVHR2LhduGMM5ZKF8jyvRorPveZTDrmhbLliUuPphivl4x5dIwvb3QyckpO8UemxebC0ojXyXtyl2jwVgVdVQ9PeDFzkpoIaFfcvMA0aBicfkqahI89g7h2qxLa7yVO7RvCGVHZB9yDyXI2594WRbx2hWNCg5z1dlI4HSm9aSmQZpTmh2GNvIVPOg8BNfXk86hdRV48+wZWRZnBDSiGJuiVQ/q03juV52UVITXkiU4jbWjWkvbyBALjeyxuL+Z6+l2reyTYRjQq6eFCORCopYdSVPUNFCOO7QMbenXtPnL+BdnZP4/aOhTkSO4LCPH5bdIzBizBgXQwr/6+hNUVsBe9lmMy/jYOgvIiRpUb01p6BIPNwTnshETsN+JNELYtF+m2YmWkrPyqDqyP25Aj74/9HpRXjim0mXakyH+yqw54X80bbAXcF8skQ4FymUko5spkSJWfhWFmyy9szLQQifsB0hPV5CL0aN7O3u+ublWpVF2EupYBLNefuR8FbzS8qVSQQzS/NI+pQ62BCDa8GF7bvnyP6npP7cEUsAvULNwnio0IU3r+61YYJZX4cI5HsIWH43ZF2oJozbXe4OCQJpZhD4GFi/L0/Wzs8yuwdn0Ufy2qf85whpsD9K0ROal8K0XlEwXnJygID6L28pCNC1Y5ZEOmclSn87quxLHAqAPclZUk3ypJ36BuVENeWkVJGuxZDuAgfHCNQ034GuPZwAsXo7kqNFmZ/+GSx4m1KMtDukww9L8Ftn5oXSqgGaON2ypqnDGxuQqukj+u8U+c5gW2sMn0QKepCMYkaOL59uon+kbJu1ITRQ7spwyefnGnc6DXZ6s5wCUB/R/ClLZ7ZsT81h5ZyYMjgxRGjGDwhJhD6WucDU+7wFHTapX1I1Zm+65C7ebs7oa3/y88tAEB6IjOpFDaGL+iS3yDiG1v60211auROMl9ROrNn6WF6jBs/hVtc69HYKiyRIRRquPq+BxOrOtkhzLNWdRC/db5/2EWm6Gk= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e4d3e85-ba83-4a01-f7e8-08dccca86e04 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 06:11:35.3097 (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: ZW/QMZl3fABB3uFx/AXmUBJJ3fmw2ViVbBeOcrueBIjrDBlfKqubt5JqyU9Glq1hL+9papZ1SOxoj7OCTid8dMU0tHaVb/ctAIC2Sp8VSMNDUWli/CI+hYWSRIhKSuSx X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB7309 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 | 113 +++++++++++--------------- 1 file changed, 48 insertions(+), 65 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 051adb5673972..90babed0f02e4 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,66 @@ 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 = 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 +666,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 +761,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 +771,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 +842,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 +875,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; @@ -1007,7 +999,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. @@ -1037,8 +1029,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); @@ -1139,21 +1131,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 @@ -1167,7 +1150,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); /* @@ -1195,7 +1178,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); /* @@ -1237,9 +1220,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);