From patchwork Mon Jan 6 05:49:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926968 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010029.outbound.protection.outlook.com [52.101.228.29]) (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 9BB8E17C for ; Mon, 6 Jan 2025 05:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142552; cv=fail; b=PPYTekRD9UawL2M/F4gAsS4tl04lHyBPfGGwQTnTrHm3wuDEiAEu+DMh+Axy2Pll/n+smtjm2FHe0ror9tJiCyj6G4H6emWzW40iiNiSbUFC0gXwN4RfAryBuk4HaRkZfmxYghD3M9iB8CTt2BSj5cSOFnd/9MZHKZE/LBbx/0Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142552; c=relaxed/simple; bh=QZps46uy4bae/jVj72rnoWFUeDi5wdPXkZlB1sAyApw=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=bewu785UL5xrV0KCTwTdj36+QyZAuEkxNuBl1iLZ1EtyF84h93zu2i9lYvDm785duRC5vEuQrqY4HblvCN3EQCRslEkcDp3SbRd4Tcmvg3170D68N70UpBLUsJCZHcsWsdbN2HhAQz01KoFr8MVwC/W1jOWGXLCxD/JE24p4Ol0= 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=TkKGKSrL; arc=fail smtp.client-ip=52.101.228.29 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="TkKGKSrL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fUJVddaj4Jjk1tGGC8wL6NeOPSqzSrzKWTL7BMpzi6FCrem5T98nJKN6PDvQzsQAT54pAp1Ytl80BS8eyB64OCEFdLulFNI9ICQMaHEuB/XdBLNj1Apn7Q669f6mZZb/sVu5OO6AYjWhSyAkAnecDfR3ZwFqPALxdB6585Tj6Y8xbYud8CQnHgV8HLC7Rn6392r0iEjz/hY4OMikTL/EqXQphlKFJRGsTO1rKI7jm8kh7tIV2sqziHDeBIfcPYF/C8g7IhqE3zTK9HSvYy1LmFrpOjmqH4VZ8CICc+up5hP5LDyy7XsGvW7+UsgzZeKshXpaUiCkuD7ftxAauS8o+g== 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=yEm7puzF7AuSlG9k9cwM27p8dG0uOhogkq7oeNbEVwM=; b=ef2tW6wImWAN0H5tkoO86f+T1JDPjqVRmAN8MpYp7lQYShQc3x8Lm5ikXFW1W3M55XKE0ftGZqdKZOemdIbEwVLevKYqJ/MCl+DDw5o3yWj47UQvSYKy6osBKGoqVVCHSJEpfHdKg0aC1jTIYLCITnxshCpYlbzoMtmNT2ATvASOVBLS+YaL5+t9HR4+77ZCo3QdTZ1tUKZhcOlVDqsWavsOfk8Q3PHA67YgD9EnTgzfiHMiGaBhnWouo2SJsB6EK97B2XZYpDBuMJDqOHU39KS2uzV+/vCuPCk5+BYEUHcl6dn+Eds8pv4vIzjftZ4rh1xHSVTjIWOTT0o3vQmtDw== 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=yEm7puzF7AuSlG9k9cwM27p8dG0uOhogkq7oeNbEVwM=; b=TkKGKSrL5rKJRJjweeH+RQjsyZlvWtKuKKeGj/8D4QaLT46iBBO83Lh7My6FR4aIoIrj4t9d7M+0AIqWXztwx6P8Cb1ZI/PqXV3App10rbwFdge5h0dea0Yurz9eY9OVNfNWbXqwPUkX1AvdILu6ow48luaMKwVs+EqT37VGVeQ= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:07 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:07 +0000 Message-ID: <87y0zoo5kc.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 1/7] ASoC: audio-graph-card2: use __free(device_node) for device node Date: Mon, 6 Jan 2025 05:49:07 +0000 X-ClientProxiedBy: TYCP301CA0025.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:381::12) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: b812b895-83ff-4705-86f7-08dd2e15d60b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: eHle0GwSi0Qf+99zydvpGJPOhoWJSmpU74TUXVqdevISx3KwZykmV9nKgnAR/mAzlxxvCQU5A4GV3CD14VY1nQ4lqzamBFmM5D0K8H4LH4ORwAVhdj3DMvDRJQwh5EVm+Ufodu50k/q5MptWGuq1KQU10xeKex2LdV2hCtwtyhbSjcvVTSXO0mnTn1ZcpkkwXMK7gSe8/knueAwQCt8vOtREW/pTE0CN32e0KxS0ir3HpyyNDAXHcAl5EqvbOtd1QNeDeimsFmZ/b9cjyAv/s9m0eJppDhcRU24+wIAX2SoBmi9mZQw+YWJSTgKFtLHd8JoyQ6LP6TWu4wVaHc2QPOuHzHnzHrrKAjOS3qKPiOviaICgQunf5bb2c9OKcYTnwoUWRaNZzgqVLvG7cz15R1NnX/suQzZ9B8kN8BUi3xDH5zi6GNev08Xtp2HEymgai1ACZGKYnH8OFcpKf/3YA8Mc+QlswZ0MUTzwQ08/IOf48xXbYvLigntTgslYpmHZYCxJqhgwO7P96bDGf8ctkhtmRpU/Qi2zl6zbhAEIyw3pZlmarlMW+trkIbvpTsSWDS92PKjcCU5EsFpor8mhGsJB06R+TI2waCcG7P9R4iZnOktNl+90lbMxgHMiS4T1yszpWqzU7ilNel6qG1Hel6wnzh9Ys65XsDM+IkurEsQKnM7CkLGec1gOESTODoMaOp056F8MZJfM7wKUFK8aLeiNHOvdX3Ve5FBOPM+VpQ3wV4BsKxURu6wffO8UVOuj1vboJYeeQx3RllUDsbEvrwboeXJEUIaNgb3kYbVb6cCUu8WLw71Wk4b95oByLTAVqdRGyZbHOOTkoRuxXMVBil4+cMtompAEG9Gt6Hr3Nk1dUTOkw5BDCGsbQV6C5IRBKBvAatTcdk03GLOpP2IdnTTLdCP5HceTTbbYpy0kpgFgfcnesbmrHJ2wYSwqXTaS25uWlofZQYARjzRRzixIUxmUu21Rpa5wtTSe/Q1dKlB8pA7nbu/Q2HGt0bGdY0C0X2M6u2S2/vMaxjxWkiTtMlZtVDXiREe99bSVh9SrShx7lqVEw4EVwBBdeWegrHzYib6yeVClWbVVXd56rBmKphRzOMZTsdiWDDH1m01lYI/DJN2dk4QsNcQL3uDwAiMeMC2TFNh0JITKn0UK56+pAPaF9vkKU6XY0qZ/Fv4FwgPUkdP1BFAglRgeXX/cW9Eoc5paC1sLfSr8nWNx7noVeOxGFclcgcvQIFiJsjhh5z8rDdLnRqhG9PXMVlH3JPrBi6rm1WhDUX+wMJHgmqyl0/HoDGKO07GCq1xW1/Io99fug6o6ShOTAqcrvI76steh84HkSH5snYKd93v0QXaVmdVU0VaHtCVvSNfgikyi07upoKtSe1TG1FdScYA3kzbcCxtbLciydLN+IjOI0rHs0AZhOrr6SnyxWAw7Pcg2cJkOGmM9E4t61oY/cFTJIstb 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MK5doSlJNBJu0/ZkJVZD9ntUAl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HqHkZZGDmcN/GScUO72XZ/9OziithmpeJkUZU+U3DJfULdrV9QoOqlgahhKIUwT81a+FY09VYzdOMypJcAdOAqSwrxfd8HJCd8jqRrD22B8I83+nZSLiwP/XSnTFokYvRMeswyLJFJoMPHYX9z4cDbOFr7N/PF7SSRCLdKDaPv8rF0TRzWu49MI5Cer+CyKrCKA/8GPVdt80PGAt1NhfJWor2/zd5my7AXJ041dH6AkvBfkq9kLuFEtWaf9yINGMmWLlhF16jiqhe7MUivhnJKkNadSRNBUiQtFUTEx3A78gV+OYU0hn/VCS7IB/WVMp6oit/wLmKIsciAyZ490clcHs3+Q+wet3S+R1KJ9Bj/ipYIWShhNge3RtDxLy8aiKB6O0snPeBqyx5IcFw0OE0o4BpIvyVEgGu5gN21tWtLkin2mpF46JjBA9Nr1FbpvIStPEzsRG7yJR0W48+CmhBSEZY45SecGLiNABu80gqdkJtpJy8m78RWpDbYshtJxQJKcI4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: b812b895-83ff-4705-86f7-08dd2e15d60b X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:07.7697 (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: RgR1yJtaA6sirn9pM7h6X9L19KfLntTCswGZ2AHGT/eVxz2Xegzk55nhbGex+YJTMbjUin6Plkvgj0/687IaIbqpntOMNa/qRcjAryAIdgQFLxNb86F9BGRiMyjZb0qO X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 audio-graph-card2 handles many type of device_node, thus need to use of_node_put() in many place. Let's use __free(device_node) and avoid it. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 173 ++++++++------------------ 1 file changed, 54 insertions(+), 119 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 1f5c4e8ff1b90..f4c825b56a7e1 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -333,8 +333,7 @@ static int graph_lnk_is_multi(struct device_node *lnk) static struct device_node *graph_get_next_multi_ep(struct device_node **port) { - struct device_node *ports = port_to_ports(*port); - struct device_node *ep = NULL; + struct device_node *ports __free(device_node) = port_to_ports(*port); struct device_node *rep = NULL; /* @@ -354,13 +353,11 @@ static struct device_node *graph_get_next_multi_ep(struct device_node **port) */ *port = of_graph_get_next_port(ports, *port); if (*port) { - ep = of_graph_get_next_port_endpoint(*port, NULL); + struct device_node *ep __free(device_node) = of_graph_get_next_port_endpoint(*port, NULL); + rep = of_graph_get_remote_endpoint(ep); } - of_node_put(ep); - of_node_put(ports); - return rep; } @@ -373,16 +370,13 @@ static const struct snd_soc_ops graph_ops = { static void graph_parse_convert(struct device_node *ep, struct simple_dai_props *props) { - struct device_node *port = ep_to_port(ep); - struct device_node *ports = port_to_ports(port); + struct device_node *port __free(device_node) = ep_to_port(ep); + struct device_node *ports __free(device_node) = port_to_ports(port); struct simple_util_data *adata = &props->adata; simple_util_parse_convert(ports, NULL, adata); simple_util_parse_convert(port, NULL, adata); simple_util_parse_convert(ep, NULL, adata); - - of_node_put(port); - of_node_put(ports); } static int __graph_parse_node(struct simple_util_priv *priv, @@ -471,14 +465,11 @@ static int __graph_parse_node(struct simple_util_priv *priv, if (!is_cpu && gtype == GRAPH_DPCM) { struct snd_soc_dai_link_component *codecs = snd_soc_link_to_codec(dai_link, idx); struct snd_soc_codec_conf *cconf = simple_props_to_codec_conf(dai_props, idx); - struct device_node *rport = ep_to_port(ep); - struct device_node *rports = port_to_ports(rport); + struct device_node *rport __free(device_node) = ep_to_port(ep); + struct device_node *rports __free(device_node) = port_to_ports(rport); snd_soc_of_parse_node_prefix(rports, cconf, codecs->of_node, "prefix"); snd_soc_of_parse_node_prefix(rport, cconf, codecs->of_node, "prefix"); - - of_node_put(rport); - of_node_put(rports); } if (is_cpu) { @@ -526,25 +517,21 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, * }; * }; */ - 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); + struct device_node *mcpu_ep __free(device_node) = of_graph_get_next_port_endpoint(mcpu_port, NULL); + struct device_node *mcpu_ports __free(device_node) = port_to_ports(mcpu_port); + struct device_node *mcpu_port_top __free(device_node) = of_graph_get_next_port(mcpu_ports, NULL); + struct device_node *mcpu_ep_top __free(device_node) = of_graph_get_next_port_endpoint(mcpu_port_top, NULL); + struct device_node *mcodec_ep_top __free(device_node) = of_graph_get_remote_endpoint(mcpu_ep_top); + struct device_node *mcodec_port_top __free(device_node) = ep_to_port(mcodec_ep_top); + struct device_node *mcodec_ports __free(device_node) = port_to_ports(mcodec_port_top); int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); int ret = 0; - if (cpu_idx > dai_link->num_cpus) { - ret = -EINVAL; - goto mcpu_err; - } + if (cpu_idx > dai_link->num_cpus) + return -EINVAL; for_each_of_graph_port_endpoint(mcpu_port, mcpu_ep_n) { - struct device_node *mcodec_ep_n; - struct device_node *mcodec_port; - int codec_idx; + int codec_idx = 0; /* ignore 1st ep which is for element */ if (mcpu_ep_n == mcpu_ep) @@ -553,16 +540,13 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, 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)) { - ret = -EINVAL; - goto mcpu_err; - } + struct device_node *mcodec_ep_n __free(device_node) = of_graph_get_remote_endpoint(mcpu_ep_n); + struct device_node *mcodec_port __free(device_node) = ep_to_port(mcodec_ep_n); - codec_idx = 0; ret = -EINVAL; + if (mcodec_ports != port_to_ports(mcodec_port)) + break; + for_each_of_graph_port(mcodec_ports, mcodec_port_i) { /* ignore 1st port which is for pair connection */ @@ -582,18 +566,9 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, } codec_idx++; } - of_node_put(mcodec_port); - of_node_put(mcodec_ep_n); if (ret < 0) break; } -mcpu_err: - of_node_put(mcpu_ep); - of_node_put(mcpu_port_top); - of_node_put(mcpu_ep_top); - of_node_put(mcodec_ep_top); - of_node_put(mcodec_port_top); - of_node_put(mcodec_ports); return ret; } @@ -605,7 +580,6 @@ static int graph_parse_node_multi(struct simple_util_priv *priv, { struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct device *dev = simple_priv_to_dev(priv); - struct device_node *ep; int ret = -ENOMEM; int nm_idx = 0; int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); @@ -640,12 +614,11 @@ static int graph_parse_node_multi(struct simple_util_priv *priv, * }; * }; */ - ep = graph_get_next_multi_ep(&port); + struct device_node *ep __free(device_node) = graph_get_next_multi_ep(&port); if (!ep) break; ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, idx); - of_node_put(ep); if (ret < 0) goto multi_err; @@ -669,12 +642,9 @@ 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 = of_graph_get_next_port_endpoint(port, NULL); - int ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); - - of_node_put(ep); + struct device_node *ep __free(device_node) = of_graph_get_next_port_endpoint(port, NULL); - return ret; + return __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); } static int graph_parse_node(struct simple_util_priv *priv, @@ -751,7 +721,6 @@ static void graph_link_init(struct simple_util_priv *priv, struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct device_node *ep_cpu, *ep_codec; - struct device_node *ports_cpu, *ports_codec; unsigned int daifmt = 0, daiclk = 0; bool playback_only = 0, capture_only = 0; enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; @@ -766,7 +735,7 @@ static void graph_link_init(struct simple_util_priv *priv, } else { ep_cpu = of_graph_get_next_port_endpoint(port_cpu, NULL); } - ports_cpu = port_to_ports(port_cpu); + struct device_node *ports_cpu __free(device_node) = port_to_ports(port_cpu); of_node_get(port_codec); if (graph_lnk_is_multi(port_codec)) { @@ -776,8 +745,7 @@ static void graph_link_init(struct simple_util_priv *priv, } else { ep_codec = of_graph_get_next_port_endpoint(port_codec, NULL); } - ports_codec = port_to_ports(port_codec); - + struct device_node *ports_codec __free(device_node) = port_to_ports(port_codec); graph_parse_daifmt(ep_cpu, &daifmt, &bit_frame); graph_parse_daifmt(ep_codec, &daifmt, &bit_frame); @@ -832,8 +800,6 @@ static void graph_link_init(struct simple_util_priv *priv, if (priv->ops) dai_link->ops = priv->ops; - of_node_put(ports_cpu); - of_node_put(ports_codec); of_node_put(port_cpu); of_node_put(port_codec); of_node_put(ep_cpu); @@ -845,8 +811,8 @@ 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 = of_graph_get_next_port_endpoint(cpu_port, NULL); - struct device_node *codec_port = of_graph_get_remote_port(cpu_ep); + struct device_node *cpu_ep __free(device_node) = of_graph_get_next_port_endpoint(cpu_port, NULL); + struct device_node *codec_port __free(device_node) = of_graph_get_remote_port(cpu_ep); int ret; /* @@ -856,19 +822,16 @@ int audio_graph2_link_normal(struct simple_util_priv *priv, */ ret = graph_parse_node(priv, GRAPH_NORMAL, codec_port, li, 0); if (ret < 0) - goto err; + return ret; /* * call CPU, and set DAI Name */ ret = graph_parse_node(priv, GRAPH_NORMAL, cpu_port, li, 1); if (ret < 0) - goto err; + return ret; graph_link_init(priv, lnk, cpu_port, codec_port, li, 1); -err: - of_node_put(codec_port); - of_node_put(cpu_ep); return ret; } @@ -878,8 +841,8 @@ int audio_graph2_link_dpcm(struct simple_util_priv *priv, struct device_node *lnk, struct link_info *li) { - 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 *ep __free(device_node) = of_graph_get_next_port_endpoint(lnk, NULL); + struct device_node *rep __free(device_node) = of_graph_get_remote_endpoint(ep); struct device_node *cpu_port = NULL; struct device_node *codec_port = NULL; struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); @@ -963,8 +926,6 @@ int audio_graph2_link_dpcm(struct simple_util_priv *priv, graph_link_init(priv, lnk, cpu_port, codec_port, li, is_cpu); err: - of_node_put(ep); - of_node_put(rep); of_node_put(cpu_port); of_node_put(codec_port); @@ -977,9 +938,9 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, struct link_info *li) { struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); - struct device_node *port0, *port1, *ports; - struct device_node *codec0_port, *codec1_port; - struct device_node *ep0, *ep1; + struct device_node *port0 = lnk; + struct device_node *ports __free(device_node) = port_to_ports(port0); + struct device_node *port1 __free(device_node) = of_graph_get_next_port(ports, port0); u32 val = 0; int ret = -EINVAL; @@ -999,10 +960,6 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, * }; * }; */ - of_node_get(lnk); - port0 = lnk; - ports = port_to_ports(port0); - port1 = of_graph_get_next_port(ports, port0); /* * Card2 can use original Codec2Codec settings if DT has. @@ -1019,7 +976,7 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, c2c_conf = devm_kzalloc(dev, sizeof(*c2c_conf), GFP_KERNEL); if (!c2c_conf) - goto err1; + return ret; c2c_conf->formats = SNDRV_PCM_FMTBIT_S32_LE; /* update ME */ c2c_conf->rates = SNDRV_PCM_RATE_8000_384000; @@ -1032,11 +989,11 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, dai_link->num_c2c_params = 1; } - ep0 = of_graph_get_next_port_endpoint(port0, NULL); - ep1 = of_graph_get_next_port_endpoint(port1, NULL); + struct device_node *ep0 __free(device_node) = of_graph_get_next_port_endpoint(port0, NULL); + struct device_node *ep1 __free(device_node) = of_graph_get_next_port_endpoint(port1, NULL); - codec0_port = of_graph_get_remote_port(ep0); - codec1_port = of_graph_get_remote_port(ep1); + struct device_node *codec0_port __free(device_node) = of_graph_get_remote_port(ep0); + struct device_node *codec1_port __free(device_node) = of_graph_get_remote_port(ep1); /* * call Codec first. @@ -1045,25 +1002,16 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv, */ ret = graph_parse_node(priv, GRAPH_C2C, codec1_port, li, 0); if (ret < 0) - goto err2; + return ret; /* * call CPU, and set DAI Name */ ret = graph_parse_node(priv, GRAPH_C2C, codec0_port, li, 1); if (ret < 0) - goto err2; + return ret; graph_link_init(priv, lnk, codec0_port, codec1_port, li, 1); -err2: - of_node_put(ep0); - of_node_put(ep1); - of_node_put(codec0_port); - of_node_put(codec1_port); -err1: - of_node_put(ports); - of_node_put(port0); - of_node_put(port1); return ret; } @@ -1153,8 +1101,8 @@ 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 = of_graph_get_next_port_endpoint(cpu_port, NULL); - struct device_node *codec_port = of_graph_get_remote_port(cpu_ep); + struct device_node *cpu_ep __free(device_node) = of_graph_get_next_port_endpoint(cpu_port, NULL); + struct device_node *codec_port __free(device_node) = of_graph_get_remote_port(cpu_ep); /* * CPU { @@ -1171,9 +1119,6 @@ static int graph_count_normal(struct simple_util_priv *priv, li->num[li->link].codecs = graph_counter(codec_port); - of_node_put(cpu_ep); - of_node_put(codec_port); - return 0; } @@ -1181,8 +1126,8 @@ static int graph_count_dpcm(struct simple_util_priv *priv, struct device_node *lnk, struct link_info *li) { - struct device_node *ep = of_graph_get_next_port_endpoint(lnk, NULL); - struct device_node *rport = of_graph_get_remote_port(ep); + struct device_node *ep __free(device_node) = of_graph_get_next_port_endpoint(lnk, NULL); + struct device_node *rport __free(device_node) = of_graph_get_remote_port(ep); /* * dpcm { @@ -1211,9 +1156,6 @@ static int graph_count_dpcm(struct simple_util_priv *priv, li->num[li->link].codecs = graph_counter(rport); /* BE */ } - of_node_put(ep); - of_node_put(rport); - return 0; } @@ -1221,13 +1163,13 @@ static int graph_count_c2c(struct simple_util_priv *priv, struct device_node *lnk, struct link_info *li) { - struct device_node *ports = port_to_ports(lnk); - struct device_node *port0 = lnk; - 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); + struct device_node *ports __free(device_node) = port_to_ports(lnk); + struct device_node *port0 = of_node_get(lnk); + struct device_node *port1 = of_node_get(of_graph_get_next_port(ports, of_node_get(port0))); + struct device_node *ep0 __free(device_node) = of_graph_get_next_port_endpoint(port0, NULL); + struct device_node *ep1 __free(device_node) = of_graph_get_next_port_endpoint(port1, NULL); + struct device_node *codec0 __free(device_node) = of_graph_get_remote_port(ep0); + struct device_node *codec1 __free(device_node) = of_graph_get_remote_port(ep1); /* * codec2codec { @@ -1247,13 +1189,6 @@ static int graph_count_c2c(struct simple_util_priv *priv, li->num[li->link].codecs = graph_counter(codec1); - of_node_put(ports); - of_node_put(port1); - of_node_put(ep0); - of_node_put(ep1); - of_node_put(codec0); - of_node_put(codec1); - return 0; } From patchwork Mon Jan 6 05:49:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926969 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011024.outbound.protection.outlook.com [52.101.125.24]) (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 61C8B17C for ; Mon, 6 Jan 2025 05:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142563; cv=fail; b=bm1OiNc42WOo/BTEWAvLPYesa2y3+e7X+jwpAOhoOZATQnnEmsNGpbmnYKZLNcuAwJ9+PdNuzxPUSla8Q9FuubNgtPi7jm1fsd6GYj63vxvyFx/tehyv36uDeZix0BqxW+WZqF/dkF4RUqqHuPhQvLG+/AETXRDsDOiS+G0tgh8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142563; c=relaxed/simple; bh=tGcFxxdLtL9v/FocUqoOF+0WgyRgMs3IoGhbzcBshD4=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=rmkOafo4Ds8oHZtd9NQt3Kr7CKmeFz9Fzmwu9DmSef5ofHWTZ8kWWzwiE/SJum4/hbPrurc1wC15bhIFmDOZV3h1ySzKMp8tIwiOP6lcPaTJZ8zbMU/eiCDCmFDgmegsfm/oPtYhPjZWFLQoDKJxX34HmnJDrJep84LTA9zFCEY= 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=NC+S5/ri; arc=fail smtp.client-ip=52.101.125.24 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="NC+S5/ri" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EPkqvU2TwGJsBurC1ZgzJip2oXeVk4JjiCZvA7v3ZRVc8o07h0YIDbUXA7xBgTkffNzgrer4AC3tnrZ0O7072Cacv5K0gXh7rvCyma0o4e4oVzEajitiohd9cIbN2GjM4sCNPberfPhAKw8rvHR7AkFUZwhPsScdH4Gw1r2CJN9SYuA+JV2RN7Ktnwy6T0tDHktFCYMj/e6r63ysdhhRLB2//aZid4xIRWue9uViWt3acaT3PnGdT7dyYoqH6mEe1nsC/0IVsx9/KsRRvJPeMwvnjFhwkBmlv4g88W7iu/H+CfG0z0U9ReRByl1B7d+HYJKX9cy0if9m+upTSgriCA== 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=0zUoAJeE3+6qnE+y8FzuZc7ykrl2IL9PBgyEkfxctoM=; b=Ei3nUHHBRMpIULxcwvAPrph41lp0m+OVWJ+ct+pYPTwvd2wDN1MSLGJ5OvIDdeTWpPvMS++6g1a1u9OA1pKTHI5R687snnW5ODDeNt5h/U3VsRXLCeJPdMWgw0IgQts/w2V4VKWISdBxfX9hZlbsuQqURtcxUMikCAjFal+zWyS8FzUSajLqwoSVMCv3bR2f9JQqrvccKdGiWw2lQxjz9SlH9w0+u0ZYG5CbvYbQ7Hx8BfTWYIIsT1VYQwbRar/YNAn1e+/nwKZGkL2KdffHK6GT/mmXZUyRrND7rBDA2md6NuDNjXauO2FDNfWpqYKAGFF+bHDsDZMXPuX3+t0aPA== 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=0zUoAJeE3+6qnE+y8FzuZc7ykrl2IL9PBgyEkfxctoM=; b=NC+S5/riuL2XdZDd6gtz3lrjSxUyDrB9CA0wqw1mR0nSxFFH62LQr9gz4Zu38AmeFmkImKeAxfaU2kezFThnt2BN3mpPuTc1KUa4JMHbdCNsu3EEounUGHbmJqNotj5k0E09Y3jwRn5+I6yiUWh/gYWY8kJoiHo/Kw+h6/vNzqI= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:19 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:19 +0000 Message-ID: <87wmf8o5k1.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 2/7] ASoC: audio-graph-card: use __free(device_node) for device node Date: Mon, 6 Jan 2025 05:49:18 +0000 X-ClientProxiedBy: TYCP286CA0255.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:456::15) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 042c2a4b-ebf2-451a-a3aa-08dd2e15dc72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: VyEV/1hihnhf+/r2BdrwLJ0LMJLOelrc28NAQuQOppQDh2myB+Be4i25A9IXjP1S/QnM+yGn0njVg7s27YIRB0VyM38p1dJY5L2uUa6Wgw8Z1H/2WAd4pJk8Omo4nyvx1Kme+c34oU8JS3tGR+brEfozrn+y2429mx5nD6WTqcm4lyJbHAJm5yUkM+Jfa89m96MXD/sCJsRMFWeyNz93HqZSaNsaJhTsMnSZIc3/XrJquDMPnH6gHZW4zfdvoZ9Ik2vW2wr7CuJc3nP39cqdF2Wsc7DluVMIztOIgX4pZoOrZ5kZ3Hc8dGEtJzTtlQRDgkZPlXQ67FdJd/0fGT3d318HQK555DzAgHdvLRN2KJ0rt3OvkQNWMSrk5oXPmivmyC/jzbP8mBW7JESk7GUYuTJ6Kx+o/kh1loaHDD6YWVnzQvsNhFuyGnzy4zEL/oTQT5ibvfPjVtwkmdwjqVCdL8xOjUxkQ+mIvXqbpoCIQbogAOwFScrf5cQmq2OQr3utDMrgPrVIlxcdJgPKp8mDNx8BAXvkl/bfHRxZnkj0a78cH5SVcVbGsvGSVZDIYrHF5nrNDA4Hkc4hoEyNV92wmsj31xMSWfkN9YeFNh0MSEL0V7wK1CX/mXT06b1r40yUxB9e9uoVDFmx4p8MXnvri7g3zzPf099+btBI0NaMdauWP6vEYsttqfUkXma3DtG5dbCAAFl8Ot7VBkWY9g2Z/McYKNRVlqKtJ9GcJ06UL7ozg97N1EXHNWOwR2lDZQ6srH7FzsgbNh7djqzsMQ/o/kL+ksxjYuiMF9Z8jSJx1nX/zbe7GlpEuwrjhIbCvy6iFgRSuIGO+nkW5Huvh/hdZdPakjIRlUTIWHt23uZdnaprz7Un50CqR4byHP4mX9A7GMuU1rZSh/WJ7+aPmrfqed0byAIbkboc3hXQ36nvSjOoHJ8gY5gvmbWSbwoQnc/6Gvh6Ae4u7eVN7u4T+FYvtV31KKPhtLpHyziR5J/RYuC8vjLxsqXe7gl+/so/d2t96h+UEBdm1yFBwxTfMDInZzXu1xxCpx8kgE9m3KgNBli2QLZUy8yTK2ZIDB1VHVKP7D3Bjww8rXIheizU0DLLLHlV/MFa0jAJQU7l/UrPg7Mq9LkFWKsij439Nn88Qlhfwf0UJAdJbEHQiaVJkhnSlUlmEIyf9MLd0nziXAXOxkAmUsFVSvtWfYO7HSVaJXfyzAxJPFrgv2u6GZhMddKMViEpcPPynt/eHDHGTUQ3fUEwCV56vFNan/q/oS5xjgrcOLpLdO6SCIgIR3XkG6n5YGXuFTXT6dcOwHFvR5vvpkIOdeVqr8ItE3Uz4RToe1+1KRclLavOCrpvqewPZWUW0y+0ew0ZY/33MBjFWoMOuBL5i1vETKkdGmIgUa0MzK5ACM9BpG6IljBu30bKt1PJIUXKqyXX4eRrPGDD9MTYraBS2v4YEnPu1FN02EAUBiDq 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P919nF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mna+Tnv57S3lFZ0y88Fcu2PT1KaIFtowDMYok7NfPaHm0VpY2fUABCHNNYCAHEsyH8sE1ThCiYhhm0ULJ0OFw78ejw5CyA6xgV87TgowRnEKcWAtcsJb4F4mPqbp9NnAmbchJVHMPG2j7hnV4lItXAsiqOGZNyB8HsnobXA741fZam03c7hGrusTwlVI8qFu+ZR6CDpkpeDRn8wI4M7RtY0okrQcIb/eUdmpe+OpUtaOWExL04ji1E8MBzPUTifoLicUlJa/nV5QE1UGKmUXOYA8hoPSHfkTE3aGPVfwAq00/1XEXgV+Soi8KvJr8F3BqqYM7XCIPFRu21b9LxPFo22R/ytGUA96RVx7zNXzKwIylsk3rFnOSqCZWeP7JKVj5yq8EIFas4WDLukcsoxe99FzibVUdXgWS2+G0nT7A328bAtXphiBlNaDjzD4/wrtrKcuPnzHXEFrefgFrH87GBZu6cDuG6EXQhaSPZi5UQNudrJmFcfWCgb1ZKMhYU0TJzQCHff4ilsyf1bn1SMD2Chs/WO8tX+7OB9ctJ/c= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 042c2a4b-ebf2-451a-a3aa-08dd2e15dc72 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:19.4755 (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: aZeYX8hMJ5DqxPeZwiRj2aFc2o3/o4gJHaTRVHYSZaHeOID+0L+RqH33UeB+KkCtRVog1hK0XeF0kVFTiEIHu70I61W19yd+D0UJY3eNuuVnCxcsyUuF4JVrLMT2Gr2z X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 audio-graph-card handles many type of device_node, thus need to use of_node_put() in many place. Let's use __free(device_node) and avoid it. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 48 ++++++++-------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 7655425a3deb1..7c422535b01a2 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -81,18 +81,14 @@ static void graph_parse_convert(struct device *dev, struct simple_util_data *adata) { struct device_node *top = dev->of_node; - struct device_node *port = ep_to_port(ep); - struct device_node *ports = port_to_ports(port); - struct device_node *node = of_graph_get_port_parent(ep); + struct device_node *port __free(device_node) = ep_to_port(ep); + struct device_node *ports __free(device_node) = port_to_ports(port); + struct device_node *node __free(device_node) = of_graph_get_port_parent(ep); simple_util_parse_convert(top, NULL, adata); simple_util_parse_convert(ports, NULL, adata); simple_util_parse_convert(port, NULL, adata); simple_util_parse_convert(ep, NULL, adata); - - of_node_put(port); - of_node_put(ports); - of_node_put(node); } static int graph_parse_node(struct simple_util_priv *priv, @@ -140,10 +136,10 @@ static int graph_link_init(struct simple_util_priv *priv, struct device_node *top = dev->of_node; struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); - struct device_node *port_cpu = ep_to_port(ep_cpu); - struct device_node *port_codec = ep_to_port(ep_codec); - struct device_node *ports_cpu = port_to_ports(port_cpu); - struct device_node *ports_codec = port_to_ports(port_codec); + struct device_node *port_cpu __free(device_node) = ep_to_port(ep_cpu); + struct device_node *port_codec __free(device_node) = ep_to_port(ep_codec); + struct device_node *ports_cpu __free(device_node) = port_to_ports(port_cpu); + struct device_node *ports_codec __free(device_node) = port_to_ports(port_codec); enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; bool playback_only = 0, capture_only = 0; @@ -152,7 +148,7 @@ static int graph_link_init(struct simple_util_priv *priv, ret = simple_util_parse_daifmt(dev, ep_cpu, ep_codec, NULL, &dai_link->dai_fmt); if (ret < 0) - goto init_end; + return ret; graph_util_parse_link_direction(top, &playback_only, &capture_only); graph_util_parse_link_direction(port_cpu, &playback_only, &capture_only); @@ -187,14 +183,7 @@ static int graph_link_init(struct simple_util_priv *priv, if (priv->ops) dai_link->ops = priv->ops; - ret = simple_util_set_dailink_name(dev, dai_link, name); -init_end: - of_node_put(ports_cpu); - of_node_put(ports_codec); - of_node_put(port_cpu); - of_node_put(port_codec); - - return ret; + return simple_util_set_dailink_name(dev, dai_link, name); } static int graph_dai_link_of_dpcm(struct simple_util_priv *priv, @@ -250,8 +239,6 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv, } else { struct snd_soc_codec_conf *cconf = simple_props_to_codec_conf(dai_props, 0); struct snd_soc_dai_link_component *codecs = snd_soc_link_to_codec(dai_link, 0); - struct device_node *port; - struct device_node *ports; /* CPU is dummy */ @@ -267,14 +254,12 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv, "be.%pOFP.%s", codecs->of_node, codecs->dai_name); /* check "prefix" from top node */ - port = ep_to_port(ep); - ports = port_to_ports(port); + struct device_node *port __free(device_node) = ep_to_port(ep); + struct device_node *ports __free(device_node) = port_to_ports(port); + snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, "prefix"); snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, "prefix"); snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, "prefix"); - - of_node_put(ports); - of_node_put(port); } graph_parse_convert(dev, ep, &dai_props->adata); @@ -361,8 +346,6 @@ static int __graph_for_each_link(struct simple_util_priv *priv, struct device *dev = simple_priv_to_dev(priv); struct device_node *node = dev->of_node; struct device_node *cpu_port; - struct device_node *codec_ep; - struct device_node *codec_port; struct device_node *codec_port_old = NULL; struct simple_util_data adata; int rc, ret = 0; @@ -374,8 +357,8 @@ static int __graph_for_each_link(struct simple_util_priv *priv, /* loop for all CPU endpoint */ for_each_of_graph_port_endpoint(cpu_port, cpu_ep) { /* get codec */ - codec_ep = of_graph_get_remote_endpoint(cpu_ep); - codec_port = ep_to_port(codec_ep); + struct device_node *codec_ep __free(device_node) = of_graph_get_remote_endpoint(cpu_ep); + struct device_node *codec_port __free(device_node) = ep_to_port(codec_ep); /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); @@ -399,9 +382,6 @@ static int __graph_for_each_link(struct simple_util_priv *priv, ret = func_noml(priv, cpu_ep, codec_ep, li); } - of_node_put(codec_ep); - of_node_put(codec_port); - if (ret < 0) return ret; From patchwork Mon Jan 6 05:49:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926970 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010044.outbound.protection.outlook.com [52.101.228.44]) (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 0EEB017C for ; Mon, 6 Jan 2025 05:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142572; cv=fail; b=L6F1je5CmKHsD3DC+pqG6Gn3k3boqzfWVIWp+BAEPYGOD1PL+hy5hBbt3GJJoxS4RyZVT9xndOApwUM0K5bpgmH4RzQnFIiyEMbKt13+rDbWNwaWjadyp6ckgcMWSEd3RBTg/T/aXsv58sx8BlUkAFVdXsEmUJHjtaZ4Y3kKYiw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142572; c=relaxed/simple; bh=dFfg5Ae/MoPJH2Ejeb8Iihqmn9ztw02wCYKV3a6BO08=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=Cqt6tMHd7QD0ODP5aiRMDhuQKDG11Zohl+8mLcoODCieezg0f22A+hQizkWL0zHll5IEqUAK0NX/ADSR1BBUY9hxArSig5fKTQBiXhtHfY+AHcwFlJFjEMI2VSKWL8Vz/nPeh6VxGz2bfIBPzITkEU/21o3SXhjdMInbBAVS9p4= 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=owJWgjfx; arc=fail smtp.client-ip=52.101.228.44 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="owJWgjfx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x5kjXoNcy+ay+RoHxHZ/tq94Nt4tkPslpywGcgt2+RVdcv5t7khor96+zQyW0t+jx+OfoY3ir0RFvgcXxDDvsXpNN7D9KZq01SFvXCB1cL4gT891iFh5GASY2HBmVmt8hyOPhsk8X7ixRk7W1BtJ0i+JBA1HDfJSkHji+/UZbdAqjS2JQNQgzc36CLR5ndIGQYZkNUK7osRr2DLMNewGBkr3LF3tLlcq14Dgjp6L8o2ooR9KNc9lb+VCmR0hpjFuAooqzuLTyZov1d6gtKGcDug7/iS9C4AFPxdlG8bwkLeq5A9msr9XEvpoAQqv5E0/NYdC+8nwFfS0Qgii3Vo+Ig== 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=S3x994mu//c+VzG9sCnHiRUdAe/K89WyGbiEHnI/TXE=; b=ZsquGWMtM51XhYLtqp4PTe9kavr6YigRLujJrL9Mdsjhw8daQNDVrBEjw2TsUQGZ73T6uo0NSAoYAW9IEAJ/fnmD4oO/HZjeyZD5PO5dI8Omuffw84EmL4EgBsgqoCHZCIz4GmrewMZuQ7ydxoDM+yZNB2neb/QQFH7cx4fF712uMrHaAaUwOKDEV6RJVVuI8jYOGdHmMVqldk2vaNf4r4oYadvDM6FK84RG+9D0byh3S7nNoT1SC2rjuNP+tJoSfV3yKZVoJBrtYHQmYwgsbHWGvaM3jTtkWQvNN8NQeVWORJ8AeajCxmYwY7Qg2nbvSvHuIml31TuX9L8Tiv1m+w== 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=S3x994mu//c+VzG9sCnHiRUdAe/K89WyGbiEHnI/TXE=; b=owJWgjfxKru0prgTS+Rkgy2bnz0ETOvKkJg3LXuVeN7k1pIXsJxEXeCHkIfTtPIctU92lY8amCQ0Bp7ycj+W1S8mnsEMpyIdyiWThEYp20zpBwhUaRPrU6+H3azQ4+ZzTQMl8YMwPCv6OTY/cLhHu6qGYs54tk2ZbwUhGQL2bf8= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:28 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:28 +0000 Message-ID: <87v7uso5js.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 3/7] ASoC: simple-card: use __free(device_node) for device node Date: Mon, 6 Jan 2025 05:49:28 +0000 X-ClientProxiedBy: TYCP286CA0135.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b6::19) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cd6581b-2107-401c-30e4-08dd2e15e23a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: YcpxeJBkcrVwoAhJvmRcMId6goOCi1wMyea9AOU3omLI/r9GBMBbdHHNu4rAEqToT5N0hD1wbkeq5tfbiZkV7+34tKEGwofpVYfMD8uBfE+A0RPFjLQ2UQSwJcrL+pc6roaYTvSy5Xrk+vcz0iRuscObpangsKqAqb6jgN2cbBIOyFkiRGjjrxndAQQaz5OqlPE2BQ/r8nUPM8rNApnko21jqF2QhRbKWaU8SrE+xpGEfkHnEC1Vkjx952BuhdoKRisbM6jcRwN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UIkT37mGbK1R+j1RJhMoTH//qw/xlk7JBpydO3kCOWjZ5Weg2ZcTqsQs9GXuyn3a8xUoajC7IjGDPMpy3B7h89rxajQr8oLKJXQ/+IXgBNXHUWU/GAnrO/jMLL5FrmTdWg/X 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dl8iiBasJKeTKLsP6VsMkdkP4t0aUnZY2sUb/Ys/IkRyHNzsEiY2JyLXEXfCvPKfyzBaNoiX5yT6FiQ72vkmDk/BH0j51aylcB/TbbFikPceC4+UkzjvmvgM4jkb1LsjaXq4wCoyU0SDZsZxWD+15v5DUUMqM2QifKQyISFRcMikI1Jv2HRb9gkoJgVeAAg62pIXMzFBKHcwc/iptI/Bz7+afSi82HVRuqOMMnOyDfNmKfTSgxqNwrH1jm+zMmqki8eVorCRpTgme8jyCDFQarSjjuUb27bJFgq1egFMuo0iy1jKZCgaqqrWNbf6ILbgOovkoIF7YPTo1zOExkgqJLH/tcha1NFNCkEodh523T6E5qjN1wfnFxRLImgH2gG8wZgZPyPXfssp0BSF+bD62bu1UqTjP+/8jOpD8a/0jpJhaHIAeX8VM6mG9CSTqvQw5UPZP3s1hBpjuk144+MPbgx64tcLyujgUgKsQzdUjObvHUFlOQDfNDousATf5GgKZgVmUl+F20iKoRR37aLwgS/n6JqUgzUuNlq1O9qt/FO2zvJ5kamh39SNlLi3wziEgXTKE/d+StprNuYv2BjNMVZCGagJcnAW6ghjQ8yUgmppLItqlScpf96ERfOtPkkw00yWLboj+vmD7+e1EwxkYcPQa73WVpVA7LW6s5X8hJ40yxkcb0rKSTi7BFWXbbqfG6gV1d5jw/v/bi1w7KfLsCesXeX/38DuNNSCO4lSiPr8Czc6WW5GBJ1tpteOg7LrMkcJVyOWRZzcS9PoyVRM9YsaeZkYI8NBZLZDeBis6nfXvyeED156OuzrexPP61QxvEE7/0gCWexSpKUyz1Mh0OJJrdgJiQiYDchF5K74/mT0WLx9GWHpALE/Q5UCd6dvneMODsOnNkBcovjshkQLYYmRUCgu9Yh5ubrsyq/o/TR5k0r8GmZ/Hz2DQ3igv9C4apAWYdFSRD+Fmu3Ds1LGSx8US8iagqaTDjwbpSol9ba3g5fk4AmE6vOLBeYwhRbIt7MFLEiAInC4D5rOa2oHqaW2oDZiIAyCGed/0m1PW0XtyLyOrcdzIvDtpNuheiGU40aYn2Q6iqQzCB02GztUz0V+uAjOtvlgqZ6xCUcFcZSj1TaP3l4V3qzQHhUvkkUuG7JEgSKpTNcYyu8Un/n77Jo2dYxgA+uRNILRjZ47QC5PHFTR463Ezf15gcskJgWqaL0fE6+rn3gcGMjrd5VWdxDLYmwCvneAs6j9Od5NXsYDUsWKm+aVZs1vW+Zyass52YlTeURgBU6Ie/crA0R6JxH3v4dQSfR5pjgALKpwHpqfZdCxS+G3fnwo47gLYrS24zLuaCigy+jO6N7NfsMd9vw+VGzvKnSr2sACG5vvji/joTqFP/nmDA0eKrtmlAv6/WppsiHRs6qrOzDlmAX88gMikh7KkN2HHlhfIRTFuLjjk+d03MuscqO0GQkrzqyO+LCvSV0uC33rUywKRMSxvpEvAEj4XqpVcG09QUe0EuGTN97y7ewkZhmEv9WCCDTGQ1O5lTkaKiTuxsZ/3+lYCHe0+1syNfDON6W6C2gtb8dsuDFcrFgi5zCVKRRFMGQG3cGkdnAJob/+FRFgh4JV8lwsjwheo5110SLwFxF8ba8= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cd6581b-2107-401c-30e4-08dd2e15e23a X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:28.2342 (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: KcXFdDc0cxulkUgk0dv6+we0XCY4KHS3ad/LY42zjY6bWSUqzV9UvCZTQu8gXASfn0rba0kqDZTiKSwn/BXxo5ibD1X6ADD3wNa2TbrL85RpxbgbXmptVUDNL1sMkojn X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 simple-card handles many type of device_node, thus need to use of_node_put() in many place. Let's use __free(device_node) and avoid it. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 58 ++++++++++----------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 76a1d05e2ebec..afe7e79ffdbdb 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -120,14 +120,12 @@ static void simple_parse_convert(struct device *dev, struct simple_util_data *adata) { struct device_node *top = dev->of_node; - struct device_node *node = of_get_parent(np); + struct device_node *node __free(device_node) = of_get_parent(np); simple_util_parse_convert(top, PREFIX, adata); simple_util_parse_convert(node, PREFIX, adata); simple_util_parse_convert(node, NULL, adata); simple_util_parse_convert(np, NULL, adata); - - of_node_put(node); } static int simple_parse_node(struct simple_util_priv *priv, @@ -176,7 +174,7 @@ static int simple_link_init(struct simple_util_priv *priv, struct device_node *top = dev->of_node; struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); - struct device_node *node = of_get_parent(cpu); + struct device_node *node __free(device_node) = of_get_parent(cpu); enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; bool playback_only = 0, capture_only = 0; @@ -185,7 +183,7 @@ static int simple_link_init(struct simple_util_priv *priv, ret = simple_util_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) - goto init_end; + return ret; graph_util_parse_link_direction(top, &playback_only, &capture_only); graph_util_parse_link_direction(node, &playback_only, &capture_only); @@ -215,11 +213,7 @@ static int simple_link_init(struct simple_util_priv *priv, dai_link->init = simple_util_dai_init; dai_link->ops = &simple_ops; - ret = simple_util_set_dailink_name(dev, dai_link, name); -init_end: - of_node_put(node); - - return ret; + return simple_util_set_dailink_name(dev, dai_link, name); } static int simple_dai_link_of_dpcm(struct simple_util_priv *priv, @@ -232,7 +226,7 @@ static int simple_dai_link_of_dpcm(struct simple_util_priv *priv, struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct device_node *top = dev->of_node; - struct device_node *node = of_get_parent(np); + struct device_node *node __free(device_node) = of_get_parent(np); char *prefix = ""; char dai_name[64]; int ret; @@ -296,7 +290,6 @@ static int simple_dai_link_of_dpcm(struct simple_util_priv *priv, out_put_node: li->link++; - of_node_put(node); return ret; } @@ -312,15 +305,13 @@ static int simple_dai_link_of(struct simple_util_priv *priv, struct snd_soc_dai_link_component *codecs = snd_soc_link_to_codec(dai_link, 0); struct snd_soc_dai_link_component *platforms = snd_soc_link_to_platform(dai_link, 0); struct device_node *cpu = NULL; - struct device_node *node = NULL; - struct device_node *plat = NULL; char dai_name[64]; char prop[128]; char *prefix = ""; int ret, single_cpu = 0; cpu = np; - node = of_get_parent(np); + struct device_node *node __free(device_node) = of_get_parent(np); dev_dbg(dev, "link_of (%pOF)\n", node); @@ -329,7 +320,7 @@ static int simple_dai_link_of(struct simple_util_priv *priv, prefix = PREFIX; snprintf(prop, sizeof(prop), "%splat", prefix); - plat = of_get_child_by_name(node, prop); + struct device_node *plat __free(device_node) = of_get_child_by_name(node, prop); ret = simple_parse_node(priv, cpu, li, prefix, &single_cpu); if (ret < 0) @@ -352,9 +343,6 @@ static int simple_dai_link_of(struct simple_util_priv *priv, ret = simple_link_init(priv, cpu, codec, li, prefix, dai_name); dai_link_of_err: - of_node_put(plat); - of_node_put(node); - li->link++; return ret; @@ -374,7 +362,6 @@ static int __simple_for_each_link(struct simple_util_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; @@ -386,14 +373,11 @@ static int __simple_for_each_link(struct simple_util_priv *priv, is_top = 1; } - add_devs = of_get_child_by_name(top, PREFIX "additional-devs"); + struct device_node *add_devs __free(device_node) = of_get_child_by_name(top, PREFIX "additional-devs"); /* loop for all dai-link */ do { struct simple_util_data adata; - struct device_node *codec; - struct device_node *plat; - struct device_node *np; int num = of_get_child_count(node); /* Skip additional-devs node */ @@ -403,26 +387,26 @@ static int __simple_for_each_link(struct simple_util_priv *priv, } /* get codec */ - codec = of_get_child_by_name(node, is_top ? - PREFIX "codec" : "codec"); + struct device_node *codec __free(device_node) = + of_get_child_by_name(node, is_top ? PREFIX "codec" : "codec"); if (!codec) { ret = -ENODEV; goto error; } /* get platform */ - plat = of_get_child_by_name(node, is_top ? - PREFIX "plat" : "plat"); + struct device_node *plat __free(device_node) = + of_get_child_by_name(node, is_top ? PREFIX "plat" : "plat"); /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); - for_each_child_of_node(node, np) { + for_each_child_of_node_scoped(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) { + for_each_child_of_node_scoped(node, np) { if (plat == np || add_devs == np) continue; /* @@ -452,22 +436,16 @@ static int __simple_for_each_link(struct simple_util_priv *priv, ret = func_noml(priv, np, codec, li, is_top); } - if (ret < 0) { - of_node_put(codec); - of_node_put(plat); - of_node_put(np); + if (ret < 0) goto error; - } } - of_node_put(codec); - of_node_put(plat); node = of_get_next_child(top, node); } while (!is_top && node); error: - of_node_put(add_devs); of_node_put(node); + return ret; } @@ -514,15 +492,13 @@ static void simple_depopulate_aux(void *data) static int simple_populate_aux(struct simple_util_priv *priv) { struct device *dev = simple_priv_to_dev(priv); - struct device_node *node; + struct device_node *node __free(device_node) = of_get_child_by_name(dev->of_node, PREFIX "additional-devs"); 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; From patchwork Mon Jan 6 05:49:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926971 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010049.outbound.protection.outlook.com [52.101.229.49]) (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 E899617C for ; Mon, 6 Jan 2025 05:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142577; cv=fail; b=hzfqm+q44aJAQuD8+GTp1cutUtnw/7fh76EiR1yCzMkvs05LedNb8BmF+xQsuMYMF/QGmuL9BDSXhWG1lUHu8cVG5pzNLJwvSvqsGnB+dcBOxZbA5dwjKMr13fOCsOIUE8EQW5gtQaRN6Ujkm9OpzZ8AUG/RzHwQh2TErtXxOH0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142577; c=relaxed/simple; bh=LBn6g11xJEn5O8cjRKTJLdVA7WnEkS8ZBTd2AqBQgLs=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=oO8Hx9bi6el/vtr2CjnaYQ0TlIdlKEPX4QJb4AI9yEE6z4Z5AQ4xM6RWjq8IpCXDoUATsNxEoMfbr7KMUQ5HDrPome53onk8lMkDkKpzfvgrzjZC7UUMGSp29qYhxrf94GA8sMADHKobrj5HZYq1Wgs5rYJ5Gbxmhojkux/otJY= 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=j+EZPOri; arc=fail smtp.client-ip=52.101.229.49 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="j+EZPOri" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fwX3BTKndysuBB2Nh25v5X/9qJOOvvXvGO6BrKDaDRr1E2V6ymRCMxTxLpliUbO/5RvKQcvcB/+CpPSvtK7oqBUe84DQWIBC/IwxSsQCvE0OSJtwSknRhVnOn7USOrMmzkdWmZa6slbrn7J3WOH4IsQAiw7ns4CRq5mV0J1BHQkSuIQR8Jcw2YjKBApg/xh+jibKEx+9nJhnYwNuFHREb/MNbq2VJvVnved1iqMwRmq6XzQxQ/kxc1YI/5dRZw7QodsDZoOHuKPT7L/oUgfnMRwiDzNlughetSt8YISl8yCiEkitL+UeTs8tW8ZwuH1vMMssNtK7qCzqRg36n9Zvvw== 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=wUQQ+4ZbkQkz4KAmBKMiDOPMK/+30sxXNCa8D+sYDDg=; b=OqGjn1olp78grMRXs3/Zw8G9c3QYn4mOOn+6+/WICJkfsLSOoFjtUz0HIXPamrrtjfYmatATJlZUycl/Syp2d0Doi85TDkWdAxb8mi834Lz4+rz0zNQnXK3PkDKkUEkxdssZGje6h3kmN5nofMGtZWrN7LVb9J4mY6CoQZXQ3xIGVIdPS9cnmN/PkO5ngiF6EIVmXD1/J0qcpYKFpJS4KYsmNgyuGhXtdBs283Ha/ISSVxQTtH0NrxMlI6cOhkcHDplJlBlXHIVA1c0vNshyXbDXlYg6NL8WkKZCHVmVblhWyB0vxp+TxkTWmwnSpn7CM8QuY/qaTC1D8JTBT5peRw== 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=wUQQ+4ZbkQkz4KAmBKMiDOPMK/+30sxXNCa8D+sYDDg=; b=j+EZPOrik/WMpgepZJIeHda7kI+a415JEHCAgp+oMCV6KmajRvGrjJV4SXWigLb/PIvjJE1yRp4mcYKALb/wxn8so68cwt6LOmNs7SLyTtlnZfp1PrgTOKeufrzB74eTFDhfAsqJSi/UKHqZKlZ5N4pKGiTYF/kvp3PXQITLmbI= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:34 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:34 +0000 Message-ID: <87ttaco5jm.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 4/7] ASoC: soc-core: return 0 if np was NULL on snd_soc_daifmt_parse_clock_provider_raw() Date: Mon, 6 Jan 2025 05:49:33 +0000 X-ClientProxiedBy: TYCP286CA0297.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::20) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: db1e3949-61a7-49e9-8e1d-08dd2e15e5b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: stN9tXUiAEgDHGcLuMusE+jxUCahucrwLTjwn+a9cUUEgQEdSbLuhaMDy6MWMRkjBep25jq9gOjlvxylCxGaeurn034ATf/PrVJKOmZ+IuRB3UmIXitu+9096UFaxMJD6GnqTG5Y8QO65gIc716BP4SWyct8gGEeBKktlYZMs6uD+0UT1s29JMTDLyBpfzVjvttvBFp4LsVwr9QNHrvVLLEgAqM2b2zR6oiG9+w+QiEO9hIdZEvObmEGoB+QLVHNAqjw5qZmtm+i4eESd8a7eKUNigX+24X8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OhccVz6mvXallKs74MsSVcDqrU74kHtj57LZE72y39NrlNcIzfIJZd1t9007gkrMyaWz50FecWw4JNru2ERnuPvjbZiQJmCEmAYWYvh+I0s 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O95E0K235mFGJtvZTxggw2Fuxxh0HjMRH5rSGN/zV44+ebnOBbxl0l0R88ybjEuiYFVD0LxRPHOp5OzjgXDBTUkUsZBwP6sSe9APPdunshn/kSmJQ5AzrvE3AiQw0lA/dl0cQ3h3zd80elMNTRYK+uHBu6CyDI+bfn3x7rmjinX6BncSsZAFraoQMNogil8qrWHgOUocHGvYRMs6x2bjPBfMkbo2Tg79gJFzma2L1+XbwxJrxoEW0dqM13IhT8VfDyx5nm91XhlOouxPxDS0zH/J3q4oY8/9gv9cN21Z3WtOngPWgn6wM0XpPH2mcuumbBp8tIUjdQ1eVijTBAU0VOGd7/4EVkpjKMzuX/oRsnsz6pc8O9MJtAMPS4t9ZnlOWGBwgSDmeQbnbd2sXZOs7M41DtHlZEhuIddai5cca71Qm3vpan8PWtyP8i8zK2r2n2M227Kcjr4ygILJhLQm5mmWxhQgiWlI3LDUP3HhcjAhuiyuYbQK+zQvC5a9CSYii9R2T7NKb681K6cWC+aNauyb3PCbx8o3t4tSJoBlKcAlmX/wjMosfKhAC+rjwUXwsW1iHUvnYjwcobfVlb84ptEGYjcQEHLVFRkfPY0pZ16n7bhC9B/lreAA1fboVhOFQ6YViWlSfoBMfUC7VnTG6+14WC4g9u65u1CWus0bO+9pnSFIxCwEjp3Ox25tAcWbaJpbCv2w3aUa3DeVA4jXTmErmVbe2uQ7/Wh37M5prv2whEXp+CxzqzDeqDHshhq6bdS8TZ/foZgKw426tBYTO3Cxet6IAWeDW7ciQGOMck569XS1LI79QS6m9bDoTnEixAVPjki0An9/jr7b7/4HL/FPmeTHrrZAYEdbfoUKDEd6zGC6WDdnAsgkB8cFLZ847wfo+0adbWhS9ufeTc5lIIuxETpUqbzzGN6TBvON8m1MSUh3tMbinlYO1EzFt0m5ASne2y+oXWUeIATJWgVDSh3Xmce6QaKJBGdGVqZqvObZPjaeg5KbDaMSd0Rvw37WhyXUeaW6WAWpSf0S8YNlOTKbyA4r592ZjGwlO88XngTIRQRFoQk4UvDnmI8FvAOhuyeKmhZPHHE0dv0X2wQ54YpIUYONRQcxOU/dhS3GQGD5sfSCfxsl7nxxbbgbU6ht5Feg009LpPA5otZghxbMGUyubnd7U4G4RlzPRZEJatiJr3nIOZBZdXq2hQ3rHf0NOe5iQP1hfENQEOCDefIxYn/GgFa/V0PUtmVYIIKe5L7VviKuXO0KpZJ+sZNDNtq2nYqfnTI23r60DNVTMhsPloeX42hUCpZyy2eD1GVCMujIAlgugS7xHep/CtIKB98azK5WEGZYfsllzgrogS9QKzeNYrLd9G7+7WRP+ZF7EipZV1Y6fDUXo4tbvE1pfWPzcxAR9KExi8jQOjU4sS9GwrsBr9Bl6jWlpX2Pb5HkqRyjai6f2n2uQcOp8yBXo1jNli/Ttpgiym0SQPkMmp7pZynfgP10KVtiM3jm45pI6hyd67EQ2M6Ga+T/JTtplR6Xg6n1ISvvq8lebXFPf/K4wsOSyPeofgmdtSGBTy1KNgHZRfOjt7uh7L3PggvylwMI1Uck1umkO/igHF6zaM1E68Y9tcXTBaRnL+oRPZI+jg0= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: db1e3949-61a7-49e9-8e1d-08dd2e15e5b3 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:34.0380 (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: 9npKSAxPEEY1iVawLugiOkcolh+G5X72AiaRIcBq7WacccyMpo0S9riAYdNLtvvcKzGA4PFqoEmOhOPTM33vuLri3Ef2u5Z6Jp5vDF3VJ+FJWCfWMYQKWeZHrJCRueuD X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 snd_soc_daifmt_parse_clock_provider_raw() might be called with NULL np. Return 0 in such case. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 710c278e4f36b..31cf499e3e79d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3390,6 +3390,9 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, char prop[128]; unsigned int bit, frame; + if (!np) + return 0; + if (!prefix) prefix = ""; From patchwork Mon Jan 6 05:49:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926972 Received: from OS0P286CU010.outbound.protection.outlook.com (mail-japanwestazon11011019.outbound.protection.outlook.com [40.107.74.19]) (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 351F417C for ; Mon, 6 Jan 2025 05:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.74.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142585; cv=fail; b=js7brTaJFe5DerXtFHSxDATQgwlQI/1PznkFDbToFuN+m+yevXaRUgz9mGz9iGzpEx0lHONDkOMSX8j7yEVkpNpclBF5E9wdasTimuZ6mc3d1iRan505MIcx8I+GGECxczdssZmBrT0I3q/eu8BC0AtbuKnmnMqc6dK3h9GL31I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142585; c=relaxed/simple; bh=LqXbG0+P+5VaOJpRuxpG4dLD6+l2bMZWieNfQ47XrG8=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=jhlvzJPvGy4sTC4UXgX+NlnX2FcRbXwMM9htvQX8o8Ncr3VtJ3uaYD7tHHif4CX6368+SQB8EIymYLbeuVpbQk2rXl1s75QhEk5FtL8to7GlBzz2UMo/lz257rN36wIWosa+Vamfv/YvOh9tre6RX3rc1bYx9ThqgEdXeJDhSxw= 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=NX81eG8C; arc=fail smtp.client-ip=40.107.74.19 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="NX81eG8C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cq+hSOHU73WSoJBbQBy9cr6Lxj3+Lb8j2EV0OrW1o9EYJe/qRTn1SsYcnqbwPXNRv9DWpmsIlUAKfJSbYmrkBL/yumtxUU/g229LoosTILH7hoSKFKmj+utHpiJLn9qL7z7ncxxTXnbHs+6KIp2oqYWdPwkbZk66QxQUPUsPA0Cq7RL9rCJWvzcOMCFgY6+OrsWVEEXCdCkDFf2ymGXKCUprdA6CUzLtGlwNoGpUQYYstG5d1w9xWCQnl2qs4WGADOGuX1jYQ0O9wy6Qxm79gIhlXvxGhF6RMDcKf72NZGHyjZWuWfA0SUZg9lNihg69dpzoo7Vi3WgHRo1sCP+ZHw== 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=o+qsAUtCDNvvznHto1UkM2CdECtHDK0kw06w+JhzIyI=; b=LV48PmMLsvBL4xIepE6Xce9HKBSy0rj0AN3E92T6XKeSVLup5JvIKVVc7EJ/q1JoHS09D6mVLYaY3iJROw771OJZ4As3xMpEHnAsUoEdeln0j87mVSsPAs0TA6jzmItmIzQL5R9kafhsbuKG561VxARxDndL13Ats41DniuCJ/4KlrXt+wWYsbigV+sz9p4V07xGXmFAhLNH2BwgR8SjQbwA+pt1J1C9BKIEi/jIaQV2mRrA4YzQb+EHWDvuoKgEEjji+fUojOlWFW8wRVa1rHUqzFE2EB0nCIKnXkp6XejdfJ8oorJ/OPvqgpQQfaS6HIqoMssVFguyZCeuHlXqOg== 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=o+qsAUtCDNvvznHto1UkM2CdECtHDK0kw06w+JhzIyI=; b=NX81eG8CYbJqaDSyqC2qSCZCk/O8HfTB6t5YKyIeQFZZLZ5CKus1hlaZoDpayYzwaUiDY201z1+vz6KJFQSLbK46pyIrfVbxWkGlvkZ9GX2jWNpUp++CgtMVDOGdyCPLnW0VnlliFcujJTE/KrUaNKRI/wsChjVjtJHSfNmtKHg= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:41 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:41 +0000 Message-ID: <87sepwo5jf.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 5/7] ASoC: audio-graph-card2: use of_graph_get_port_by_id() at graph_get_next_multi_ep() Date: Mon, 6 Jan 2025 05:49:41 +0000 X-ClientProxiedBy: TYAPR01CA0178.jpnprd01.prod.outlook.com (2603:1096:404:ba::22) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: a8053e46-3275-4818-11fb-08dd2e15ea0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: kjU2qTrc++0GQJ8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q07tV5YWs1xQuT4tW3Ji39Dw2AMiCkuEzHks6VFS1hBCYPoNa1JLRk7caQzIVF6ONB3zeivOn5fkFpMafW+zFkAhPRgDYVULRmHYSKw7rrokvI0QcEAJTFW+7Itn199ykAI6C23JfujWjj6KWpJs0zWvNFiBLOOcp/qI7naldrqqtxZGyg4Mrr56YDOsr1tpVf0QwKcczrQDnVoQDuN8hiNO40utJpd3mkkVUC/wD25GdBVXZRLu8Apr/wdisQ5Hp6uSg9roJ9k0O/WbNUWFAJkOroJNea/tjT8Jc4em28w5ZdtIyaCu/Ehrw1ADr/b50xBl4lluudo8B8TVnPwwpw7I1h9orjQJimUJ5OwXmAZElddqwKo3a58EN 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JcVqWSlXUBUjdBeDbLqocjJtnVY6SE025R0tnNDEbfbzRw86FKmI8FcN0BCq8u9WFnAOVG7kABEahg09kIH3GlHqDc2AwqajDdONzZOiGew3OHxspWcRNrxLRie3wX++Jnd5uwPaZtpWbbT91x+rY8joW6OVLM93xx1C6/qfTqw+WDfQU0U7QXiRMof9RMss9yW9upjY53sRVb6dT3cqez1D7oB1yNANTGf8l8W7qBtI728Q9I+lKViQMB7o7OKG/pXbDoPftZQrXUQ50S160ua81rbc1GAEvSlZXvFufv+r3aVx3q6i0xpcWN7yhVFAog1dS/ZAgtLnCq2UfYeuQr0g3Bii8mxLNxZnXqLck2W//nVpPvp6jo03/GXNgxzMZ2HrDBD8WoLuQibYaXop+BcRg5IPJ2VOpZ3oLzQyOzMb5ni0BmWR9QF58eFtx5Pwo3YdngvB4I8ZvB2Q9/p1ZutjO4ovcJD1va21FN8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uI3M5Om11TIKD5cS5qPfHIAS+CWj/Au2GZwYvHmfEQD5sVXqNCwz6GyLTq+jsj93RwjdLoAnyI= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8053e46-3275-4818-11fb-08dd2e15ea0c X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:41.3498 (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: F+RfznUlkc9H44yS2lYG22Z0VWn9Cr5mB4YhbwSSaBnyiBQpSKDeYDXUhObzk5grN4aIOV0A6N5y7dN11wDZtX4vymPcukyPGlHH3YM3usUOxiYT7Tv8UABADvA7VexX X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 Audio Graph Card2 is assuming "port" are necessarily in order, but there is no guarantee in case of overlay. Use of_graph_get_port_by_id() instead to handle it correctly. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index f4c825b56a7e1..4e330aae04894 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -331,7 +331,7 @@ static int graph_lnk_is_multi(struct device_node *lnk) return __graph_get_type(lnk) == GRAPH_MULTI; } -static struct device_node *graph_get_next_multi_ep(struct device_node **port) +static struct device_node *graph_get_next_multi_ep(struct device_node **port, int idx) { struct device_node *ports __free(device_node) = port_to_ports(*port); struct device_node *rep = NULL; @@ -351,7 +351,16 @@ static struct device_node *graph_get_next_multi_ep(struct device_node **port) * port@1 { rep1 }; * }; */ - *port = of_graph_get_next_port(ports, *port); + + /* + * Don't use of_graph_get_next_port() here + * + * In overlay case, "port" are not necessarily in order. So we need to use + * of_graph_get_port_by_id() instead + */ + of_node_put(*port); + + *port = of_graph_get_port_by_id(ports, idx); if (*port) { struct device_node *ep __free(device_node) = of_graph_get_next_port_endpoint(*port, NULL); @@ -614,7 +623,7 @@ static int graph_parse_node_multi(struct simple_util_priv *priv, * }; * }; */ - struct device_node *ep __free(device_node) = graph_get_next_multi_ep(&port); + struct device_node *ep __free(device_node) = graph_get_next_multi_ep(&port, idx + 1); if (!ep) break; @@ -729,7 +738,7 @@ static void graph_link_init(struct simple_util_priv *priv, of_node_get(port_cpu); if (graph_lnk_is_multi(port_cpu)) { - ep_cpu = graph_get_next_multi_ep(&port_cpu); + ep_cpu = graph_get_next_multi_ep(&port_cpu, 1); of_node_put(port_cpu); port_cpu = ep_to_port(ep_cpu); } else { @@ -739,7 +748,7 @@ static void graph_link_init(struct simple_util_priv *priv, of_node_get(port_codec); if (graph_lnk_is_multi(port_codec)) { - ep_codec = graph_get_next_multi_ep(&port_codec); + ep_codec = graph_get_next_multi_ep(&port_codec, 1); of_node_put(port_codec); port_codec = ep_to_port(ep_codec); } else { From patchwork Mon Jan 6 05:49:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926973 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010016.outbound.protection.outlook.com [52.101.229.16]) (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 1F00A17C for ; Mon, 6 Jan 2025 05:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142588; cv=fail; b=CkQ4iQ3oQBVeD1nA8TR122ws4erIiRGaxGNjjX+DpanqyK3JJw+uVICL0t96HdEJ61pI5Cxvt6JExKHF4S+EtZWMMrhOHpZ2eck6h7wfP/CGPYBUgvWIw3RDdyNuupJxLXfPnpJLfhE67BvSSZyfP/o5fD64z4Qq7FCY0NAXvDg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142588; c=relaxed/simple; bh=P3lBIYceFZvtGODMe5E2CFfedsXcVN8l9R42YlMN/GY=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=TR51hvKVabUopZtkMKzKOe6SymJutSVhuXa6q9Bokb2cUqRu4uUrbSyXeswpd9ExhxFNS+hl28aslcvkaOz/tc7+YGH/qoFgiWQpbOcbwLvXgZPKCaB5pGqxaFK+idD1zub8VqcCB6QcCZpmuGyziPvgBep497yAvYPJW3qAxjM= 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=BqCwGn9h; arc=fail smtp.client-ip=52.101.229.16 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="BqCwGn9h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bKEpwB1ZXX/dFpo2mNPK/eJVxqikk11TUnj2VCzHB5jlt3B8DgppN08Htzo8Ce5tPjtpPV+oFPpwn4r2dr2wWosJM2BjTELG3Sok3Oyclb5e3F4bMRfHK/8OWxr9kR0T+Dh0e6+V73wgTNiki4mbS0WfY1OzM6/ensJbPg43o00mMWBQdue7O0HMTAJWceouzIW3zGzHHXOIJ9S+tDzwkls+7kAOH9cfRoVhbGrtn1ukm4Pp8JowvFlw1VCimH2oOdSTPiYOXc/zvsVZSqRfrdBMPXvrwWfp2zeVjnV6CVThngLYHfZ0l14+wRnGjLY/AjDQMMtgXnMl9pPhIEsE9g== 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=ptxx4KlXPLr54EzR49exvE5r06t9J/AL/yfOPW20bxc=; b=d4oTSdLAsrIKh9gqCjSuDBTklpp39UTXWvXWfBAaGMA4SYU16hSTH7y3d5KvPjBMSyD8gpBiDfBo+KiE/BpuHaE9P9CawjVv2ufpKgLKGleMJ6ZVYfpB8L4gnthHT8fz7LTuf1Mqet+nLc+K0AIv7vPpSfNT6CxWGjAA4UKLyL78O/BQ8hic1KZyoIQPUcxN3r7c0dwBsPlOHjS5QjpniXbqPyniIxQeTsfHI81SYTlRRlMUqj0gLvbWL4ttGh62FwYcn3JaLDF4YvyOweJeDxQGRbyQ60LwjpE5XNATJiokdfp7FqTmCGuagi1VSOgnVRkAj75JV9cshbDLDDHtgg== 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=ptxx4KlXPLr54EzR49exvE5r06t9J/AL/yfOPW20bxc=; b=BqCwGn9hGuCzCWxzwy/bsvBdLxJJAnzbvj3+dadEGdK0yX6lZ/7rlFjAjoPU6zERlVI02e15+SH+ubFd6kiKFzNLflLkw10AtS1VY4sDrTwNOAO3IFpg4e481g8c2EQvK60aSIL207Y49S4JFQWXNgmWzmmrFq54jcmY79TC5pk= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:45 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:45 +0000 Message-ID: <87r05go5ja.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 6/7] ASoC: soc-core: Enable to use extra format on each DAI Date: Mon, 6 Jan 2025 05:49:45 +0000 X-ClientProxiedBy: TYCPR01CA0139.jpnprd01.prod.outlook.com (2603:1096:400:2b7::16) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 7da932a3-8675-484e-553d-08dd2e15ec79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350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9YaqXnazrKafXQPBFcBCqh4alCC4E7sFFwgJ/eyq98ssQnGWgJEVOS6h2WqA4QE6i4TmGPNE9w8hgTQrYGQY7WqLbko5cWdy/SXUI+/91kMqLkZikXPhJ9gCqDADFb+0Cu1KhMWs+paeles3ghXO3gZN1eVp5Xrz3JDZm9q5LF8/HNGGaDhpx18VA4Sr7J2UIa3HostwyJo4kXUK65BSK5arm4NaGS/Rg1MyBK5aw2nEzvrVTq77cxy0iOWCsBdnnH+T/j9Byuxv/oVfwBSKQQM2OcGtw982HF5iPzKiejVhZR1ki5io56x+9dkDULplC88C0i1aeJe6B79IwaI+sIRY0J8oFIzDOXaSdALiaaLiMkr1xZWck+CxJrEmtTynTlJAdF46fkxT6M/mKD 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)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Y4GjCJ7kbO5IK8COs7VAb0ZwwmLV7vxExxY0Vk31XyZSguXpjUXuDcLGTOibuKirkY7PIR+/BzztkyEbnQuXKHnMNETwXcgWWjJjYWnEx6Fo3pCx79rzh2Zq0sEZcig86rV/Cr4dmmqiI9r4qwCmjYHZLm1E29q4AG2xK0JJMZ7KgOuRY7MWlExalSIn8+QyZkJsUrv/7m2lGj4BN5rTC6Ksnqh/vaUHziL0m8QhbhproeSsxs9qfdTq1Jhg2Uy2Fun+H0w/EhE5LWONx7/S6lcpw0qGAIrqeVaZ9G3ift2A4rzEjJgLB6TNyFBJONHg8Nqv0LVNCdTVcaLxuckr5LQ8uQ+ygwJOkSvbFJQW0fOL2qHK9IQ5SHw5fzzg/oHQj1eaMgq6a7QLYadq/M4RkLI8fV/E+BOXyZcTzoxcuO0DFTzPMt5iq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87uZtQic9bUSjKW1hd4CxenMIYLb3sEtZ15L1PcW/m4Owoh9jiJIfUBIE/YDm+sGEErQ8xfFi4kZcpFzZx4B0ldYbPJQymdJu4nIALmLReoNlZk4uXqBdw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7da932a3-8675-484e-553d-08dd2e15ec79 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:45.3912 (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: cYzMPIuUGxBoqh7GHr94FtUNh2CvSi/vikLyGGaaSOoL1F/PNqxvw5dGN4an0ze6sfRoVuwipmCPKM/4cE3f5MvspDn4lRYxN9his6m+qxX6tOnjZ71FdWlIehxOVn58 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 Current ASoC is using dai_link->dai_fmt to set DAI format for both CPU/Codec. But because it is using same settings, and SND_SOC_DAIFMT_CLOCK_PROVIDER is flipped for CPU, we can't set both CPU/Codec as clock consumer, for example. To solve this issue, this patch enable to use extra format for each DAI which can keep compatibility with legacy system, 1. SND_SOC_DAIFMT_FORMAT_MASK 2. SND_SOC_DAIFMT_CLOCK 3. SND_SOC_DAIFMT_INV 4. SND_SOC_DAIFMT_CLOCK_PROVIDER Legacy dai_fmt includes 1, 2, 3, 4 New idea dai_fmt includes 1, 2, 3 ext_fmt includes 4 Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 11 +++++++++++ sound/soc/soc-core.c | 27 +++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 4f5d411e3823f..61eee40da12ad 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -681,6 +681,17 @@ struct snd_soc_dai_link_component { struct device_node *of_node; const char *dai_name; const struct of_phandle_args *dai_args; + + /* + * Extra format = SND_SOC_DAIFMT_Bx_Fx + * + * [Note] it is Bx_Fx base, not CBx_CFx + * + * It will be used with dai_link->dai_fmt + * see + * snd_soc_runtime_set_dai_fmt() + */ + unsigned int ext_fmt; }; /* diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 31cf499e3e79d..bd16b3fe59c8f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1449,23 +1449,46 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai *cpu_dai; struct snd_soc_dai *codec_dai; + unsigned int ext_fmt; unsigned int i; int ret; if (!dai_fmt) return 0; + /* + * dai_fmt has 4 types + * 1. SND_SOC_DAIFMT_FORMAT_MASK + * 2. SND_SOC_DAIFMT_CLOCK + * 3. SND_SOC_DAIFMT_INV + * 4. SND_SOC_DAIFMT_CLOCK_PROVIDER + * + * 4. CLOCK_PROVIDER is set from Codec perspective in dai_fmt. So it will be flipped + * when this function calls set_fmt() for CPU (CBx_CFx -> Bx_Cx). see below. + * This mean, we can't set CPU/Codec both are clock consumer for example. + * New idea handles 4. in each dai->ext_fmt. It can keep compatibility. + * + * Legacy + * dai_fmt includes 1, 2, 3, 4 + * + * New idea + * dai_fmt includes 1, 2, 3 + * ext_fmt includes 4 + */ for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + ext_fmt = rtd->dai_link->codecs[i].ext_fmt; + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt | ext_fmt); if (ret != 0 && ret != -ENOTSUPP) return ret; } /* Flip the polarity for the "CPU" end of link */ + /* Will effect only for 4. SND_SOC_DAIFMT_CLOCK_PROVIDER */ dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt); for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + ext_fmt = rtd->dai_link->cpus[i].ext_fmt; + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt | ext_fmt); if (ret != 0 && ret != -ENOTSUPP) return ret; } From patchwork Mon Jan 6 05:49:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926974 Received: from OS0P286CU010.outbound.protection.outlook.com (mail-japanwestazon11011036.outbound.protection.outlook.com [40.107.74.36]) (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 D8D0617C for ; Mon, 6 Jan 2025 05:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.74.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142593; cv=fail; b=OPLUM8Z81RN4DMSl0t4KLrbmq6M+yVcstvQXRJNQiYbdYX4knskft1d+oPbeaGVBHxaq9Df0MbAaN+X8qxpW4OkyFIEmi5XT5QDTkEPV0uMuvlSk79gwpNSlJ1MwUVbs65MHfD+t+MmoGK2JbX3h0ZStttGOTLCEU9PJ7s1/RsM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142593; c=relaxed/simple; bh=v7Gh0yu807l1qwUuwvWAPDaLySyF9L1zH4wn3YeQbf0=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=TYH6Bsfp9+igftXLoUtcpO3erLA+2RiZHW4/rnkn0hK1BtImA5eMh18zEu9/N7D6q9jhlmxqzMh0a0wpS7e6oUqUGLUNLiItJtwyH3EpL9Aaf5ytfhHdsc4KN7/LjiBBhE6MEjOTb5YQ4spme/rLBYhEqQeJZ07etImLLe+PVWw= 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=MJfMw6f9; arc=fail smtp.client-ip=40.107.74.36 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="MJfMw6f9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VG+yEEYOpNHt023M4iF9NcPhILugjlEUGBYCRJLfxArd8U2rVa+zLoUcWbU2Z44sZpeVgk5K66OAGripW965B0AbM48Mo85cc5RVckNA1uy6DS54ITgbAr/w+oEI9zj7KMUuAyqfsXFLodwWhm+Lk2LeuyRMhVYhZDzwsILujyC0Xozdz/3HsGO5hCMX5MnivxPEj7QeUFdf1FYEneds3h9msh0xw1+Lv4xk2SoeOyexVIrLhMsBLBYH6J0gfCNcq9i3AD5vLtB9J+CfRJoV19GmmjfJT5v1HZj0Qu96TUh2wLUMpOIeONi/snoOYVYFiBDiyoYq/Egv9f2apNXTTw== 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=ukbgokp6BcdP4zI0o7gxBu68uiQJal0gfmt/12CkmD4=; b=VbhnWxQ+CoT+Fvpn8TdFiHkg2YDpT8q2Gt9u2d4curbvsYmvQQuz0gGupAsb+YwaXcJL3kXwFdyWz9CTb/71cnKAK8TyQkGnVAn4U+Bk7gtGg2t6pD8YDHbiousiRl8wypQcrpBsn/0AkryfTyywcBwtNa0E6yag4h9OSf3WwnXm/4OO2lHUqSDXn9BhLJb5yaJ15PVmQ19ybaZ2W062hJxfD34omqEEvlfm+5qvMX8fYhBsXcqDz73ZK044C2v2P+u/T+VCmFIsiudFsNRKK+XZjoGOgLL8Ce3qrW3gCSUQ99TxKVo3CFaFYfeXRSE2qDiFVq026QNiZKR8iw6DXg== 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=ukbgokp6BcdP4zI0o7gxBu68uiQJal0gfmt/12CkmD4=; b=MJfMw6f9vHedmeRN+tM33Bb/Ar2a2UAgmJcvC9YUA2eLeEIbuTLG6lypkUsRcEXxOrPb+fJh3gjxqbQVZ8ShVMO3rDrIwYtsSVDYYkU6QpTrl9BM+edv6ZTL2qnkXPDT5jUvF/yxocH6RMUDzQiARjJu8b4Ejh12SSFrKJnaso0= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:50 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 05:49:50 +0000 Message-ID: <87pll0o5j6.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 7/7] ASoC: audio-graph-card2: Use extra format on each DAI Date: Mon, 6 Jan 2025 05:49:49 +0000 X-ClientProxiedBy: TYAPR01CA0053.jpnprd01.prod.outlook.com (2603:1096:404:2b::17) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 4205b672-163b-4416-8a5a-08dd2e15ef45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: CCreLxHhaR7u3ojCB3Rk80Gh07+hV/B2+POMvTzIwFfS7Z9ZS32aY6VF2C2KMf3V8EtA1pLp/x627US7zDGRn+SzpJEcFfdrXIo+Q+AkP8imlqqWn2DxyZn4QM8FtHtMrT1mc81A30mkPWl/IfpYe3i1djyRxNuOuYsr1cRfNHD8+h7cDXXCI1AiFP/jm0OuIIWL/S/5+T8e/7Nf0yEwnZ/+Njws0V4sf78GqFdPUrAboKzZV1Jd0KRbpJzWoCYuuu4y9ye6yezsDVs/NDsNdmMHIyXKACoQRmavodo8XZls1ebqLBT9e8fBSlalpWJK08GSExxx9VwBDW6D3D758VnZ7OBLQ8hmm9PUfXHRUAcAy4AaWVRm4eGSCLvtic8Q4Haamp/OxCAL4TWEnSMnIFSp85XbRuDq3gyDIk8xwfIBSrBThem25w8drghY4PpKliiGb9hJJVDXHTMM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pnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MH08JNO2JkeV0jsrZeTEdkcP0X4xah3kLPlBF4sqU4MTB9SicCBz8R4OflKmnPWfFtLRJkLmVawySzc8+Kjes99UwtFQMqKhSgP34rkVbEjgJCKy6HLDvLDBGA5AHQ10nKEPwwYMhoiMecQHfSyCT3wvxDWnJxSuIq6LNCd8eWegir4pl/h9cOSO7Omnhx9GqIQzGJUpi2eQdEtpr55szP6uDhTicfKIef7cfsm4yHAlxI15WYB7yn0MfOBaZEfCuFzTUo+CEriTtxpTk+8DEjt2yatQLGLyST0Zl4DFyzqZQEVpA8paGqgT7kdrfhbtfZnlH+UFgQBBYc5h+1FvXOEEl+bBdKIX4QT5gNOnGPkiHaP2RhOPqdlzpXR7nchRkf94A5t2iQMzRpme2VmQW6DQU2zjRxftVphF5k2a5ZpjbsOOuLKLdM2+4lRIMDvfGBKzTGOnyAGtCB8PZTpCRxemkaUqQ6d2TQbsxirKsHs7A8E/kxgwrNhxFmzUO/7xZouChbFDpzUlyocTEQVPCOaSMHBihWuULMngLM+Fh+Gcj/Fy264jzqfqa9GnFxhfN0D01lHSlWLSxDXkzddRci9WeAOpXjsJOqvbZVbBOr0Hh3u5DG2yy9Gn6wXaaJaHQlIM9+XgZDn3qH/0sZsGtkQ065PugNqY4UD3e5ONu24W642FRypPuSKwaVpWQf4LTVA7ao7dVUVQtErD9NYJeQm2Ci2TdHkTXYF9D+aDmrrD8+Oi3aqnK5L0I6czWudBLXOl1Kwgx3NBDLnwDLOl/ef45rg5OEcwQ1KOSWJL+H4YYMyIMv7StNTht/v3TEcW6Uo9wWt9M2fXTceHWPjKnGfsIRYs4TnhYVgJyFtkqYJQsPTwv+InLScuLtw6leH63D9Xw1iuBir+9vJlZU95wQLD6AS+Jh5w+riPqxUnKpbX8WehmvFJBqHEAVXq0d0Q3y6rXfJMTK3DPaoGVa9KM85/HvR5LMAs4b7l9MRiwb07w6VyxzWtTzUdEJH4wnOrJChAPxT11yacjsTFb6PPPSacrphqvWRrjnvEUT0fItdcYC+g87hwKmt/QGgbzZ4CbHPycd9TLkg7q/jaajlKjkPGBWp2UBglkTpaNryccBjUBX4xveofoKqBuyTdv3zRxX4nUov+R37+KfqDS5Ri5MQzlAsvSyxmdnEyhXmBuy9lfWrFz6fIAP67zpjjTqScCoLeI4rjXAh0b1tNyByGZCsFUPtQrySpG2wG6SG4N4Vp88AU7FBWtWx+qDHFXKcxaeuTT7jPlWmvmoNHGkoT3WUZ+LIN8WKQE30cMtdTIFoqKuKGTzZ1fFFNDL/emqkEdP6XOIVHZiZJB0YyohJgtw3k7w5cLHvV3Nj0gMoUJB5GopHChl9KHZih5Of6U/aNglmsot9ewVGR9yiO/6+kKAs6LBfRp6ObOMYL9pDMxBsNnBXmyP1uet+piCKgJ7M0j4kSk38hSPYEZKZHRwWzSj/QpagI9nS1F6SPHlyAGnHHETb3gd/o2c+oPsicqeE/5XOUGltxBtRCS6XtM0wHWyb2cTy0BXiU+siTUZrlWxM+IgIuodtRr4uPr9M9VkGOEZ6p2z7aRr45vsF7bL35SBIIJd4doYLm7p4A9G3doZU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4205b672-163b-4416-8a5a-08dd2e15ef45 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:50.0828 (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: oqi62K/a2CN0YKxOkOSC6neIHn97PWkKHy5+k3UTvrn1Qj3UrHR6Nqu+17BhHP8jWJOgO1QQR6cCAX1E898ak8RlSsSyOw1huGazJpntbxWFzhkhbXfHW9pIaSTGfwOk X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 Current ASoC is using dai_link->dai_fmt to set DAI format for both CPU/Codec. But because it is using same settings, and SND_SOC_DAIFMT_CLOCK_PROVIDER is flipped for CPU, we can't set both CPU/Codec as clock consumer, for example. To solve this issue, this patch uses extra format for each DAI which can keep compatibility with legacy system, 1. SND_SOC_DAIFMT_FORMAT_MASK 2. SND_SOC_DAIFMT_CLOCK 3. SND_SOC_DAIFMT_INV 4. SND_SOC_DAIFMT_CLOCK_PROVIDER Legacy dai_fmt includes 1, 2, 3, 4 New idea dai_fmt includes 1, 2, 3 ext_fmt includes 4 Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 76 ++++++++++++++++----------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 4e330aae04894..c36b1a2ac949e 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -667,8 +667,7 @@ static int graph_parse_node(struct simple_util_priv *priv, return graph_parse_node_single(priv, gtype, port, li, is_cpu); } -static void graph_parse_daifmt(struct device_node *node, - unsigned int *daifmt, unsigned int *bit_frame) +static void graph_parse_daifmt(struct device_node *node, unsigned int *daifmt) { unsigned int fmt; @@ -693,16 +692,6 @@ static void graph_parse_daifmt(struct device_node *node, * }; */ - /* - * clock_provider: - * - * It can be judged it is provider - * if (A) or (B) or (C) has bitclock-master / frame-master flag. - * - * use "or" - */ - *bit_frame |= snd_soc_daifmt_parse_clock_provider_as_bitmap(node, NULL); - #define update_daifmt(name) \ if (!(*daifmt & SND_SOC_DAIFMT_##name##_MASK) && \ (fmt & SND_SOC_DAIFMT_##name##_MASK)) \ @@ -720,6 +709,17 @@ static void graph_parse_daifmt(struct device_node *node, update_daifmt(INV); } +static unsigned int graph_parse_bitframe(struct device_node *ep) +{ + struct device_node *port __free(device_node) = ep_to_port(ep); + struct device_node *ports __free(device_node) = port_to_ports(port); + + return snd_soc_daifmt_clock_provider_from_bitmap( + snd_soc_daifmt_parse_clock_provider_as_bitmap(ep, NULL) | + snd_soc_daifmt_parse_clock_provider_as_bitmap(port, NULL) | + snd_soc_daifmt_parse_clock_provider_as_bitmap(ports, NULL)); +} + static void graph_link_init(struct simple_util_priv *priv, struct device_node *lnk, struct device_node *port_cpu, @@ -730,15 +730,19 @@ static void graph_link_init(struct simple_util_priv *priv, struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct device_node *ep_cpu, *ep_codec; - unsigned int daifmt = 0, daiclk = 0; + struct device_node *multi_cpu_port = NULL, *multi_codec_port = NULL; + struct snd_soc_dai_link_component *dlc; + unsigned int daifmt = 0; bool playback_only = 0, capture_only = 0; enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; - unsigned int bit_frame = 0; + int multi_cpu_port_idx = 1, multi_codec_port_idx = 1; + int i; of_node_get(port_cpu); if (graph_lnk_is_multi(port_cpu)) { - ep_cpu = graph_get_next_multi_ep(&port_cpu, 1); + multi_cpu_port = port_cpu; + ep_cpu = graph_get_next_multi_ep(&multi_cpu_port, multi_cpu_port_idx++); of_node_put(port_cpu); port_cpu = ep_to_port(ep_cpu); } else { @@ -748,7 +752,8 @@ static void graph_link_init(struct simple_util_priv *priv, of_node_get(port_codec); if (graph_lnk_is_multi(port_codec)) { - ep_codec = graph_get_next_multi_ep(&port_codec, 1); + multi_codec_port = port_codec; + ep_codec = graph_get_next_multi_ep(&multi_codec_port, multi_codec_port_idx++); of_node_put(port_codec); port_codec = ep_to_port(ep_codec); } else { @@ -756,13 +761,13 @@ static void graph_link_init(struct simple_util_priv *priv, } struct device_node *ports_codec __free(device_node) = port_to_ports(port_codec); - graph_parse_daifmt(ep_cpu, &daifmt, &bit_frame); - graph_parse_daifmt(ep_codec, &daifmt, &bit_frame); - graph_parse_daifmt(port_cpu, &daifmt, &bit_frame); - graph_parse_daifmt(port_codec, &daifmt, &bit_frame); - graph_parse_daifmt(ports_cpu, &daifmt, &bit_frame); - graph_parse_daifmt(ports_codec, &daifmt, &bit_frame); - graph_parse_daifmt(lnk, &daifmt, &bit_frame); + graph_parse_daifmt(ep_cpu, &daifmt); + graph_parse_daifmt(ep_codec, &daifmt); + graph_parse_daifmt(port_cpu, &daifmt); + graph_parse_daifmt(port_codec, &daifmt); + graph_parse_daifmt(ports_cpu, &daifmt); + graph_parse_daifmt(ports_codec, &daifmt); + graph_parse_daifmt(lnk, &daifmt); graph_util_parse_link_direction(lnk, &playback_only, &capture_only); graph_util_parse_link_direction(ports_cpu, &playback_only, &capture_only); @@ -788,14 +793,21 @@ static void graph_link_init(struct simple_util_priv *priv, graph_util_parse_trigger_order(priv, ep_cpu, &trigger_start, &trigger_stop); graph_util_parse_trigger_order(priv, ep_codec, &trigger_start, &trigger_stop); - /* - * convert bit_frame - * We need to flip clock_provider if it was CPU node, - * because it is Codec base. - */ - daiclk = snd_soc_daifmt_clock_provider_from_bitmap(bit_frame); - if (is_cpu_node) - daiclk = snd_soc_daifmt_clock_provider_flipped(daiclk); + for_each_link_cpus(dai_link, i, dlc) { + dlc->ext_fmt = graph_parse_bitframe(ep_cpu); + + if (multi_cpu_port) + ep_cpu = graph_get_next_multi_ep(&multi_cpu_port, multi_cpu_port_idx++); + } + + for_each_link_codecs(dai_link, i, dlc) { + dlc->ext_fmt = graph_parse_bitframe(ep_codec); + + if (multi_codec_port) + ep_codec = graph_get_next_multi_ep(&multi_codec_port, multi_codec_port_idx++); + } + + /*** Don't use port_cpu / port_codec after here ***/ dai_link->playback_only = playback_only; dai_link->capture_only = capture_only; @@ -803,7 +815,7 @@ static void graph_link_init(struct simple_util_priv *priv, dai_link->trigger_start = trigger_start; dai_link->trigger_stop = trigger_stop; - dai_link->dai_fmt = daifmt | daiclk; + dai_link->dai_fmt = daifmt; dai_link->init = simple_util_dai_init; dai_link->ops = &graph_ops; if (priv->ops)