From patchwork Tue Dec 17 01:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910874 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011035.outbound.protection.outlook.com [52.101.125.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 552BB49659 for ; Tue, 17 Dec 2024 01:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400116; cv=fail; b=JnbJnjvIiKDKQ8q6BpqWrORYKmtW0BOuiihLfCuLaZAssYyKguE7xMbcH2Xn9+AryyahoKaMhl4U/yFytotLb/bTbKjf++1//b4X+HJ9fPOkjeZc1C2AKH1GHv2dvGcj/XOCWQPjGMs6msDU6ZXT+JwTnUK+IIGsgsCgC6wjy5Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400116; c=relaxed/simple; bh=IcSAPPhyC4W6DxEAZI0beSzMymIgRmr7u1Kn3Nl2KI8=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=jz2S5UY8/9gWqm2mRzkuMTfUVfIwaLgK+ewaMkaIgWpRKI2pYfDKngdT9JpO+uHX2xOnP4alOLFkIO8sXyU0MuhlyTklYSs65f2Fua7qPTGTsgS8BKJrVzwN8XWwTtySrzC3HdV7DYOggQNOKl/r7DAGQuDcQ75oMm+0Gx8GjRQ= 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=IlsgAi7P; arc=fail smtp.client-ip=52.101.125.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="IlsgAi7P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ct6dbv/gjTBvOtzaWrPGW4uLo8x9PaWCbCeWvVdPrXJ5v46ENiwkbnTwQcdPiBItuSKXeIXs+50V79JmGQRSGdYDH/Ymvp5BWGugBU2HOhoHoQs1CFPABZtPUnO6O87VrhUJtvlSmCW9gSJ45K8PC2/DTEtv/G04lYDEEFk/9I4oKdkd/30Vr4BsHcVzG0h1VYhB2NjKHrWJBTT7pwCNxUjNO6FG+GKErlrtBqLI8WJ/sb0Xxc4YgG0Pw+ACTE4HS3crhzxzrnMS4SvO1AAKBnkjRZD6W0wZitgCIKMwM8wUwd5EmpfEwzrPxH9BeV8o3qpEq7Z5mtNwpe2FautoFg== 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=hU4uuVVe7MacZTlGKHb1JPA4+aDtENIvdmuC3rwAA7Y=; b=F8q0Z9tM0aMS1ujmt3bNWFD/joTx/dylHYLnpnIfZzuKtblue+9wj0r6irqtjKbsqVhHr8HquI9ziGl22WiSNYTGYzF8cd/Y0LwNbTukiTvBVBBRQu+DK+RFswAsHur+oJRKv9B6RR8ECIdiY/91sDTGV26MpQ57SnrsR/9mRTJIMVdfIPr7TEfO+DopchqbWkq7Vrm1YAPP7+HwMpwV4ipsOypDdaDawoWgLfeySU9ZUTt5+Sw5/A3mMatA0IHAUosJTSpFzExZb+9xv0X88DhQ9/va1jvAok7p9vI+b6ael1kC2xoy/b0sbavZWIm00pZYN5OHiHqeZehHNjFfeA== 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=hU4uuVVe7MacZTlGKHb1JPA4+aDtENIvdmuC3rwAA7Y=; b=IlsgAi7PGndt7lhfyEOJ7MhWr2UoEOfitRZGrBHplVXcIlTdVmJmWMzLc7/kbgut0s8qIW3mPGZkSkhI3NZCIryTJnXmvOBR60R4RS/h7MgFaQrZG0dbuHoobik/AU5vajd60K7mek/gJpg5wIoqM413bYDNMKizxJtuQCd+6ZY= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:48:31 +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.8251.015; Tue, 17 Dec 2024 01:48:31 +0000 Message-ID: <871py7nkpc.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/6] ASoC: audio-graph-card2: use __free(device_node) for device node User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 17 Dec 2024 01:48:31 +0000 X-ClientProxiedBy: TYCP286CA0148.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31b::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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 936494e6-dbb9-41b3-994b-08dd1e3ce91a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: MlpseQp9egydorHiDZ/TbDh7BlZeQDKFOPUJttd61bNZRXDQxlYoYwXkoW7FHf0vntmAs52C6ENSzM0v/VROC/1FcRSv7nH8/sQHDK9CH9QUqxJsw+AXx2Bm2wHtD+1UDSH6oCcHxtnyGDgFl+d9rIDDW61zbtRblcBhDnXoL9PMtQl6WbWS5EukhAeD7AoBYQ7mIDiHwm8kkdLGFjR8x3fCgEsPTcmpFnPcPzQRxlDLGraJ4wOMzflCKeYtsgsQ2rYwZ43S6Baqtcup0XDCAAZMeegWO+p6TqWK3lMGd3d1jX/IKgEKvGQnWfnu8z/CXX0wATO45vhHmhn8CMz0UlSyS5vfrkqSQ1uNaaHh3gg9RFqe0s4O1q+Xm4tFBzur/ffTggIPQ/chuwM4XedXGVzSRjjXIKttq9VZc9o2tKJfm8a1zG0XtsSQQ0Nck6dQB+jx1395owD7Y9RSlfAvnWqbuk5zGNY9wxDoViO1a/6Qkhyr98V/h2cBewroWeTGGtsXBz1w1jT6wEeF4cX7BaPrG/onP4m/SC9W8pWvfyxeTeH/gI2Xv90G0xKxU3jRwh/jKSAHOgB2ZziqIcn8r9TdS/2SJj4G/6XpEiYXD71ZOrn31T8L6BdsjT3GWIC5QL+RtG2kjfoauB2YqY8of+e8ISZ09I7tQTquJ+zxxYff7hWqxyi3N8f8eOMGliXGCQMDo5EqiepnbN2Wr8QO41pyhdP/dPzUVai6A5PEuYjKYTgl1hI4Y2J8fzITKcRtQxRVWSmoNyrndIMjQHrpf7/xOffIDEoq/g/aj5Oa4HOA+YRipJceL6HR192P9+9/c6+BSx0nHT69J1ZPWJdAgBzVMLCzhzYxvjnuEVO6Jy6QHN41WwhDLDt02VD3BmX0JwKoQE4zWS4FCQB88Giyw/+7knI9rkE9jgguUtxqADCoXxFuRPvSZVrbsL2c4WPeX6LR7mD3oHpJSFp3cGADSBE5X9YBn6pD0ZvrPZ8UqIA4sv7DtWzGqV/ZSvW2F5elNERmvC1AgnZAIiYe4TVn/DfjpkyqIDFqYUBZtQJA1Sb81bp1bVtuRvjVqbOcIeZUxG9sYoU6TTvhnzKl17MbY7C1EWH1LNphFJy0kn/uC/tE7pb9JXUJyQmmuTqVuYX2dbX1+rUOAjuqIXlNFNoDR5ssu7bjTglfrePLUqY2O2D5YOW77x5Fw8A6/D/i1JSWA5kaD6k+cB57SNQ9o3VK6YA6YFBk86PReJEzvrNyed4MQ2XRrmZYRY5aLX+92N1spDfdtKchvVpH8AOWD2HEbdB0B/XH/1g+a6Ga3egTR1H0U496zi1ISgjohkaR5UXwVfuxLz5pUNkbtWH78hrAjbzrQBZV0j7ScM7NXlB8tY0TUh21NUrnd+BtROpPzP69pK1ocws+g7mFofVZzNpib4UVrjO7u5DZuuXBl7uf6+wHlPD8mGvbOg5cWpxAgclY 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X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vV2TvI9vLG1B9+kIGNW4T1UeUdOZCzL3HdyV9MPFybbR9x2UGBgWWtUc17pCsVBcVF+RUSZvtQ3pKqHaxta3Dw91e1Jyz8EMMHyaNRaXX6XhJIcrL4ugsNNrSOjevDK55/TWQ4FfDJVAdjN13RlG3tNUzZW68Dbi3/Qxohdfqs43BVZr4UX1Z9gjGmwGgklMnLzy1dHvdRKvn8e8OKa8S8RpOSU+9vPLGgWXmNwrGZqitF07OOe0lo2kyWPd/xZkTFek0Bg4etnubdOCieSOhMrXhwxa6W/Km4hpSSVbSpdAJ07a53v+2woqi/Bo9ml4tkCT+L81MTjm9t4hygXFV5+fQ2ek2AkuwCDAE+0m4/GvkMzPcxtQBL5FetS1JuoARl4tiVS5v6XbQdwXfZwIHqT/OzWw/htz5MicciD8C30lz28hFjA0wi0vEFQjzUEp5VfOCvpNNetNHJMp2eJpNNUTKhpU6PwTLjeVccSkWO2wa25FMypkngwUJGb+wV7U4i85Aqo/D6tVwZ/YdFVkMIUeWjaZ8LPmpa/zZDaurEZq2a9ONB1S/TI+OFUhOiBjibfk= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 936494e6-dbb9-41b3-994b-08dd1e3ce91a X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:48:31.5002 (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: S374eX1FPlYxTyTCvzp6hhKHFKW/Mlk1T1XII9XzoZh2Yg60kIKZNPng5T+hCoo/mlHevdjEs3nsQT7uAHDddU/9g7I5keUz6B+0bn7Ttt8t1gDpXCyWQ/EQlrPKb03+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 5280c1b20d85e..079ae8a7bfff8 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 Tue Dec 17 01:48:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910875 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011029.outbound.protection.outlook.com [52.101.125.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 985C942AA1 for ; Tue, 17 Dec 2024 01:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400120; cv=fail; b=GxCneQRbaihrgIH0SLvjvRRx/tx3RbWr2VHTdX9AfyNDMcuppQbrH7SJaDWer7S3kwA7B9EsJhu2JhUa0pNv6LT3SOdzkHRk6fsM30vCqgEWy97Cu2AFThLrZzK2aYSyWm68/eLq4uHPMeI4+KLnXQRwrcVpD5az+x+a1vNKa9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400120; c=relaxed/simple; bh=tGcFxxdLtL9v/FocUqoOF+0WgyRgMs3IoGhbzcBshD4=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=b2pvLHGJSlr0tq3zMDwprjMW1dfbe+Q4kzsts/gmkhci4wefa+n49YiKUtw3m8aE8tkrsm8XzTnWutLM8KzOBIBoLSkCXD2sGiTyCsvdH6F7c+apQJSBdrCn2PuE2rEQuG1np1YPVz/W/zROo0UP8P0FbIn5chzL6PLfjEkfbic= 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=edHiuPCa; arc=fail smtp.client-ip=52.101.125.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="edHiuPCa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dLOxtINY9J6vnCzDZvI+jpIksSdQLV/PW1E++czIfem24/l8veusiHc/rlFq4aB6RG382AAoL0og56A+Sk8HVRrqez54AkG9bRyZXguuI/jQHzOGPnUMehkgCcLqlSfYzanvE/4j0GXFC3cRf8QvWw20fHJlyLZIkyUO0tZR1oahQggaY0pY0Yo0sBJ6rlo6apwkSof4U0icMX6t99TASa0ggH74+5H0rWb5P/FRESDoSuCsCnFqAG+9Z6GovTsvLqqosEO6RpK5N3wDsnpMZDSl7pBeg1Hc+jxywlHk7k/jBP1bKmne08HUdfwlbBf00K6c/jX1K6D0NbMyj6JPYw== 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=fzVNwZ1oNLqYLu49rKI/j1dwLMCHov0v664DJyEm2D++XhKE2kDQHM34QPUVNPRwKU0OFw1sJaMM9kQY7PcdeRNuIjnYkeP7ffvg9eJOW4qLhS7vkXv0pBLRCdNDgHvTmNfjjek29zt3hjcW2aFNnYXZQdZp6VwpKunlPIfgpuSxp2I5rU+hBKq6uvf90PZzxzrAQzXe+7e+wCQIDt2qjg/8lPqClZjv5fQf/zEdzYP5ScaezXFeR98TpceY5RG3uCKsqunuhOTCUQTNf+22pE82f9pebUbAONVbykSws4ZTcCGzvZKndB0VE7gAJT/IBOM5jb+4KY1rdAZcO3sD3A== 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=edHiuPCa37jAcma43vIH6Yc1DAr7Q8H7igG3vmsyaz7wP+nzrMtk70mw67GPEeUDqN7ykVqMCfR7LNbZ9PpDuiSVilAEP4rLb1Ilbg8aupCYdjFHekcE510OcRl1Ym93WqicM+KbvJBeTZgKrYMHyFRgbV8dSvArGf/cq6i3q44= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:48:35 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8251.015; Tue, 17 Dec 2024 01:48:35 +0000 Message-ID: <87zfkvm64s.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/6] ASoC: audio-graph-card: use __free(device_node) for device node User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 17 Dec 2024 01:48:35 +0000 X-ClientProxiedBy: TYCP286CA0148.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31b::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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 1528fddb-2387-49a5-8f4c-08dd1e3ceba2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: oc0kAyYkfC3d5oBlyk3rds4F47j7F3+d2hWPJNiEuG5vGuO8vRm2SqvyR9/S09Av6fl1QwiPulwJzI48Nc3QGGWp+hFdz1AUCxWNNy9T3XAxmzlMpXVYBRrvQv7Pe6EuAguVZ5IFd37c3gQ0ImiFO8xVyWS1/Kq3a1WKmZD9Nxdz7PnLSwlHrR986kSPtZW+dN/0jl06qNmxnASLK4ef1/DXTznFXX2r0Ar2EdVz1Dve/eIGx/iGd5V63+z29yCLcAJAoqx6x/Hr0iUedIssRvfeDPyjot/or2iff90XVQR84vQ8dFz76WADJyr5rBazmDFrquMOMKItcU+tlqB+vGTJsvJjt+h/bq2NnGqFHG2bxutT9NTBHEwg6mPnBajmgsMcFYK/2hzhzby/1vSqWhggIrjjXpDq1Iqau81Jft4nhzx34S6OMJgmM442TZROvEysR0sEo21U9m/Rzcf/hJDq7htBeB/Ov8fkUnP6VeXQfI+iH7tBnL6RESAwMNCuhy7pjfsFZrazUnM4FZRrCdxe65y+o03EurFjLygtMGHfyAbnlv7lNhJGIWUk580xNEPg+kBSTFJjQhaU1fk1jguUYVumxsBoCDG67YjIgQuzRdKflmcWlrFOsB2QUKBQZymSnBZL68k8tEg919rhlkKdoSaBd7DYxoD7gVRBM4aegoGLap154obzVX4zcByYqA4TDngT5qYH0aq4VYKUbh/csbargZHpD3uvBU2RConZ+qiGuSGutUN2bPCg114JuEY1Uxe3qSgyM6fiBjCnS5naSa+GI3X7HPORBQL12KkIB7E+6FeZw2wk9yPNItWTRWyBaCaLWgnLZw61wgtLM2Uz2RNvsuxedoHZvPyZM5obWUa5BCyPAq4K33Re8U8C6lV1dRwM7zChO2quIpuTy/BMZf7e8Na9FyhR2K0gT1wuDdPuXNkfVFOpjaQ9BErim0fzjdmwP30EE3SEg0XI4A0KUUixWt7WMIrOty+nmEQxzfN3IJ9osdfEt/ALwb3l0Y8CPNgt4MmjnqYWOqK6jUNWvHfglQz4rzSnMXLlZ88hXNzdUDm2BI5iTlLGMa5DNKdOPfpn0Fkqe9AIdtDRiZXs6PA31tUwGfkINQDFNJvmTQR2oKht0saWNCr3pMrOseqyDYooR9hF87Hn4qQWSyfRVrM5iGHlc1nUETu2I2m9GpcFRCNOR0M6fACF0Bjq1E1mSXXzwnH/Zgq5EiWSBuX82CEtRc8D539mHv/S9MdaqacQqvLD1y2AV3WIcQvmlg7ixDVplls8RO9IvSSLZeugfmS6RB3HEueCSapUXONHb/uSH9f4qmCWth8DtKRlHtUjUJpEeY6A155t/QKJl0ZRKmneX8MY0MmuVi5AIMeevj3P91AHKHhmPB357eulIGkH2j3vaGZG4uWjujLoijromCMfn7wRumVVb6esfSOlZ3KuVTeYvbTmhnysUn5u 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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5vvLm9V+ZSfiW5jn9WYMBuTsheLUDBKDLUH1me4Eyf+bcxwLmJFwxc0V7q1jEwshWdQ/QBM5A4qwZPPWRSmovzlh7VeD8rvVx2hi8txQwISjKXa29iqgUOxCfIESTx5AzModIIksDe/5P/IdvFc4GQV7p4w6Lht611XtXSnUFrYmPHWJmZknDmKCQa00wqeVGnKc7XR5vA1XJzSkWVoxe6WT6e7yAZcod+/TyGr4lnHVhiDreEUhnFYSqWdA6UM7nUGyJxc0VQWSVEUgVTMGL1L/rmfThjEoa/RMQ1reaVRkUJZkHITPHzpamLl+N0POGBt0x6oDwtzwOLjsyBGZ7+c6XxI+kC6vSsnRlnjPPSFBXRtFmCAvC/rKWSWhYzJRZFkIfBIWZClndMWvAbJyD7CrAXZoTIrS7dUFxHEf3Hr708Pq300P+9vjW2oCRT/rr307o0mHbtlAraJtYZrQ+zZQT8h2RCgkCRGIr31M2W7nxznpx7n9JY5HVRF64GNI04hwH33167tnZBQxeAt6gjG+JE713sKBRSD/3pIqM5Wf0I2klB1nzTcULp4g34DTEjkA2nwWAHfbPlocE+T6C0kXw9YY0= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1528fddb-2387-49a5-8f4c-08dd1e3ceba2 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:48:35.7712 (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: R7PNuH/Y0+ew1cGvE/8P46fDVSQIldbXLMZ3i2pYBCNi/CYS9jrr80fvCw9VLAHgr18tWFa0b/+2SRuT1vLt8XHzl1XdK8fA7htVlIqT5Xpw3W0WVfS3aJwF/8sRuf6Q X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 Tue Dec 17 01:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910876 Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazon11011005.outbound.protection.outlook.com [52.101.125.5]) (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 720041C687 for ; Tue, 17 Dec 2024 01:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.125.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400123; cv=fail; b=hpaQf3WCc5G4kHl8qiL9B90vBi+EYue+nS8o+zoM0VJM0VGTGkR+SjuMF6bqEGLZ8QHxK0PUJ0A8B4GRDJu3Z20xpgQZpGvZn/RFZGwGiuBZkgeMtyPcorG1y3mjyy1htCQ48u9q4Ul2E7ykVSlKbM3v20g8Xf9ldj5Da3ldILA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400123; c=relaxed/simple; bh=dFfg5Ae/MoPJH2Ejeb8Iihqmn9ztw02wCYKV3a6BO08=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=cXVT/IfzZ8GbZdiwQQNJNjsetZyQdx+IqdnYKEMsD5AvtOG2hBsrpbuyTC1LmjZIfsp5ajEwJcfqO07VZpWevCQW2FRBVBcfzBy5nnXrd9aCbrOaAWOkZN96wFtdBHPWH6HVCJVc0RuVo/4y3x6X/8i0nFLtbvuPeb2l2jzGPRw= 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=FW5gL+Gd; arc=fail smtp.client-ip=52.101.125.5 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="FW5gL+Gd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FJ2bMC+cA5zoQP4TGIJhNX+pufg9Z6OtD3LpQyEl/KkbOBxzAzCapeoxHuVIdXvBetUpInJXjjZ3pOqtsLiat9MGIRBzJk6sGhB8syVQwyPRRhYDayoTLNzQallY3tcImMU7bU4zJ1CS8kdHLK44SvrZR/x9eQrcbWAbf+0PsVmzFdrnNp7lxKKViDmwxKqKDWzqE2SgCezT3+0R4zYi6ceEK11I0oSI1mYCGGB9z+jL4xP3Z0SL4GYSKacsZzHeEFOPa8SGXvrxqlpYsy4FY16roITxFyaClmzVPv/iBsWT5jzr4ZPzN57szdy+YXvaQWiWwPGpc1ZVpxLtV9O//Q== 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=unZ4V8MK/mUNmMvVaiL1mXk0nWlWTnn+KzC+glQvHx3mJGcZiPfMX6WjMfc3vGvQrxCYXU6alQhQ1QscvhcKCRAQX0pD77b4u8negqzrfbGsyudowUrHhqc42molNO0PoOuF1TWsBKyoGDem+jI4/0xtRtJ1iIfx/a5H27Ij3P8VFWJZaAhkkRVw8ebKCMZB7aNqEVoatzU1BBWIHCnbUZ+O+fQs51SG2hUR0JkncBjMXD4GopIKadxTBi4Q7oZr32PgDbLrT4jMwGl9olzxLxtgryqer/iN5G7FQilv6r+DLwNZhjWPFVKc+o4x3T1MHyvJtO0ha/JwjdYe9d0WJA== 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=FW5gL+GdKiIaWLQyBhVEScDf40U7aE6nyosQlyzJCOv4+HQfUkQukzT79p5bqTj7p91ujLgMBYHbTMJ67XoVFDQsR1veInmb6olEi4+LWY0Gu+GJjeRloHBwZKqBuR0u4W3fU0DAxXYXbtckJ6X1MGNVaNuLEgLff2sB1GFtJIg= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:48:39 +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.8251.015; Tue, 17 Dec 2024 01:48:39 +0000 Message-ID: <87y10fm64o.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/6] ASoC: simple-card: use __free(device_node) for device node User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 17 Dec 2024 01:48:39 +0000 X-ClientProxiedBy: TYCP286CA0264.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:455::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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dc0aca1-ee98-4d94-766c-08dd1e3cedf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: Ueia7w28D0NFdlmbkaAm3EaIrbWvgqgM+E/CIjAwRHChmfXaF1dhmy2u2VfmoSeK8CBgIDfJqmSjUo7y2d8ufReoYY2v8bCHuXOmacApPO4k7xTVFhNBxm6tVL+4GuVhLzuy9dg5LmbCIaQeT3t8gHb7mdQoot8Dfx8R99mN95xDUK6XOYLeeDlt8h0bjaZrPb32DoeX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tDm1L8V7FPBy1TGLppuYLkntR/b4aSMK2JGZejeRZI2AIWRri7Itd+Js0GJGptLeMYY+iO/SCgoq5kcGOTDy00IzscbKMN/Z3HCIBDE+hCIfUFh0vZ3X3ibx1hmD+Amfh4PAGRwCh1WIoqDKBlMUMGXrwD63B9VtsSy9DbeJg1ldpjOq1TJobOpFNKwHknurSyzodTSoeJyT 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gz1DHxaBVNogjZzRP3MsrRR+P8cKWzgPCLVP0hRnWhIBkRrSP0VxcsVf5Fa3wjqXTj46ahtfkFrO0EUHwAJiqD/Jsj7liJ/1POXeqK2QP4oeODbp0aePXtiXBg1ihD6tLEhmzka/1u8IwEJD7vTjx0bxvZnHDYwhPuEfdJ1an2oD82QmeIgtYXlRSGqlo903kjcfplBhcKJ1NgHWZFtAGo6GHcemV8LLJNHrcVckBN62lkVEFIcRgqo6fsql/APLKZvcr3Hn8kZbmKZX5QsEMEqtDgrcwbvGrwViJfsIJpkzkVSGb5U7j4SG10B+TxTpI0sUAStZ6FJEQUWX6tRCBM6RW8REkN3KeenCBpR0pL0B22qlmJ3eI/A0olS0duTCUAgmRjwl4BPJ6TXQHq6Mbo09W3/yawgBQws/06UOjw6+PWd5T4mO7REupgaUvgn767agGQR8EdPGvE8bfRHkldvPDL9WYHLLvmuEavHFEiVcIIRGGLrfWgNYehCiP8wudOgt9Ft1Wf4LbFcoxX46eyFxRYbEIe4GTMC/XKeq1ATtQuhj7Dk2GMMJN63Ma7G5nkDE+G73/dNsL1bh19JK7iC0W6q/NonqXf765hsVswWEg5+8tttr3N0czzClcpSy7qe421hM1jCubFURdYLFaP+RREUo4HTaMKUwG0w8CfGrG2tai7CjCYxH/9zYoiHsHMa/371l8gf6vynivPn42BfoOsCJ/htFSz3ZRruesbJGfjTmMeUM/ntc02/CS3ESu+zTOhxXHap2+I1wJ9TXEPlKetWVlTgT9IkIWAzmbTOg1WFvlocaW4IsJeVZ/p7gQv8LWyWDAcwW/OWT8wy5xu4TAxUFPR/wFTdlbpVqK8tTaglfxqBCtBIyEttAk9RCE/9ML153byKX31IYLhdRs4wO7Qd+/v8RE6KpJozveOrFtc8NM2day3GeaMQ/ac7V8aF/b89ky7P0IaIfc37TqCNnT9Vr4pjBmZnBhwg8buZCMSu6R3zZk7QK0xdonmCp9u8/0AJvb7AqxT0S8rCCUp8hMMrgSor5KvwsXQonmXd7EWkt7h1aFv77UrCdr4AzMUapzhpGYsThITX6yCK3kA2hbgiirCcIWX/RDoBp29EbOdFn7+jfF+wwflbxYrK1Hj+jKx9+ORbuDuI5vxcBSx+eA2jwNp8GLUwg2rXkrmgZnT2+eVtQfZ/m4QagWvnh0kpxb0v17ZUDjXamfzr9mDcQec13twBFBILD7s7AM6vGM/1RdoddEw7lgTofSq6NvR41JB/ZKDyqzyTnoXfWpexp+ipbznPwQvI+RoXCuKfd7aRVj7bHi2muS+G502yikFj2DvlM7CzvqrF6ROvjc7vGWhoEp0glu+KOR4ip7SeeNC7WUjcvA137qm6G73k3cq0yfiyrWJQWH9CTSs9LnqhTtnKb25z7RM38EphX6YlkRMu2R/oviTmJIWszA0KMcdQ0giztfoMRgs8MJZ6ZmQnNOVgMrP1vqseywewPssFUfYlQq/jLoYCUhzDRyaw0tcT5dZWtO9X2pjwwgOLW4Ima+XADXuak6oWx63nwGepFTyVfh0BTL2jxWHd/JroAV0MA1ufHa/ZIS82MxyjiDP6xRUTwonL7KHhLa6E5hks= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6dc0aca1-ee98-4d94-766c-08dd1e3cedf6 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:48:39.6566 (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: wVvcV3rL4eD7AnO7obIggRgp7k6/qkznH0YSWw+fVJH0/oWvF0PaSS7b3Iy2dDQRn5RcfxOGxdoGUYoOAU8eYsgDIFFdp+0/qKhNbMiRuw0eIRWk/itLtGf4PJ+49fQ8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 Tue Dec 17 01:48:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910877 Received: from OS0P286CU010.outbound.protection.outlook.com (mail-japanwestazon11011023.outbound.protection.outlook.com [40.107.74.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 860B743AB9 for ; Tue, 17 Dec 2024 01:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.74.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400128; cv=fail; b=n/BAAguV5sFP9Y9pWuqQ7m3kmXZCAj5e68gcPq08Q1dS8bAAy+WkxyNm+ivuXk2gj2iGan87zc7DmFPLFU0km4ClrKMW+gtuQ7Oe3mJVvP1/f4+PgA/zK1vDIitciYbtir99vHz7ZQNmM/OCacBs49LdAfdwgVpcQ2Ht3wL8Tn0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400128; c=relaxed/simple; bh=RWRXr/aUyMR2s3+17Copbv5x3j/ZbDjR7g4ASZF5u68=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=N1V1wnDLB4bNgNJo5SP2B81KkqYTr619hyLoaNiT8Mh8/wbqFdSrtr4TV5uXmoOq5ai/XdlMsHithMQQ8a/EJhpiIjU2fD7vZ2Yxd0jP8C+SUwmG4kr2NKz4lOye52RUvP3yGkHGZ1oE63xbC5Lu+Sr19vCg119zcctjWZGxO9U= 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=DRGymu7e; arc=fail smtp.client-ip=40.107.74.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="DRGymu7e" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wN9Tk4TO2WxHkSpnqsded8sh1PsBf8IZ7ymWICPTVuKSnpXNkJ26HMEmtZaDODf5vAVgo023kFBvo9IVQ8f4lxlQi38BSq6yYCeAtULrCwqyTErkLKJPw4FLa1nPBh2OnIkBHv4bmD9JPJKZEU+ukRk31SE7WdncZbPzMPiMLLmYSmBxw/D5C8JMs8qaCt2mqt0DrxsSUaLPDA2+HEtgPy6flFudd9SIE+b2ipos88RJS3VkvXwAVLNQ5ePb2dlzvdDdFi4ndvqkAAPDJkoS9RcAW3QaAEhu24qU1CVmqNvF7lE4DbsuriY+iGpPBBnH0pH1QGwclgjbcesK5ex80g== 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=1WYTffNcMlytA6sJF7KR9FwZRGyM3o+Ej9gK5Ukvb7w=; b=snOjITEUZ5SSQ4/efetjkiKYRi2eRFlwy6PCZvP4T1bG8gmIjtl2pyzp4KTeb3DXj48q13WvBK6GpUN28UiydGqCjD5MoGz1bzNUJ8M5zrktV6Q92hX+iNFqdpQSm6tZ0Ai8k2VMLM6yER21gUfXY4qXi8TWcTae5Eh13mYDhw9tW+38tBdZyjNNVwJVAMHS8clxmhcl5KrmILO7tQcvFeNBdbmur0BT6YMhI5AqcWXCUTx2lzMb6VCsQ6DckQDhHD5bk96sPee2TX+xIz3oBy0qahVhjNxYvC2H+qBxmJhYMoT4bTSK7hanywiEDu4SfUBTP3PdOqPuq024H+JqdQ== 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=1WYTffNcMlytA6sJF7KR9FwZRGyM3o+Ej9gK5Ukvb7w=; b=DRGymu7eZDnGiQIUKLvuOHrCRUN0vSuDYKhPfBJzrMMfQZhJ09WNLsUNq1Her0qDorA0kRUAz/AR1qyd/EpIxGM/vc+wYkbr2cuHNFxWCNg9RG9WoSszRsGWFkzmP2wUJJvvpwoKwNBQv0VWQeaZBP3WUqsC4Hv6KVBRdW6vELY= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:48: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.8251.015; Tue, 17 Dec 2024 01:48:44 +0000 Message-ID: <87wmfzm64j.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/6] ASoC: soc-core: return 0 if np was NULL on snd_soc_daifmt_parse_clock_provider_raw() User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 17 Dec 2024 01:48:44 +0000 X-ClientProxiedBy: TYCPR01CA0106.jpnprd01.prod.outlook.com (2603:1096:405:4::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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 96a6ba63-8ec9-487b-7ad3-08dd1e3cf0dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: wO6P8oVCp04amqhKhFsmSwUsbNV4uHPrDDV3bvRgFBnQHuWfDBZ9qufXnXe0cZR+WNncsRFqEHuFor2nCQVwByrDs5yLEceznd/BoAKngOBro+pY3KWxa6Uc1Lp2uIo0mObYyQJXkF64xMz5T/X1Y7XjZ57z5iiHz20kAVV56pdlPrACq95LeRDAWznK2lp8sRTkHt6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oINYBNcu1iCl394Jfr3/mkeKbDbJBB71YkeevDNhXu1BVDrCtKIO0EbxbJvMx/IS3Q7j2Okkid6oxWuPHHUJRayLfaCtaupcsZIueNckCn4DYb+T2gJgt0+HDNNPx26PzHIJ0HfFFZioX1tKNEri/FwoJVezNgjTt4Ya0Zq2CLDDF93U+W5B8wN5Fq/2MTrIw 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m1/7ayTNkQ7lhhFaT6ZUCk8ZhswrqPk2gnob8HD89C/kgGxnDb6ERYXjJkpgniQ7iKPgNPFSHjxP7z7Bp0LngdSbk3QB6Cc9MfzOGdcPayiBQJl88MdIHwSQsRNBzyYPL8rh13ELCsT9Dqs3zqcdRcER+rZrCcNdjucmHFa/p23S92G4ZJx3LcBuDbHmd/XMoZZTqRET6uz7a4qOy07mvEN31UFO0xIH6V0oWQLYWfVOTPT81DOfXucz6+ASCTi1KLrqUUvc8cFjACN/N8AnwcjcPR1mDEyyH1Glqh6JufUFfg+lA8Mtc0Y1gp5JTkQli685Ehx2N4kBPqgpo4vzTpo0S9/YgHoSO1t4f5s1aUsg92MvkgcQ9gDGz6Dsxr0KwB7/qVidu6ZeAb59NKX09lNKUf5PpVlanCQQhKbmO4OwQW257PwKYMm0pFR8S2ITsmR4rAJU+j317u6kmFdyNkpRqkZpGdbaIIdaOC5SOO0958sxkQWUtTuNPXsxhScx+4cvl/WeKBqC53e66UDThDFHc2a1KUvDPhJFGjFNui5TGZ2tQ69bg1gvlLgaWTmKaMxJeKGXCHFPZWxHlTl472xb8CeDUVv3HirCPIN4avgUbv1USyYQlfKaHZeKKa8XJL68TkHXNeFL7kt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ange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:48:44.5526 (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: /yekdKUp9mCFnf5m9OQsXG2j8zH+fvhMfaSRs5BxZZYcmtTqBUEyt+2jmN/Bh6LkTQho4gAwAUAjEwB4DFtvRaFSbhiNO/VQ2KFfX1QxA8oXFj/b8PZR7/p/Fywmi4dZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 c8b7f78b02f0a..426f8d8baa38b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3391,6 +3391,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 Tue Dec 17 01:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910879 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010027.outbound.protection.outlook.com [52.101.228.27]) (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 38F1612C54B for ; Tue, 17 Dec 2024 01:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.27 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400234; cv=fail; b=KtAGKQVqQpmjFTGIoxmIAk+jui2Ngm+WAX47zCpMOVqiXOmQglIqIFxyi7imI+ugs6IoqFLSf7c/gHbAVD5jfpOUj8Auww/r4RKTN2imZIwhdRAgjJrvKFp6tFa3GT3GGYB2Ruv0IK8h3RhwfUwfX9B6ZDj0wx7nOi31cjsQHk4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400234; c=relaxed/simple; bh=Lc4kzxLCllajJdCh5HkkYJyONs1sbaRqqvgHA+IH2N0=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=D2U31rDpavd7aFR16Rq/arMiq3GHCpqf/9URStmPb7q8NNqWFIC2nFPVRlJnMwhnWRAjIAXI8cgDUMHTRMNc2BQq8FZhGsP5SUjS33pz+TRJVgqfHBBBY+/FWJWOnGJkwYbAtJj6fhEOGRF/F2Iy2gI8jHlZKLnpUAUj4fhPPYI= 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=ohF8ZdbY; arc=fail smtp.client-ip=52.101.228.27 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="ohF8ZdbY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WfI+mmcgRH5vqKtlvMqYciKB0rys2u6Boga1G8kxZhxDMwYtNpAC8ylMc8GMNKsFm77GNLsVOE2mSJ/hgIlBkLELS6+EI7OnLat6vwDN9s3bUJKqf7eeWVeYTo4/Fhy5MHmrPLVZtS28ck+yiwxEH49jCmKPVcjVckyuHPREWkulY+B8d2hj4eDd1o6z18OB/OMZ6/4ZAhrEhYjp/h4ny4urC2Vtwj35U2dZxI6FEbCDPrGqki20UkvuGYaG8RmKKteQKOG/aSa2BblfXjlr5RpNt7sSvTXwl2Y/bYVGgotLIzpgyl82bfJqUNm8UNs/ERiJFfk2lrxvjCkdy7u/3A== 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=qC6Dklo9EHAe/Bkvwz32hjcvQRPGmVWPJVRiVfz6rCA=; b=rDuWppefBqQU8W42y3Wwrk1lllkG9vWhWuKnygjeSAp46SvQ2+QDhMcxQpZ7wvz/asBUU397RrMzSEMzrDK+9fsYR7KXNeqDeJdiS44rsgpf07+Yb5mAb7KQ8lqnR8ZFchXpu4bzYbIY4Qo1o4hgW2XHx1QZCoWsx0rNUY7liRql6ZRZhRjDp8Yf+SvVThvV1ZcGCwQ5Ak1CU6srFPZ35EbA+5U+uOC/cSyEbvmhMf8XkPyRJC+zp4BvJoPWlq6GF1yJLx7yYaI3aRXXvXw3bXdKstw+OKRaWHl38UywZnj4Y9pZIKvzrtiaAslfSLDCteEDPKI9+BJbUCTmZdSRVQ== 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=qC6Dklo9EHAe/Bkvwz32hjcvQRPGmVWPJVRiVfz6rCA=; b=ohF8ZdbYaiwcjwUNT1raR0TqQIS0K6YwngLdm4cgjbGCAFKOL8zMskXDtnd3Jufia3Vl78g1elhRwGF+9yM7toEDBAzGam3iJBfrHejXRrvK7Mo+NwmXsXRDSzUpkHTVnHYCC4aAn+lq5mSMymxWx1laO0qA8MuN5bhhCelYFRc= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:50:30 +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.8251.015; Tue, 17 Dec 2024 01:50:30 +0000 Message-ID: <87ttb3m61m.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/6] ASoC: soc-core: Enable to use extra format on each DAI User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 17 Dec 2024 01:50:30 +0000 X-ClientProxiedBy: TYWPR01CA0038.jpnprd01.prod.outlook.com (2603:1096:400:17f::8) 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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: 363446d0-5cc5-48d6-5095-08dd1e3d2ff1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: K55ch8vVGkKQrIdI0YFtC2Tf5us8z1rHJnJxt/XTUXhA4xXgyBZjGLQ9yUDs3yMJWMpfj9srze6GLdu8r14b0DYJZIC63qU2up835t2sXtzIATKYvKPn7YvdI0kzJ6g3CXate1ncUxWNFb73PjikD3KlhQn+rKzNqTbVJPOAObk+OMfQnV5y6mhOZRBXItmrymjtF43HsbaQtHNuaejdM+kAlapoK3LTaiAeC8wEao0KOo8HInuuWZifl7u+vsK6xEjfuyjbljWgDnYZbwmulxVcJRLa9ZnjBUms6GTZLS7gZG3walVGHDMWCDvrfmJ+XARUIXCGa81hC+3NF3JLb1OXHSCvOUO7Akuj9yZCo0qbK0UpDocQQRTuBItYT/ThBgL/J+UJPcYRx+wL4OPRDLCeO9RFtB9O0xfGFk8int65fPnn3qZvVvcViZ309zV4lNXDGj3BLdKYno0MP97giQvQqDNJjvkom3/C0XCRLZqDxgvRhbRRNlLWUkZaD/ZEsB051g0PdnvHlDBAZtN0/GAbMRX3qEHkzdshE0HzQVGh3XfOHqhcA4fMLU3UJMIYe0yGObwK2+vX9iY8UHAWrQVdxAb1DiokSPvfA+pA8KijiTXU08EbZwAEMAYtZAgCPHAZhNfRQYKLy3S4tj8+/U72soJOIZa+53YfaLGSTnArbALmukZRM5BGuCpiXL7n8ygvrBp+9ZD0G0Zk2uJWn8CPF+Vyy8BZLnT4o1qgJ7PqNqKnfrhX06B17JenfqNe4C+AnzLZytbdK+dJbhgWHUBIeyj47gl0iYiEkwYYvWEN8M0yDlNXU/MPOiWnYG2VCsuXXx7boQ3AMxa5JPiSXlyqzWXVOi/QrEAQPBCmi8fKL9ZsWK7y9hrfO+WKwiSmrXeu+FYNCpzk1zeoaUNqUALA5yIu9kBGNirUsoPCDXFB9mZKMqpzlSxUXGmSmuF7ZKnb6UvIruoJI68fv0STnjneXIgHnLJnEhO3bcMd2McmFYw+JAN4QxUvuCiXHxhnSOmmmWOK9b68xCStRrNNejL0tp5bwt0nF3RHU7IllSCSE01R5LsKMCOUI4W6OaOTjibFQ9vK3CiEFoBHVvPYAnYXBTbxIOYP69gbgtckaEPm6je72SSiDV5gTmdrXxkg2IDbd05fwU2m73JOxwpFJ6WgUS9wp2kQXJY+vbY0u8k0j/iPVS00pPy3+NXDUQg3DmVrWLxeJZUqeqaGQzeOuOQh8b6dkMp7uu/FA2O6PJu1oN7hUmuR2xgWrMRBDStb5/m5IkdoMsbh+yRyH0mW9Qarhhe21vci4cLQZdSEhJF95agO0+cj7CCV9CZU8FcGUUCLYe0IBDaxaW3vE+4kY23E3zzGWNg04vLWq4hlQcPmPgAhNyawTGKFTrmGH6LdAAXd6Vic7AZ1OmcfqUKWRc0galx0cc9Mxr1v/yV1KC31AMXTbZ4tpyyinzKPwq9P 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aY2BFOUQWoc/bnfJMMCO+m01ozISKZ4nBhw/YIjGpYAa7GmYamJMjnPSfGxKUm5ekqzzw3Ed/k1BanQQv6jNXlH2OxnfNLbYVy2gUUC94tqFAvg0DljmsyMcfzmrx46/KTZCbuFp3M+fhlWrwx3a3r1V5Q/JqgM/pDPA4O1vi3rOK+r8IjIYqe4cPEsdznLu9ZhDgDz2xscCzySN/FhQfosbpCk1Zr8TE8SbqZNPhBo+J5tiuiHvyuN3qPqZa7HVPzg+m3uboq+GZYWKvxzL5wnbMAWbM9/H+Z2+5R8BGNfW8qTu+01Cb+R5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gTyrRkb6GcKOaH45iwY/h8kO5+XpSdObjveBbRl2SdVJ2cNGyJ0R/rBHXaQYsBM7aIF0jcVZZgRi+oeVev1+tcHTQ9uaffsuCUaY9PmjzeeCNDuu9dpQV2rqH54koapuavT6RwV3DiMaZKwcbI6W207jby3nwYVQqPFweFiYZmnQhZK6OJ+A/7sFVuY9qEUH/+0ebqfY2ylvj71viNtBP+LVFaAatICGmyYAf3vyON4GxFcDbLl5dn/aZq2M= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 363446d0-5cc5-48d6-5095-08dd1e3d2ff1 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:50:30.3602 (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: FbhsMz1x9p81K0CRZJNYTFpqz82j01Qc0O4+TVa/+6/rvu7K+BtNoPoqLI2zHbfUobAL1TUWhapj4n3H0MbIP0q4uunbq4DmlzW/r2cLDoOE83Pd/a2XUDWnxAyV0cL0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 Link: https://lore.kernel.org/r/5011ceef-5100-441d-b169-dabba135d27f@iinet.net.au 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 426f8d8baa38b..e067366f2a315 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 Tue Dec 17 01:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13910878 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010065.outbound.protection.outlook.com [52.101.228.65]) (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 A58A115AF6 for ; Tue, 17 Dec 2024 01:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400174; cv=fail; b=Z3d8krtfdkcbcsTPR9/ZTK3NdTQTqby/9SG9/CXuUqLSxw2UKg1jZRrmiDI2X9lSpTWP86asyyVexw22ujfCN8+/h57cDETwi6qHsr+s6lY6RMiTJ1bUiOmMPFtsqMouvCak1Q8tspsl/S5B3EU/HNnPB/ZjrDfbk7LODtIq/p4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734400174; c=relaxed/simple; bh=Gd/GBORinSQkxtk7j5JYVafvWbJjNbEYWZkgpb8glsA=; h=Message-ID:From:To:Cc:In-Reply-To:References:Subject:Content-Type: Date:MIME-Version; b=MzmX8ENAcgFsu49Zj41GvpON1pK8Ki/rxeOx2BQNWavNy0txcqRlbvksykFB82pj6CxHTcTXP+Roqub5Fg8M0XNxXNIDsGf3sQ3go43da2cD1WV4alV2/ZJ0dKtYH9OgHU0Zmq9SlghB8ijnOKqHfB8MSf4ombyhUErGqApB9bY= 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=k9q9gHew; arc=fail smtp.client-ip=52.101.228.65 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="k9q9gHew" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K9O8tMbEmjl6TFYCIxcdpz2RRC/m8cQfRx3wGCgQsVv4XqUnX866PMHMdrR/TujjyqPdEb3qLjsOqo9LWrj40xvUMZbgIj9dL/nGZjV+pNR/cTvqWis0O+07usYdjVj3tGdL9kPyv14On+icJX6aF7UaS8NL/esln/i8/5NpKkq+CyhDxSwivll49QND2hEZUwRXBxcoMQ3UkOBdPGn5mj54WNlG/frTxInqFXeB+T7bgPhWuclZb+w6x+FIxw3oBRITFF5nD1+8uYi3CfaYskhdceNCeTTPi+NPtUNGLX3Odbrj00acr9hdIrBycFT7hDLbG+T6uli9MueZlsPVtw== 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=p0gUNXIC9Lxos9dWK/7vbC3OJ/k0KCzZ3aM6iG6YJ9o=; b=fxv4yzrg5Aj18B/e98wXywuJy1nYWv/HgLnxcV/W/3EFvwT2xqTzAfSGFrvhVi5woEwq5o6p9QpTIw4FHTfZnbaKsycuL54cZSbjTtEy+lQ9CmREHBma3lYguY5LfIXder6F/4rkOmZzgwq2kcP7nPpZvf8puNZp9+gOi0L1mYHColauSvoNIb3/WK3WNBZnPXZP3vjpsiJKYV2VfcqHrstwccMUZrrPTx9K0CMsm4yA/gIsOg/wuwRPKA+5xi08i1mPKuO/ALMCCFxljVmdeeXPASfp08ufvrMltkDyldy5bXbjFNtTnP3yyg8EcpdXnsajML29iv2Nq/dAGRf+pA== 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=p0gUNXIC9Lxos9dWK/7vbC3OJ/k0KCzZ3aM6iG6YJ9o=; b=k9q9gHewQatGyNBBGEgh9dnw5WkrqdMT2vpc+2Cithz1hIVvavrGDg/8ledMVrsPi33Dk9CikH3igZ5PGzZva+aAl0elFzKbAt8b4solm+KppSwYTwGTvnzJs2Y+wMRfqbABXYx07Xf5EFcK85ISLSGV9ZqJZo3CEekjPRUglQY= 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 TYWPR01MB9279.jpnprd01.prod.outlook.com (2603:1096:400:1a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 01:49:30 +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.8251.015; Tue, 17 Dec 2024 01:49:30 +0000 Message-ID: <87v7vjm639.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Mark Brown Cc: linux-sound@vger.kernel.org, Stephen Gordon In-Reply-To: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> References: <8734innkpy.wl-kuninori.morimoto.gx@renesas.com> Subject: [PATCH 6/6] ASoC: audio-graph-card2: Use extra format on each DAI User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 Date: Tue, 17 Dec 2024 01:49:30 +0000 X-ClientProxiedBy: TYCP301CA0006.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:386::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_|TYWPR01MB9279:EE_ X-MS-Office365-Filtering-Correlation-Id: a8c4d65a-91ec-44cd-c82f-08dd1e3d0c6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: cKfhYxpCwF+y+8+yE/XLntB6N9pFKqs5cY0GHPgKm9yNoX6y59mpS9lug1pb7SMPWqulhA0hrPxuhDqd/R1jPqT04edEb5b27Llpp3JBLUE4VFSoNsKqEDO9RSR8qap0gkg1vp5JE9n4kUvUmMYMv1f5urg0+bcPbAl/wHwV9eTHANoPVgxljq9Ld13zGyy5ZciWkHeR7TbZkTgClQ/+i0DrWwyeJSBCyhDcW6GtBM3+SBCRUoQuXJ04ht/EAFrWLDhqNmHOY6ehsrgKAJfjJsV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zZJygOyIEJQxSm7kocWhfFEeIbD3+LWP6scdIJXQxDwCoVsA+tA4tfGcX3oAuvpvbQZzzlg6Nmgp+BaV08BwB7MZXCAtsh5+bmDWMn+wL4rC8Q8e 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)(1800799024)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mIWvc78H8t10G7gsdhTcu09E8M5XMAkkkH8ubL5AtKVTpIZqjXNwv2FFwp6GyTUzklnd7y9ttIl6UbAQbKPdgM1lYcXO2jA2Dz48C/HqZR+uD7k9ypQajJq2G8gd+hyWAVhxd1sj7V1zqsR82V/jgra9d+FtEnfF4VQ42A2KoC/KRU3W/hj0Q9FxnOBwAw4i5Ax2GIcvss5vF8pN11nNUa1rbyR2XGWxcpvXDgnPJxWYgWMxBDt1s4gOOHgfGU3BQV7UY2zeO05OkqKC+aW9UTo9lBqV4pa79LC4NTHNeoxyjOmFTsIDx07L1CRhQAqoRpHhtAf4CexPXH7tANMmhzWpuo64KgKicUjbI20qkaM5fa5EgydJc76bbICtUW+f78DoGFuvExAjLJiLNZmeVs7MilOBwIBCH1jngMs4QONEUifL2FOlUdKZBMKP4Kb5CI0WWvrXVcrYklNa1UZeCxTtHi6CA2Hsk6WtYFXGzVNPSWrGUm9FD/6xpFX4FcE+MC20HVLtxGsupSk7a8vWLXkzemPk9eVBa5VSSlU8Q9DFmkhdd8k7ZTorwI15MJEayIyXHXzVdlgQq0sPwPubr8IMfeZErKN18awm8sUGyLUNYVUn0Imvh6NAloVxrZ44WSd3zJCpkSVNaVZcdZalOLTXdpTxTqAdmljMDkq8+6oHXjkSMyAIkMwfxVC6XwECfjHsYcdfnzFMaPS/YVijDzu+OvTLzo5G5Lk9+90q2Y0H3gxf4As9UKxgrD9P2MvSIEmJiF/kZ/o4ou0BrOUpRdxtpwkkFjD57GzOXmycNqCf+s5tctOeszi7MopiVfuaD3bi3SdEowA4DGQVXPLVlVrdsUliQzae53uks5Cl5ABF58/YubwXYLzoCdLNtoVr6pZgHD9Cm4v4xpaVHvEKzY2yQ2a8M7XO4xam19ZDdqT1pdbX987X0+RWg+e/KaX8vD8sUngY6LCjT8sPzm8ghaWyZH75IfLXF8yvIPTu5m4Ff+aQhw0gcDMhoHZPoMQqECZEq2z/q6tOX43WWJtomH61qUH2Da5fF8y44CncSdmBn+K4p76le0QAeKMw2br1x9DcSWRN3jqo9W7xajz6MupuwWUZdYkSX5h2n6ICnLSdu/cYTdMFAe2UMndf5g/7ekoUtjvJ5v/LfCAAeOVs+C5u3siVXwxdGWiZlpllR69GEpUoKtQGG5i8v/+MvAHNxewn8tX9Mrwb4Fb43L3yvXqEKRQtBoQ42PstHlXGfrLZh6erq3xhtjFd6qBsBNzwjRkaVJU3VCDwlePAfuRskES2F7ECKXL89DuJNIhBlAufx3nVKMIr65WUSsxCE+Jo7djkWzKzIEhUCJXo5hwgXgo8bmrYeqmE1LH9lbLFujaDQLaI4lRSEyh60iTuQH2YJlbLFxCwGzk9VdKOibKUiFRh02X4VTXJXVK8Hgg2L3QU+kxn2gyzPYBFJ0ltlkKPw1oGV8cc0bBYbWv98fxLU2kN9Jk8tIIJjNFP1xnUvJ122T+uGXV0fARqaWlujey53kgPQeAu7YRA0KYpFwOBr/JsAzxAa+UZGhupIgVHxYeTnnMu8zZpNPbl8YQEE/J5uce3GRyk4Miet93UCYOB7LsM99edz8Y2FtVyfIALzIQ= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8c4d65a-91ec-44cd-c82f-08dd1e3d0c6a X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 01:49:30.7414 (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: sXCMbRLVpnrzW3lf6LEhB1u3UfjY0/AhfCKo0qygRukhwtsY8XizhsUStvWQYneZ2/8z6WKEXGDRCIjd5vO6/KBGAIwqrYs/yqqTQduN5BFcaadR7jmqt0s9qHr5cuzv X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9279 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 Link: https://lore.kernel.org/r/5011ceef-5100-441d-b169-dabba135d27f@iinet.net.au 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 079ae8a7bfff8..8c7c449dc6498 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_cpu); 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)