From patchwork Thu Dec 19 00:35:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914307 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011042.outbound.protection.outlook.com [52.101.125.42]) (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 70039320F for ; Thu, 19 Dec 2024 00:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568510; cv=fail; b=XGvvDHyQo/OWWDzPkcP/rgT3aM574q6eANwjiRFHl2T4QJyh+TBwA3kw75dIi9MYGi1ZnYhqFEMQjpQRhfAS6pg33btvKielbD6EhnRx1cU2HGARdW5V7zyMTv4Vj8J12fi/kDL6HxFmMz3+swTJiUREZyXf/caIf2yMF3Kvoeo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568510; c=relaxed/simple; bh=QZps46uy4bae/jVj72rnoWFUeDi5wdPXkZlB1sAyApw=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=cNTabDp8XVYG/b+QcNi3yQiwEYl29pJhXWwZQo9CMrteUayVG8KWv3a955NnxAZ27zYav4U4ORlq2Db8NKqtM6DLd3XBSsJA0QsiMVUNuc6T+L15+nT1HzKLLy6qHjyorjpRbyGcGT9A/Xz4/89NFq+TDTDmboa5GwTRsPz7Iic= 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=mihIMxCQ; arc=fail smtp.client-ip=52.101.125.42 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="mihIMxCQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KHNqd/lNTCf0sUIkfajYxVzg96yzNUTjnjD0UPFtmM4XX/aSUNQVu2xSg4A+1So6gGd/oeDFNWZPV4Wy08aU0Df3U704IACEQROMFMXn/Hk3HyaS81bpcRiRA3yjeyBfKxnHKhAO8FhKhVu5WyAthwt6hW+gphTAsC7sMZVheLwZtKjyrNiP1t8e6Nnc0RBOJEHwzu/4uVaLqZxGmD0mHPzbh5M7gndKaonn79iOMB8RhQofm8+fixza1v6JkeNIVPe7nd6kQ8zBmHFEa7lHZ/uF7gNVho1HHTLECGp57fAqIiEJmGFoxzifh9vDcyQM2Fdgc9K6dfVjCp4dRNOfzg== 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=OOzBCRwA+BOsnfUmPzoUhXE0rL2n9yHBThokGYKcI64DeJDy/cYTcpsSMVmJ+pwbp/0TDOSiGw/LXaSNRjCYMNtDeRhofSc5XZpeVU3BoDopuqtaKUJDZoctnnVIh4U0RQ7zHELw8z5iAZPXcwETaxMjhdoFze7jeukZiyMpND5XdLLdxifdnavHt+1GqzBiZefyUW0W3RuRa6AbAjl5vdDddMnT2wl1RD3KSmS60j7bYytNBQZNSBHaxHY6J6CxbrGQHtAd5VmQvE08Ou84nEiXnw8KszXwacmvUfCRViDvwjISLUzPfxdV7sMM7uSaKZbFwOKhZmN0qIUfAC1nQw== 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=mihIMxCQ1aepfjYgp25PGLZ64d2FSORd8c8IPmuuZp1k3+kXERaQiPNbUmObgM3ZjiVT6qVUN55+OlrMFBl0cU7DtpCWHshDT8z+WsIad5eRSmzUPDlyMVRpDjfUT+UZbKjRP/gcz37oeVc7E16w+vmjp8eJRDSW9JB4Qz8G/Rc= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35:05 +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.8272.005; Thu, 19 Dec 2024 00:35:05 +0000 Message-ID: <87pllocxxi.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 1/6] ASoC: audio-graph-card2: use __free(device_node) for device node Date: Thu, 19 Dec 2024 00:35:05 +0000 X-ClientProxiedBy: TYWPR01CA0037.jpnprd01.prod.outlook.com (2603:1096:400:17f::6) 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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b6196e5-f658-4eac-5930-08dd1fc4fbbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: VCyX1EFEAfaFEUgHVgqjoCOKoPNCVGnRGl/YXzklspTN89SYrN2KtCvhTRJQiqXYaB+842h1dbkMeQg0Ke0MqvLVcSWH/kilaAJDfMrW3bIhKzHTDXyWLk0fUReLZ1kFTEsVI2XJFzr0176xUfHMBpallCkQdS1R0YClAWHU+eP+pe6pwBB12ClTOSJ++wTcoJu4+mNb5jOmYUkyfYmruREt39ph2AGtm+KY7Q0zCtTYGwCSB/8sW/W4TsTmcq8I6c+PeYx5Fz+744LOWfxxTnBDmlBMmkZg8Os6820l7AKTntmjb1wAXF2APK1UB/u4k2ZeQNFT/aRtDL8QhVQy/aOSk98L8WTCeTDFfMdRz8Qlc8PqKPFjjqVj4EFxHeBqHEaf1ylz/Ked1/wZX5+UbsJQZG7nFl96XFioCMsItPeBSvXrhlUbc+drFEo3YdVKCwAoDfug8C4MRa40ns59DFO7cLOEuwkLmn0zdqs0GVeUQ9UNPaxLfwZ+j24GHKB6Jil0Cc6MKlOkXQ9UAlC6UwqD8Mane2vFISTY1N3JdEnTxRxud6b/zM+eh4eVq0CursUmRlBr75EAsngRqYtiFp9F4m9aqjuApMt9FvigpQN0tXqbI0SOToZHYz/a77KNTq9Kl6pgB11p7lIv5ZK57G//cbFU4QNZtk6mpK6f8z7zosAAPXbv58h01D8esi8c2i8ECr6ECbiCDBvsmmQ8Uy0/cvaloxWEUXJ/sjNPU9tHDNmekNd/346TD2UfsSabETvvLa5wYWLIOAndSwGAnY5c5gzmLlF8EPB8XVEyLCi0FX/wz+w3rbl5nWsERouoYUb74adm9XnPZUylEW6RHCe3+iN0+1Rv/0RTT9dp1OrGDwUGi0CCzB2Ito5HcAStRkdamhqF8dwQDPKVp54Fuxp/Bxv8gid8loCutWPe4LUgjDWKp/UTdansjEjKULDlJLFbCc1T6RvNHaK2UNeZEIb3VB45Hue6+jtHBtufI538Hp4/pep7N+m3DWweWi8gMjlP8OwXbzWxKtPW2c81SX4vvNDMk4qP/VgWTNu2e2v8tuAvU94Dxd1iRcmyBi5jZJYGKiHk1neR4k7l/KRvQ0+JmyEWaIpUYZANB+BkkKFwsSLZNuAnaljT+33UM+c9zM02MwHWfk4aJRM0nN2x9u0BcNXF8Mn0mkQHFqS6QTqhpIv/64gjfvA4/xDGZbPi1n8sNu4kzEUsaiYe5A0IGkY2OA2k0BrkrpdpqsXyZHhN56LtZvGqq/qoNF3gbZDhio28LWKb5wXH3dLVK3gqxs816hsHrBjP1j3o3iICuu7ba76NbjJdfBWHIAcgg6A+p4uLtW8daeMfxd86giOI3r24efxvLDEqSz1dHlbcm114cVtTA3aaXWKJUBV6r7eJDYjxkMFYObHpXYNPI9IXdWhb/msxfvCqEG0dcfZCnm8wA3WwPh5AE+wQ3FoY6nd4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +5Lkg5Riw9JxAs52zWrbFbDEhtjIllpVJhzOGvxkyQ02+qI8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JmuoJYZH7azTH0pUzXOIjnP3hChYv5ZcJetCx+pDVtdFDOKy+sCcerXVx51YggfXgNWvVlcQ+0VcAKdcqu5OmD3aStXF7z4BriMNxNzaZqSfM809jkVfosZ6SX70eUBv63ObxOSsqc4MoMMYLAtfdvKaWRKTPzMEXtafnsnM4ThTTQ7BUyIPURJPwqGxrlA6MXu4tsUiub4RfAnpLIfuwJIYhRGbKipOR/9+ejEzf7geSzP/A+T9UJd+udwuNKEWFs4an0FNdyAkh3n5aOxKYna9UaRBpWrFZDCdd8zdYs5eXUZrGq1I2WqfgKItC2vtmPmhjz4lBtuOakRPQh6KPWaHLTFj82v2TtKG8bj8Mu05G9uUEJW5KNi6i2lkKZ36lfS0PBObolf1rGvbGy3yoo01Tm7oVOtJUtYB7Mnr3gnMGlr5SejZJrabeslg/i5CRhxmZbiHk3yemXxXWUD3r0XSNxBzZI7jr6Xt3ob/FFWbV/jlmuZ2I= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b6196e5-f658-4eac-5930-08dd1fc4fbbb X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:05.4885 (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: Z1ancrwVfaPvEE538eMAtp3UtAfqZ2J/htVC0CkrZ/1Xw/P4mnrnR5JZJTPmlhU3xA5hvMnbsn7LhAaMn2k2N1p3VE1RuC8D+mtWHot8qJuAHNPEzxb5clwLNyL21477 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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 Thu Dec 19 00:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914308 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010059.outbound.protection.outlook.com [52.101.228.59]) (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 E9C07320F for ; Thu, 19 Dec 2024 00:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568523; cv=fail; b=exA0VZKxWaNIYPP+PNMKvMkIcM1DQnAhqzMgc1M5fPmzzeJ9OU9lLvuczPLoZsaPXyO8wvaua0argbPSj+9QTOChspzwrALav1yWxBT+1Z+YY5xQu6kXCoqlNzCWio/vpfzV1PFB69PJCaQ1IeADt3eqdrtsZMcmaNwLvD2McrU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568523; c=relaxed/simple; bh=tGcFxxdLtL9v/FocUqoOF+0WgyRgMs3IoGhbzcBshD4=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=qQIETqBB67CWqUhUDPakznicCQYdMIQHx2k9eDsLyl+rneXmJiEHOCyju1IX7Zr+IRJINaTNUOJhsM1x4vDNwm4WchaBOS5LNteH/9WfIak5ChTyT/f9lo0gzCYk3WIEV+96YmndypYtleAvX9vouEZAgKs6Een3QUyz8vcWpGY= 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=TbiFuoi0; arc=fail smtp.client-ip=52.101.228.59 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="TbiFuoi0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UL7vKhd/E+534fjky2yOmgiypT4sw3cJiXzWKFzzxXWYO7RthTjDKNMt/BzEyAp7qs57xeBVCpintyzknHkYOos31qDaFtHmOEXv/xBKPsWA0g23v4+poZVv8xjwE2n8rljvhSUZK5YDr0ZpBFevGGnHOoHAtDh+5nPnZhHBUQ9RKTL4W3s8BLIYekqaqyldsHNWmShinzNxWp+2rJIv5dRimgtTuBCmv7hkM38FDhldks8IlbhAhmVTjFwjKs8+7NZZEN+ese9zRwEk698pHvL60wMChk7glyz8fwjBM/7HlCU1nfzeozIAk6zDc94BJ3siNLeBUY/iIfm5fAkmMQ== 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=WdMvEKBp8ZYoATK96D5Qb1E/7T/TmMO4A8YTB7dM0T8/JQNsJ2hLJlZ4bdSHWldr/sE0z67fFM6vwaCsU6SsrD5yH4+lWR3SEEQznB/3f6ZuPR2N+O4tC5rzMPmpl6vBCqn1bWw3NLzQ07HDmI7oDQjN0+3bF0zDCsMPii4yd1F1vU2iw+Hti1XNpLEWY6wo/CUeshVuizd1AnEnnl/eeuUYu+s/7PkqQ2GNqEm5b1WR/Ttl9TZR3e8P7NA4Cpn4GeN/sm5gsgvOC3znHdA9D/+Aeo8BvJmp+U9L/4iZnHaHLJ6lVz6yhyNtyQe7OxZjXd7pFmEH41YL7ylc+IcbRA== 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=TbiFuoi0KB11MeHXD5D3mAEfg5pu+upXfi9ztUBGkOW+kB8UwzjIUIxElwoIVBIbltUdmX/dDyONaiaP6v9wf9i168MEzStcYQcknKDLVVuTwJMovpE/CwjBaSp6IKs3mNNeQ+66LwMREuEG9XmNrchimXgKTt1qYHMCCxhff4A= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35: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.8272.005; Thu, 19 Dec 2024 00:35:19 +0000 Message-ID: <87o718cxx5.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 2/6] ASoC: audio-graph-card: use __free(device_node) for device node Date: Thu, 19 Dec 2024 00:35:18 +0000 X-ClientProxiedBy: TYCP286CA0359.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:7c::13) 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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 57fa8661-1901-45a7-e3da-08dd1fc503c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: nVhsJZDNm3fZfEUlh3IqMDyGj3XXkydARSHoIY8NMDf8mAwEwpHIYDfs3AJQzRxWSgfBIgsy954GgTMOEf7DUWyhq0G47E1bNkoCUFgVPHWWwhNgPc2/StctciqXWwupuepSwoybQIuxBvh44M/6I866OazdRRuSOIFEwesms8cXAt/eUC+pd4E2VcjeR5q2hI8NQxInY0mXM+NfdEaHmmMXxO4MfoNLYWJSYOrP7UrHx2P0JUOYnk5i8TJ3qgLPB0QELMsSTzomxb2OMbi4oWR4IIm+4a8fkrDeXn35+uOi6Tn87+5oWLk2NfDkDw/yDovrEyMC9ptdKVSARNHNGC1hkvsvpP4ddpwyJWxusOnZVkvgoyzvTHz1fcTIdtPnUlfFYRVnyaCIIEgKCkpji21S6cnzjdPXiu9eW10/nOguKJjvAWO5IXDn12f+JFm+vkyVScc2ydW6q7v9WlgaliCFWWqK4WHzgJIZsYCmqhyS/8KjNOix35B8AuhEF5sEsOW5BMvlaiPsYj4sgwkCdbVCvt3PnOcsi+WTYJ3Bk9e+0kfg0F28VQ21Q32G089b1rv0l2C1R5g1JUHucsKA1tgN9IBvP1DFXUvnZkzMEVcsD8ayqBfGJ5DU39Y/PyYwEMg3vxNpeRXe9mkBl+ndTiTf1+bOvI8eyIvTbB6CZqNtK7sm5V19FxDWCb6gP+r/n5wI3i++zpfp/0PqB8eThUa6ApYsUiDlATA1V37g/7o45W68kz9zMhm8wGpyvZfSkmk0CA1gHMFzOGfWy8gUi8qgGUKGAYnCN13y60lSDLFCjS6QYoP54TyU1ubNB7Q3Tfi+CN13S1ScAdqHHaBKriL2WnUp6dgrnfa1d+3PmttdvFjDbr/xDVRqHB6aT+mf5B7jBlke0qo7KHqPrkvvVUmcjcHeZaGNaWv7UT2W4Eqd4qRzgbSxE8Q/6HQSn9jgMm+rwtCSEaaLLTrB6muuYynOgY6ORr3ug8V/B+ty9ljxGtGatD373Pa5ZJ3TKdn7Gt4lgPBeHl2Q7SFa1HsvITsVFHYueiJzZWNr3IIETkCbN3aFKXsf87Sa3NnvJsApP3JjUXliDT7Z+/9IkzgzLgqZYvKYoA3sQNPNDYW6Jrrptjf0PHYBf5GBTrEjjVr5GHzbFNaFwu4uETwRcJIHV18EMmDzULz5i6TcREwqC2o4Xd8lB88Hb4ibcyKGP6xIpYJCA2kJh864Pv3llGoXZV9mzjT3YalYUS63W7Q0+I0ZTGfAhapS+aLDFdez1ToaJRNI1gE61SYq2y3iH2bB2Ltt87VxJ3x5iMmaCb0IgnLdYyNcXJnEcoBUS0V7p19WccV3/GRAnfY8XPRb4CKUSC7S0PmnjOGEJP18jhJKrEYh6t6G6w76jS+4oruLg5cSypzTjynEVbIGXYQpFLJ+vLBVNOfUYAnEtDjaui61YvmKy7GavnLloE4g2xtK8cVZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HoUwaK9hgvsgxuzR0XocaSA71DQl2cuI7qNyn2GVwLkb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ePO4Mt/Y9DHip5bF1On77MtWzJASbnne9LFxY89heJTLDLgRfoolrvqjw0LizVQigWwkPR638AH8lIqicNG0U6QmRk4FIh4Boe1y1AxZS1SVePtvQ7JYdQw0jImu9hWr4LwtXxBNqK+Oe+MPvRtmH4DcOI+92DjldsADomnGEpNrVPPw4J1kDqIG2hQzCeT6vhdNZhftbLvLC/ibSfv8iZ0dbv2owOgYhHgldbLySMbMbb/SM2in6X9Pp/eowP1TC5eUVwyN7QOLMESW6k/1ON7v49N3xv+XmYmB1G1cFZu0fr2cDHw/3swsWzh5dJmE08XcfJSybjaJuIvCIRqENiKjEkhFpU8UNqeVHbID9Ng15fx+KLgQo+eRQnwn7dnDYd6PB6fvXeYoK9BxIzTPoOdoJylqkrkvUS6fQ8/dfBn9vlKvD3x3He9rnKNOH99rLlY54GRRlqcGAWG9ldBcVma2VQSJBTdPKWQJ5nATxFFsaCr1Du4jW4Ckr3UGcof9sY= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57fa8661-1901-45a7-e3da-08dd1fc503c2 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:18.9445 (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: eH6EFKnRPkWhbxbcOOUL+yzPPTBtChr0KObGM8QLQ85mNGaAmeCWMVy9+1l/BSQ8xFV9d7xs5vyQa+fUOlZyC0hPHr/UBWHl/9hwzimEhknw1kzyZ+yjvsIbVFE8UUPZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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 Thu Dec 19 00:35:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914309 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010023.outbound.protection.outlook.com [52.101.228.23]) (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 80B9F7494 for ; Thu, 19 Dec 2024 00:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568532; cv=fail; b=nCKt7OALKyiCP7kORh06npcnauXBc42U+mwWAbJmzD72HMSEzlgNBg2UKHcED6sEnQXL4vSgRgVp8gKNEPO5oajxu3dmtIRi0EMoQqi4jD9uhPMbbAES19m5JkD28uaqashlKdaFQbzRqOEbGqExoez9V9sdTyNiMGG39MJe/ow= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568532; c=relaxed/simple; bh=dFfg5Ae/MoPJH2Ejeb8Iihqmn9ztw02wCYKV3a6BO08=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=I55rUW35a2O2o21szXrYOyDeYSXmX4gfRg9FVMvmr9ZWIIxV30S18Umw9Vv6sGC67NOSguqK/z1CfJNRFYZopHvks+ReFEL37eNdCJOr9zrlEIl+oX6YaJOmXLj4nWLoGw/PZIWh/GeBRQt1KCMk81NJN5+nFbT9/nsTApRWyfU= 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=UNkApAdD; arc=fail smtp.client-ip=52.101.228.23 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="UNkApAdD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H9wWn3Q0TrZIJ0VKbpDHlS9MFWmE4xdR+6Rvcv6BOttieEswGd5s4cbgW+hLUifC9mDrj9hbKoas+7At+7zSSF8s95iRAs1MiKbUd9r/iOA98FcqshjNUD1R9WWzlAm0n0eEPAj4k0inHRN6vZ3Rx6P/MwWnI6rsBZAii8pWF8Xbm5QMjXfMUoWd9Eibx/yVmaVFL0zRoEE622x0oKyuaAraTfD5tNlXa9Zka8RQhg1NMRtG92g8Ej5qRfyijuf7IC6+ABUAVCoJJEi0GxpU8Fs3zwLvaem12UG44u1lAVKCtFqLCyHUeU5/7l5HE/nm3zrKeGu7SYAkrx19guGk+w== 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=lMyYbOy2vifPwo8uiJlS4kAsBewafwUg8VM9qg8i8glyLJsg36gcbUZgQdcFaZkXhZSpDnQcqPQPaSI72M4vcasj3e4Dk+dWP4s+6yTsUjQadeCI8bVF4xx31z2ktR2oiuS+s9VSKiVIdoFOOtcQOWuTWdSx0546QZ8KosH0YximVUqKoDN2cy78TRdjqhvREyUgupCCXOAJI/KIRwLSAE0nKIet5oK+pb94rXlk0F5s0tIAVurzHScXpoZ5gLLGhH2qj4EfihMnZzo0lX9GlWQpOvD9R8YvTo7/sS9ZRtEwxQl5RsUSaghojLoT3PPO0kNA3bLlh3CLaTlg6ZDhhw== 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=UNkApAdDCwQl0saMygztRPgdF7L9XJGL6aNtmu9xUEWkSVVrE3hApm2vFUpkib5gzjU85OyjUnWN7G1SFLurqjq37GLFkb7P6nPH49VBM+1KmFqZUaMA9HVUHbepa4B0wbQuCqKY7w5R1glVTu/9cq57dMyJFKsaNsNbEmpM2Ac= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35: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.8272.005; Thu, 19 Dec 2024 00:35:28 +0000 Message-ID: <87msgscxwv.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 3/6] ASoC: simple-card: use __free(device_node) for device node Date: Thu, 19 Dec 2024 00:35:28 +0000 X-ClientProxiedBy: TYAPR01CA0238.jpnprd01.prod.outlook.com (2603:1096:404:11e::34) 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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 21d4b129-2811-4148-6508-08dd1fc50981 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: +LG0SuGNHxLKEQpvq0ixf78JWaYZL5Sm1niHupwZ4u5sxMUm85dguXE9LdXYRru8bnMJTysYHe/ogQg+0I9rCt7G9wgs58cvKui7mgy5X/eOjAozrhIIh1fQJ6PtveidDQha7+FYjGij7BXQVJHSwP9JwDgVhHmhLray/jl4ZFF/nRaritZwvEXtU/gGyzJMFRcLrU910qEV3O+4MGMoeKB5zfy2jlj3fXO8utP4fUBQNNxC8uZEXn2vavRitBXqOcn5VcKq2QjlzCHYOmLes0RI8hX8fShzUTfQZoaFkCj4dFuhlpgzrk9fMl0ii2pINcvZYWUqFF8V5fn5I77PX7Fl5ynXh9BDEIDcBs6M9o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e/SJTGD0rgnzX8q79Dbv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a4qA4PHHEIAiVul5abyqzVYpfqxwBGUeSlSepiazc7u/UG8lyS3NDnqigpsv7nYpTephaaTBABo6RBe5vn+Nk0/IlSnB7MiSFcCfWvHS5Au6arPJR5OMbjiwlMQH+UAyL1coj2iXhp6vEXTdeB78bb0xPz9BD/bhemAk0Uw9+n0hVW/s/a1nyGBVobMeMyJQQsPG4tB8ubv7UOM7BEkOTXiMnuEuF0+0iEzupQduvaeRX3MhAcph6tR69xPMHZLc1fi+AzkxLeogc4Cr04A9OuFhoP9Fpv+LvY/ofMtMYsLEiBtebfPN/wKoQH0OyWOwSRJB0yHc17EWnx6cXblIHgxL0GBNQDBj3QYUvUE7YDSa+Hd+YLUEthW3EtsaYs3+jmwoYXXsxeQYr9yINLb3ZA3TTrXo7+FjtWpKR7SvLAuJv+jv77Kg3xw0sGmLMYc1lwG81/jWn2RUXDbJEiIPkN37gekCwQ71PkrAI87mVmhViLi8JHdyrBRDBg2xhIvFNRu1+yq5kQkS9YPHlIx1RiAGR/0o9ZbWRbzTYgYguD18guPhVsWd0G6XW2Pta8ngosgnOZOZgLuCzWR0FrT1QFyW1I219Z5pGOvjLWRGuX1IjkkzH0+J+ohjatu3x8j1/iJCc13TpSf6SUCqpizY+70IIClIRtl95R+GoH0xMNPa00k2OEsdXKKRCN4D5O/xh4SD5BxbheV6+hqPe6/NPfMXqPnG6Uc92gIKxZ0yuz+L5sIAqM3nQHl06ALLnRqJ6UD0w5JQiP/K9uThSJEm3Da6JtQH2oosYNv/wfn1T/G+aTdgHUtaZy8auBkdE5mo2W7vqbVdZjQteTKCfiAfX8F9NpYJItbALemb7ZZCrmF2q6kNuFD3nEqc76hpBm+GlgPlMhzLUN4/CUVJUkjjscU91to8TBaEFH84ndD24apLToLhoE8Z/+quS0N3QF3J02hxsE+GqcgjWEf3JQkN8vwAbqnLXtoXHMzw/ml2WO/baIBVyhw94nuezt2XQaxlWxWHIohs7DNYlluMEgZpeY6S7e9pjcYFOEf57R7rvHo1F3YS0IQJgw8mjVlye+hlp5H5/Rsxd4YvGQW23avZwfqw5Ar7GKRwvu12ubk7HNTZHdQzk+usXf2yHGxOQp3okeX6tYY0oO8Duzbn3iBS5tYCrLxSH8fAFWlXjC24SVvcmOIQlezVXWWden+VITciSDCMO2/EfgxKr6InH+CIsLbIm9t4hM8X5kTR6Bu8nQhoz+qzCfOarnEzzoUXvLos1OLk8fW87XyL+9Zx4PNvlwgaO+3waiFDUmo6udI93celCJOVssoFPX8trZWwcRZxLmpvZy+4JujPttw2JVHI5Dcxizqa0jJccM3Gyc/CQtmisbxK1zvqoVZx/CXZtve5H5F1UMwdLGwTMp5SUxZ81gST4gmWuDr/ZuofqDgOhGuFxNOVezcJX4Z7jwTO3/JgnZhMlWS5+YLZOMtF3ErdPILKnMsUzz4Q+YDq6gGvb+IjCeSSEyF6h5dHplQuzYLV+mLsAQae8ZWGzP8Xuv96phssB8YRkCR8o/ejEpiiHr/LdYxGZfTHLwGg65ctSBI6l1RjH5AGdTN7nRxY1vKZxIeGsrMKObmfhPuW63UClqQ= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21d4b129-2811-4148-6508-08dd1fc50981 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:28.5864 (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: EEqegav/1Zdh2M8FxsyFEBmZwdIaM51id4hh/SmphbWcUihzNvTUYLurUO3/hahLnRJmvP9nEwics4TUKW7hONMVpZrl6gofZ6kUbbsFVYFep4rB3seOwx0UlF0n7V5B X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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 Thu Dec 19 00:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914310 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011002.outbound.protection.outlook.com [52.101.125.2]) (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 D193E33DB for ; Thu, 19 Dec 2024 00:35:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568536; cv=fail; b=KdTLlJwjnP3jbiWKv3NdYEBYeYZn3eA7Ik/doIbVDNoaOOZ0WUrjM/si7vErj52YRZJLZLLNp9D2k73reezjaGrtzcU/QxOF0/BGn0CXGBWuWP8kmgTRmLnrtR03uhhnKUjIgUs3I0pDtH6twd1wrSuCZS3fsts49fvoaUj1On8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568536; c=relaxed/simple; bh=LBn6g11xJEn5O8cjRKTJLdVA7WnEkS8ZBTd2AqBQgLs=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=RbsHky4hxqTRa1nkq7NJ9LmIqNzBSUT2drtZEqOV6xiR5TjJgwvD5DXxbdhU03Y0Ff5mj7W23VrMkHjgSYO4iihLMmdAUzIofp/eTdwsc2eDcchq+RonjSYoRvVXdrbA+dv33f5L9jPP751Wp5Q3rYaeZEmhH2Qpl24drZ+E+L8= 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=RaY8Mi9n; arc=fail smtp.client-ip=52.101.125.2 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="RaY8Mi9n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KmdySXPtAbT++C1N67IG77ela3KtN1xt4tSzJmNs1/35b9uHFno0M0xtpV1xyGVjI4J9XkWuhNTaKpVJTTV4B9a9GA6qMSnePQ0+QwKqInf3dpKl8jqluakwKpNJ3Jce5X3+DysiJOdQBCVBNYsHRBEzeMY5BCsve+RbzqPQoW7zHs7H1LExPvR/0eVvYRP0JM1EVPqTLmtAZ/mw3fXr1OTegPh7XEBBywmJymrV96HupokCqzdk+Q0+3sINrx0uJtdAG4cOsSLCLsF+nrAIUJlEHMpOrSiW4le7NPzJYqsxeNq3YG4PqTdUYXXD09VUfIkHFp4CA2/CE9sHXbkaiA== 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=Le+I+SaB91spDoxFI1r+mKeuYG7lW7Hzh3V33cdLc2O8L02oThrRxncbNP7DihMtO8QxlArknLMC43HtD61LmBX7ECQZpnScFmgU5VIxnQwl/y68lNWs4N9iweshKtABgm4lTZPmbhT0+Ya7c2muvBGisVLmCRcQABqM6GUfoeHm/q/Zs0E6MWb+7Av2XhcVGPhh+5zTS7MOFufzw5ImCwWUEbVxRBPinqly8FD/ve1X4yhcVpBXrh4PH8ukoWGTUQlXqegVTjKiU3eFiUBB0gp98GoFQohaNeyUHD1uecjMJE1T7+swer3iRmCUPcqqwpBfDsHiIOJXDFU5cDOSzg== 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=RaY8Mi9npQZFkya1Lq78EI7TyC8JNVJSwUJhujo0vzbsZoR7izrY1S2MSbHs00lkweBrksqBpflvBHa8q2iybahHk1tgBJX5wVJkNXXmHJfoFQrkzF/RyX36tIudPwJhsdf1yAQ3H9iOI7/9monhG0GAWr3MmHqdrCB9qsKQONs= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35:33 +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.8272.005; Thu, 19 Dec 2024 00:35:33 +0000 Message-ID: <87ldwccxwr.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 4/6] ASoC: soc-core: return 0 if np was NULL on snd_soc_daifmt_parse_clock_provider_raw() Date: Thu, 19 Dec 2024 00:35:33 +0000 X-ClientProxiedBy: TYCP301CA0030.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:381::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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 89c7bc75-7e43-4754-ba1c-08dd1fc50c4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: 1MLUBEbgxH43h0Rw8y3WbxBjwBowERklYwwaDiwzqOgL66nOZsojmHQitP3D1Pw8F/rgrsQ0nxxQF69swquvsc6F7i8awjXNrP+0144rZKv5eOcN1Z4qrQm4DcNK4ikijGtDK5pS7QQKBtu2vHvoeW46KONTxFT4Tj+jxk7V1G8EIZ3T4+8Up18N5bxmwGDoBXyxJhZSwuOIE47hWuT2+qewNXZ72NNA7ryvSLY4WtU8Ohy7j1ctCZOQqwljApYvuDESsPal4DbrT3o1eBJBUdchcyqIAWVWF+pc2cQqsH6Jbku8ukeQDb0AGVAH7ba3VrAVK8pSJLq52jSRij755t/IrSXMZTI9yK6qXj94b1p+L+bRGE3MHIM3VRspBAcNnjB29bFJNOsPW5dKhFxUkqrWCXUfPbRs1QWw5u8SeOAteg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CL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sHMz3yhKfL1W2FPD/WaWi1MFBQIYQxD9KB6ZqqmNLgyOYCk/CIBeL0em+t3zL5uZo7YrBlTmrTsik159rUWu6J8TLWW5rKIwI8SpmDNKqUbOA/3lHl6/+N6OxTTsUZUa6rkut9urao4sLtR1E4d2T4339AWNJHqftnm7j9ITVPf32F2e9PgwoCrWGtgrOFGrNqTPhQrdIxohTgrtSQUI9lQzYbjzjTVRBVE8mt8hG5J28olzSVX0Gn7iBZQGjGK6tEnx9NP/Ew15Vxe3HLkqvFJWhyXxSYAWa9bE6hVhffd3SKSAaVG0eQ74cQLaiFVpykieczd5mEzUujglklk7UNjZCHA4a8mrYZlzG5l+EYmuppKDcKI0XozpLg9KlXdCpq/HhbTsUcyEZxi0PU4t7r1MLGyycA/GGPGGsx9svE9Tqor4RBkuD2uQH65g6rS2lF0tuuBPg9mgim3eLHaGhT4YOlOkjAlwXekAtEUQpDR16c8P30KsMAEP9/N7iP9wuR1kCo6b40iaLy064jBbQ/Yvw/w8hRJoB0imzi5RTW04Sv+H8y4Q1tIeiMY7PsUbu/dJkd+H9j0kAa4/bUzMOKQZQnklvM4+odfVZ65EoiEkZWFhd1GWmtUbwdHsC1PFfS9RFWWvOtUtT09d2nA9jdSHM1vDMVpYYH+InEHR4zr5dOxcTbBBqL9QmIcGvSc5Ms8RX4YLvXpI1E/9xnYhfHMZjo5Gsa+8r8075YkZlzbqpttj2YhyxGEBdkcKKP+9Mn6BXZS+LMYLn9QVAoi+tlfvuCDM04/Et3c52mN972Ec42KxzKGAbRmGXzryi0WZ8ru46XHHwbbrqyE2tJ4qXTbGpiBGGDo3vy+ZYXVfjOZSW2HvL6kkYHMLtRQyojyNmTLpVimKSKugeHRemIHXJVVvQAhVM2/XEmLvyITxp8HHrCWT6bQiD+RfBLBafgOikDsN23prb00KklcbErmVC7KcXlyUwwm4nI/l5Xg1oWhiHcuaCDaVerqhVDXhCkiNAmQjY/nqP09CYoDUkb2Ra7xQGa8OHC0cHFr1IRrxD160KfJp1iXHAevfPej21g645GJYOdgTBK+RW+omY0ZItVPzKqGffc7qryKHGO2a6rthqWOlEWuL0INqOBCWXO9T/JKQUray52CNr5D4OiX/DSX2akUkbeda/yXVd3FIGeAbuZNmrI6ZfMvisfmKyZ3kD8njSYSGGCENH9XPKlsR3AO4nSSnl6u0qBqKpNay5TBes/tMBPN5hDPe9fWo6+NAuMhsuRN472OnutvY9s0EcHXu4uqpPfgVczZgpVGljUvXF02y42n8x3MiobzVL+0ijMNMj2I6IYVZHDVQj38bpNNfLjENVS0/vYMHcbhK55t8kiZiIIlBx9be9uL8DX3dS9UkFINpyyFhQM3CJJieu4spKcP25Mi2onXLUAWs1pO5O+2nn0d3i0PZCPsU/8v1GVPuiGojw+iO9PXVgQueXtZhMhlhb5ryCOW0tIKP2rtT4ZVe+7eKRLrNfg/b5D7ykKKXsOzttRlACPzItGbegVMJNzOcZ/ALmRJxxL15JKnQ3sDozDZ0DyLLNwk4fpZ0jGVqarl4BCfNYGs3W+LzJf8PSCT6LokKgTA8hk1RgOM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89c7bc75-7e43-4754-ba1c-08dd1fc50c4c X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:33.2857 (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: npFP08oZ9HHKM1hYRgaVuBQKCYoV0O2IJhTAFlh9duNZ8ka5EdOH5G9JBNmocB4mf0Mzpz6vBVSBY7B3CAyUPEv9KzYsU9isUZVPUVP7XxrFOJQakLfB9GTU0QPSa4x9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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 Thu Dec 19 00:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914311 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010013.outbound.protection.outlook.com [52.101.229.13]) (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 428D3320F for ; Thu, 19 Dec 2024 00:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568541; cv=fail; b=rMKDuo1AmEGb0RKAyVoe0lqymAu6ikwfLz9eBCtT2za6VkIOJkD7Fqw7WEERVvJu3WQvZ/NBFNRrE5ghT+0NQ5AFKAhDdlCZxiD0K2/Pijj3OGGFd2Lw3Nsc7R3r0GSyHTjzeKAAjRjb3I+mWVlhP3z1Wb5IH+wlJolVEvMoCVo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568541; c=relaxed/simple; bh=P3lBIYceFZvtGODMe5E2CFfedsXcVN8l9R42YlMN/GY=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=iXi1OSN6u7YOB4wWnPtpQHLrra2K93V6T33Hf200/useS8sWhTRC+jYvfr9sJiO1cIGgGuGDbrks/WJBuMM8UoWJHFQYKhEXu+v3kQtYGZ7tadHr8nt54CgIG54Y87xepCBGbIyi8TGlcBnkpy/a3zrug8uNokXjvJVc5nyb6Y0= 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=FHh+mUFq; arc=fail smtp.client-ip=52.101.229.13 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="FHh+mUFq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AWTrGp9ZeoRm3fjuVE8nktEBlBGvrwdD6/bCcfXBT/GWZupLSVVKYAOwrqliPntsHdzl6efeyh6dVHdZ41/Qy0SUoGuk3koss90iHSgXcJF/PkIvconHOG5eFu7lDw6BIFjNg8na0+DwrfsIWLW+iUEbso9fjU/X8KwRiRC8S4yV2g0WVmdsGyyEm447NfkGNtuXdXzN8P4u62GBLj7wZTXP0Pb42mFVHcj986axnhzdiSszroljB/943N5mSa6z/hpIna19ml1n5U+DeGepe4Zwmt4xkRi6bSlnRKsC0eP+/5q6VSav/2kJagd9X50Oo0LXeSDHRE6uT3j13oEPbQ== 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=kuCgUJ7m8x4OJ5JOyR1yfTHr5Sq5ZMi3KEIz9qHS2lxi39bUIO1R4yhK8tMDQ+RNy9Bz8EaOMh/4YigS6b0Xcl4eraZLApOf+YnlArJrmbdCnl8apVCYkZnaTBif7imuNCON60V2QIOc6eBS/PEzKl8T25Z89eTyayULePbIkWJjbQF+tu9hYSc8yiA5cz4GlUs2/KI+7KjDrhJV1pARbYONm+hPYUeECuH3T7pLrxUsFbV3oGPpW01ZQ3FgdH9egFa1NjwEh8PnIMv4gxPeiYI6sWcUEDyYGSaVf67tE2yHHlsd65wpqYvUgUA9hm/Jy++t9DjaRr56w10MfV/Q4g== 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=FHh+mUFq//x2JZ7NjjZyGDWSPCn5ZHPONFHnR0Qhc3HemktRvf69Xy5GBM7yHsjmw/pHYAQJb42ACfxxEfkUWw45O8waS+U1AdnRGtZEqs4Fhsx4rM29U9q3I47R30Xin+i7PFxRsv+f761AB4+bO2QB0V4dVZuE3KQeWmuOKI8= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35:37 +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.8272.005; Thu, 19 Dec 2024 00:35:37 +0000 Message-ID: <87jzbwcxwm.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 5/6] ASoC: soc-core: Enable to use extra format on each DAI Date: Thu, 19 Dec 2024 00:35:37 +0000 X-ClientProxiedBy: TYCPR01CA0043.jpnprd01.prod.outlook.com (2603:1096:405:1::31) 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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 8916638e-b2aa-446e-1447-08dd1fc50ee0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: //i2vttovlpssYj9Srd6XTGXzZZi/0YJGQgaXxd0g+SExtSSwZPpEGewIaIeuvdzZHtco2L3zFxezhsIEMVCzeMz4kJy+x4pjIj037kT/A0PqfewSwmAr9d9mgTS18vh1olPl00/E/UoyrxQMNdgXXPwRCS1mhpEKoqa5IC4Y+ULqt8ZRtg/9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e2JsQLJiHquGv3xsdw24Kg0TUozJJM6AjVrnBmj4P/Qt1uHLU0xWcOYNmq8fKYJvx/HktU/dT/siKoJ6j5tFlvyF7y+OpzXMdzHPt2p8ieQ9fy8yN3bgnWekQdZGmPjsK7z78FutmOB+gDeMm7V3vSbx2PsW/kLze8rB2uhKh9c7ZXClF42SP4RkKFrbDF8E1ccMGvGYEE1rKnbA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NsoUFLb+GyTnIQ0lFuA6KNs+d9zWi66mRGA5FvqfYLwLZuaOzndbRnnR0W2jpmoPu5AODeXc7uzR9KSPuHflusRtD9SyIJ2W5y/Dv6EEIORAPyzTiO1WagWrNoFknrms0rTcjFCOTGbKbtDAFSNnLIYh5sPYUxoqQF+HYJiKQNo8/r5Mrpb2FthyDCrULFCv4YeTURW8syNtyq0lAz278445RKJVYAdl/bHU8YBiHyPvvdiuMkmS+iWs7KBNJwTXHri1ec5nBCDJSNiN+b+9a4wwec7tQti0C5/xPmaS9xvYFj02h405tRmBOjYVo+X8ONB/0v1BUCjEwsYDrdEd7jJ3sInP1pUkfNSKYZ+V8u5w1Mxx/1tyZ4F5BXh9vOPxrjsTR2NqJHlxcXPZ8o7MVnPf51Ey202m0H9BwvnMQU3y8z17e3p+elS5RThNRruKNyvfwpNyZk5Vtlmi2mmKnuA9fDdTX+V5e3Gwj9C+l/KVKFUhH6BWoiiiQbnYhsNxTIBMrBNZV/vrUqSQonvSz2aeeCj6SYBoTR4k8w/2lM9+J2sp4WmaIWNcwEI+pPxNMUM38MUaZSMRymAaJNlsHomlkcxddFFMbFhwE9DPwEScbtqgJD3Kjyu3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d1fc50ee0 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:37.5918 (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: ZBBhih3HuhmJxugKKqqguUCZlsxQG9j9/Bgqc9BW6TWVrLlZPIZdLmvJJ5MiJ/i9ULCsnGEidlefZbT5nkqNhFJarcwHEJedN1OX8rRAoUX75TvRV4seiZOnrBjJioFr X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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 Thu Dec 19 00:35:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914312 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010035.outbound.protection.outlook.com [52.101.228.35]) (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 343C3320F for ; Thu, 19 Dec 2024 00:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568553; cv=fail; b=pidFm5/7xP0xnGD37AM2382WOSvIctZc+mSqqhW01IE13QHJviyqpGGy20x+Aqiw10QeJSvj9Pf06Hz4Yvp9+vNMHD9GeufqhaXWjDD9hkQIJLOTRCEVmaRaC3CSTZoIuXEJUm/ngBLjiadpbB8oQVxb7UjmnPreThKsU0ccEE8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568553; c=relaxed/simple; bh=G9kaKzuDafMKVegT1VF2G1sj+JLPn4enRMfBvdtQCes=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=EzIfJIlbGe76JDccN7VRGxTnxWXFufhcdYC8gFKYrQyLmYCM1jbtloN1LhGSdag4XM3jY/GRbOwa8NH2FmkpMgof9yRu128LVa4eH9ZbiVPwgZNQdOj5kSX3D6Zn5SAR572+gZ3EpmRNHxSZww6oTUqeOtSTOWVTRNqDmrE3dvc= 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=bab2Yj8t; arc=fail smtp.client-ip=52.101.228.35 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="bab2Yj8t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TgfMsIsMlFaDJ3v4Zgy5Dj/A0TG5krm8AuwZ3xo7522oYz8S5UtnGiSC1g4CVzMViHBtbABSFr/aGGNUM13RIEHYbMHTuH1lXRchLNGisr3aon0T2pUKXxqKBzzFthUkvgrJPnT0gG9DBT+ETTPydsOykmH5ce04yKfIRC3BGYvYHrjqeEatRE8wTPgJdthJ2rvdtqeIq74+aDtC6b0JY7XpidhjFgf+r5Sb/OhdGEQNvXkwuwA8JL7COJCtKAin5fgzr1tWLh743+yQQRxXIT1FapeRfh2/nRxOLH6KJUKpGrD4VesbnddhPoPW6rv/cf4HoVzrpepLmqyRdIHmzg== 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=VWuUWjPiluTxqbXkK51L/VWZHbvqsuL4ztRIhfBst70=; b=o/6GfhX1XeACBX1ooORJzmWjUn/H76W0m8lX0P1d8v6Y8ALEbo8jo1GNj74kqovIGJ+UDtj3V8sWdW5zej66NRun6Z3U9IosDGEPR6NWucnU3SohjjShjOhBdgtddA89lF15E8ExyTXmfFCemilCXqP6w7O0mbu6PbAS7+2XhP1Q6xsyvx0WPJVby0EjqJU/t4wwN/XqzlizPcsFm/uZI6YxNLI0/SKZuSVKmp1Of48LV3XDvWCNM028U6HfxncvGSYV/0biuj6Eo8y+D29RJX7kGQalinN5FB6rCYc/WhTZ21bfoxsJ9xpUOtH8HE19v8jOaLMoZvqPWN6OlZKj2Q== 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=VWuUWjPiluTxqbXkK51L/VWZHbvqsuL4ztRIhfBst70=; b=bab2Yj8tkBCpo7cge8zFGIdXFf89eHneig+l9UyxXzH7zELP6NjceuPmCj0snx+ShBJ+SOvXWxKO13LTBLe3/e3nCc/jOyh7W9SsRaHBAOL+i4mbxviATUWpKq1TACMkcpCuyScxLMHg0DmN/9Y1L2LUVgiT669Qkqx0ggcLR/0= 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 OS7PR01MB13794.jpnprd01.prod.outlook.com (2603:1096:604:36c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Thu, 19 Dec 2024 00:35:44 +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.8272.005; Thu, 19 Dec 2024 00:35:43 +0000 Message-ID: <87ikrgcxwg.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 6/6] ASoC: audio-graph-card2: Use extra format on each DAI Date: Thu, 19 Dec 2024 00:35:43 +0000 X-ClientProxiedBy: TYCPR01CA0193.jpnprd01.prod.outlook.com (2603:1096:400:2b0::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_|OS7PR01MB13794:EE_ X-MS-Office365-Filtering-Correlation-Id: 447b0f76-4766-4e97-d8a7-08dd1fc51291 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: PWQd5g4PSxWN0go6AUF7MhubgHkY52nfrfCEmS/8xVdb0f2rtsTOLX1z3yoo37fAH4KNwWoloRWmDZLRJEn9o+uYJIPEqZq2iW5Ft5iUiPjsmm4q7q63EvUmDLnIIjjjxuQOxFy8phVRppZCLKshdoJxxHHyDJ2pdzmOC4Q7JVaBIBmxmhbJUbTQgswX9uZxWgCAWRltnRov3bArrERBF6KjhNm2Rq25pdGZS9NUztY0hXYPz/ylPA8dsrr7EPfodJm3MSX1zEF+DUC/mIP3UQAgxi+THnViyvJypl21xrlOBD3r3aHIGNU6VJ7JrTVENO5GOopr8zyrCleOiKRgKQS0qAFq1wze7S66NTHCIvXSXIyXLgOnuubGhNMO8WbCcPsCzYle3+hUakO9SUm+hd2lTKUQouTz1wHQAft58wdR2GCRb4SIvPcgOgau+ohus4aEkNeAtbZy6vdO2v3tmNf3ddBkvbJyHv4vILltwdhSEc1oe+33l7bOJEzvMGomiNHUbNd/UdHlC6itC/j7WFSGNTj+AgPu7uk9Ih+qs1YhjEyb0KRE+nvA+vgvxLomqbject527QB59Uyaxcla3p+u46m/T+srilfoky8mSMapCWg+Bbd9zu7UJy1H7atee79C3u3OQjx7L5YpHrSPVADuxO7/ywA/jIcete5awIgL0pwkq4M58i6wXgw2RuMK2ooc1z0O8Nuror401n+UDmt4JXf8HOqfZ8A0oVLhTtLx3gEyBbk7NbBI10ll1LEhzQArBFDiCTkPSF7fa8/UpUx18kCNXK1t/V9M1yTvLbEocUQQMyI7yh5BUsd3XLI6UEhD7prpDffQNooDDruJxLgP/LvmKvfVU5YC6KQIONzkmT4PCRCIwC2Aq4mT4lqKfWvnz2pgIqAkDHuBk8zXEMYEmoLzqavoSR5tItY1gVyyfr99PkCzjZ+xH4ARFruYJlm2N3KuGMxUqt24bZl6PCuGVvWCXADSWz1qEFoCgPaBPNelSLAh4Kkh1WD2LvjuGuRslineYR1DQtF+7g0lZsd8uVpzqCHjQxaEVwNiqzP+UJaBM1pqVLTvuI8LUpUsld0P4eZHPlAVUO0nAzKKmuJi/20+my3zz7Xkx25YHi6IKWls4wL/gp/gZTtF87QYWvLLIazn4anjoWBcVo6lWXuAt+tw5gh91c78lbM0PtWspjVgvgx3P/CaLq1E0xY1rrP1rTPrjy5RN73Ck3q0wzEOHW/hVk2+2glmrjVJYrv0B6dU8eZgd1opmfEL8laHGy/+FPhGYw96q/dNUqvlHh+b0CocUCQu3cwkDR7pmbW5eCF7eCls3XpxteuZm8bPZEP+hNjIai44lfXXtzekKbGUhR0bjCvxusfQsGVBpzXUAjbJeXWsQpzdGSOOdSqiZG+Nf4rwwIeV0yZzhIVuwN+sTptAOZIDtqhGmu6UQIg2+/sNst3yfwfzDsyIBIr3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dN5HQ2PG7tcr77lElJvb+sYrOrnQc6GKw4lVJqV3PZDqd++4LJGi8AjgVDIkR8FdqAZEMAnSaLN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kL+QtXXQrSZYpSTEWaUwUC4VVIS/dUppN35RqwSY6g30X3iMUd/LfItHlw9mUpn0wXTDkriPMKPmA/vTjY93eTVmnAvevPJ2uQDmrrUQyIn8lssMV97Ey/oWiZlIwaWtJgHZD3PQ0IMgOaUBzGOwjs5aQXv6zhSSftbzs1p8n41SKq2GM3nkTuw09zVnoyBoxXc8PQMIH45v1xMrhdOyUEdNoI7fNNdLbpCtdq9Yubf0SeK9Yk4Dr373JeeWWH5yJGWwaXXBsLDi+zwqdhwtdzOKWMulgJVJC8L/gzGBfPrUMvh6VxvEZ7kLPCispNaftNCeKg525Ej7nGiSu/mHkgUEdBNq4dFDqhRxYr0+8ymcOHLL5AaTi4+NhJQleph9soM3pb0mvvB221E6G/o1YfBjCqlSQb5/ZG60oHbKM7WAcuTUpFYbZCP9ygNgm+oTikfVBgSGVNQXNBhihus/8UBWR7xIDN1nQWKaB5IfIGc= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 447b0f76-4766-4e97-d8a7-08dd1fc51291 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:43.8023 (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: Wug6iXurN/76uBo7IFvEGTLzA+upoKXrwg/XTN2yzQb/Jiub0h7p9F1UQ8icR848Yk0yppo9VzzV6tB8cPlylGoCrDG+fBOqICn7bwhREhvNOOGmgGabyWzWN3RnVJJf X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7PR01MB13794 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 | 75 +++++++++++++++------------ 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index f4c825b56a7e1..2bf7b25e00ed2 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -658,8 +658,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; @@ -684,16 +683,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)) \ @@ -711,6 +700,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, @@ -721,15 +721,18 @@ 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_ports = NULL, *multi_codec_ports = 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 i; of_node_get(port_cpu); if (graph_lnk_is_multi(port_cpu)) { - ep_cpu = graph_get_next_multi_ep(&port_cpu); + multi_cpu_ports = port_cpu; + ep_cpu = graph_get_next_multi_ep(&multi_cpu_ports); of_node_put(port_cpu); port_cpu = ep_to_port(ep_cpu); } else { @@ -739,7 +742,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); + multi_codec_ports = port_codec; + ep_codec = graph_get_next_multi_ep(&multi_codec_ports); of_node_put(port_codec); port_codec = ep_to_port(ep_codec); } else { @@ -747,13 +751,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); @@ -779,14 +783,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_ports) + ep_cpu = graph_get_next_multi_ep(&multi_cpu_ports); + } + + for_each_link_codecs(dai_link, i, dlc) { + dlc->ext_fmt = graph_parse_bitframe(ep_codec); + + if (multi_codec_ports) + ep_codec = graph_get_next_multi_ep(&multi_codec_ports); + } + + /*** Don't use port_cpu / port_codec after here ***/ dai_link->playback_only = playback_only; dai_link->capture_only = capture_only; @@ -794,7 +805,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)