From patchwork Tue May 28 05:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13676128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F1D5C25B78 for ; Tue, 28 May 2024 05:07:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8A71986F; Tue, 28 May 2024 07:07:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8A71986F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1716872858; bh=WYetgctdWBF+MonuetBJ98RHX2voXcw8m6pYRS/135o=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RQ0T0G/F3TaVJr/kskkzinrdh12yr0LWe1Sxi6wDYmqsS1Oy14sG1AWZSaaIbfrMT DvKSwxgZftwvSHP3ppwDOI/psbSazavLgD3PVDmUK2QqvjUWBxhSXW/0urlbLjt8sj RFYQcy/Rck6+boNSdB37wgIwu9oKt/IMaoW1ryKM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9FD7CF804B2; Tue, 28 May 2024 07:05:52 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A3CECF80698; Tue, 28 May 2024 07:05:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8E7EEF8063D; Tue, 28 May 2024 07:05:46 +0200 (CEST) Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazlp170110002.outbound.protection.outlook.com [IPv6:2a01:111:f403:c405::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 79F1EF8060F for ; Tue, 28 May 2024 07:05:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 79F1EF8060F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=oBrH9uBH ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=arDD9NFXGvZSO+1zHK4QsaA19gdgIrBR6hxR2gPsrMbCrJa9IGdiorIIGBWkiamdDEtSVDBB8KILyDC2y8Gz1kRFCuc+yrnFDpAOZfr29JQqq0xDXM2fJkbTPw4wx+RlH/DEeyryfaDij59UHswQATNA+PJ5l9sMjigwTA+IrLKig7qi6029KScXyyJY0Jk8hEp1zZ9XLmwmUejhBgMKx6XiKHR6SGKXWDGRjua2PL2savoN40X7r+4H1r1Mz3W5jEa8taiK36uDKzIsahhGHcvppXOg+JOu35nCbOdEOvC0x+J+FVJbPGetNxBv8bvXiENxwOLlpK8LgSVzmeUJkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0VMDQ5xlUDr8K/0ewxS9dq7J5ZcjZwEjCViONSdXYOE=; b=Ge2eXFaiO3ZayQwjEvAvMpTRv/HwkHWTaiYs8fkcpusap7i+/+j+Egl95Y1zwg9ifE2w/dQDoEQy7x7aVNrkc0TLmJ+4C9XKDiJgx68CWCvx9bEZ6pUBTIseGtxzBMBEcRxnzQ3L0+0dm02U/TQ5J/1Ltx+wAMSRZeMVgzjn17hWSzhHdwggIWMgzu1FJ04IaP3rbxh63dWhhxkNOhx07h8dMem0bx1k4iiUoGAcY7+fMtPqJuea8fj9AerkVMdcNyJxgejyRyuKsZyGEIOsGIapyc9NU0JYt5/jvW0hugWXT7Q0DUMB5zDL4dWd0K2y6nrseD9NGZHH7rzE/JA+GQ== 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=0VMDQ5xlUDr8K/0ewxS9dq7J5ZcjZwEjCViONSdXYOE=; b=oBrH9uBHc8EWvJc0eKvlXj9Ove+qVJsWvce0cxZNtiN8KGkUc4FFEfm738C0P+cDqifiAFIz6RbyDcZYu5ocbftFPpIkzkttWGPS+kb5FHfArBzuRWOGlEKbvIySuuN369pPaFJ3ExRGcRaap3AQimjPFQqKmxOryjf1ynAm8rA= 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 TYCPR01MB7090.jpnprd01.prod.outlook.com (2603:1096:400:c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Tue, 28 May 2024 05:05:36 +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.7611.030; Tue, 28 May 2024 05:05:36 +0000 Message-ID: <8734q2h6fz.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 06/11] ASoC: audio-graph-card: add ep_to_port() / port_to_ports() User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: Linux-ALSA In-Reply-To: <87bk4qh6h8.wl-kuninori.morimoto.gx@renesas.com> References: <87bk4qh6h8.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 28 May 2024 05:05:36 +0000 X-ClientProxiedBy: TYAPR01CA0075.jpnprd01.prod.outlook.com (2603:1096:404:2c::15) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB7090:EE_ X-MS-Office365-Filtering-Correlation-Id: 42dcd7fb-1fd1-447f-5aa6-08dc7ed3cf6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|52116005|366007|38350700005; X-Microsoft-Antispam-Message-Info: exY9sVU/3sxKZm3seHQL62P5XMwYcNr/2ecPC+/9CSNHGsWmrFpXNWWFsSO2O4IRPtlcNekl1yzZqfFfY3FDsSTul7tt+0+Y1tQzrYVIGIi7deyZwo8Iwm1VEH2EMuiumN3QkpKkrfsFl7M5euowpjOUtFMLGJbPLuXbRmmzhs/o16tgcSQxbMGqhMhxjC2AZn9odL/SfxKXS3TL7ITBs/tjyP+n9VQp+vV3daSDJYeDdAICtJeyVE/CGgFmcbH0mUN/wuloqw/120vvhvAzWqX11E/wXsczHfpe9KL9zsLXV3XtD/zLN4TO19xzvekDrWSYPNLGxQK4RMV4CEkBeOQEs6fIEAV5SReftUzA1psOjLU0/aArDZIS2Dqe3j0+p3HlHuGZRgqN1yi4mdJKHxOTvo39SfH3Ot93XReiBqvsVueErK/IiaLZlhQGjAe+4qJmQh/MbsClH8X9ntk9MqNV0PMxeU1Kk3T7ZS5qirX+HBRwPmiTKbOaFMmGzIcqAOBqD7K5oK1L/oSwKxPkTTfirL3sF25BAmqk93yXnGPyBTV3n5GG4lwTgkTK75QhKpnlq/EBBBuez52oF2rcyXMrT99fLyWnelRs1rU+5LNS4qZLH+pNbNMKgwT+V5MYK/hmeG+bUlDdT4g924iXL48gbbFTPzprnwGh4JogUzWQHwCf0OzkwUsePINFjBDg/xoS7nU0532gogAT9fkI29Jfvchg7jIwNHDddtOGyJ8cJGsPsiDEDqzRjTch1idRCCTDtu9Zzp46X5G1uFwLY5vDnDUPuHdInZ+3svBUEkspNv7l7qw47Add/oHo1k2B2QP1WTdrLVnvq5tEDvRtJlwt/LlIgwsnm+wkwcnV8stezFZv4/USiA2gdPC2rh3NbtlpJpU4DNymxxkLdy9LRk4KozM5hWX6MhjaLSxI6qgZu9SBcxk47tJf0bujxy4GRa9noZpqQeE8f+1PxePht6mFUn6IytiqQxtWy4mLCn7+P2PCX/55e0DcCKwgRHhUHiWq7AUZywFj380uIGL5w4v3IAkI1222sFNwpoTeMuBv4po3QLdKTk1XP/ggR37KXdx39TekAfYprpcHWidH8cjC5FvWJ1jjkwW+rmn+XBGLnN1kMmMt3ZrObRcSszqDNUGrGr9fpGrXnrT69hmEgAAZYPn1+/AusqLB8F6Lc1XSFao2rjchzC8AcgvdZerA4/0RkSiPjlwYGRbmwmkUtcm9V2Q3CLkt4k850E3LhLJQlGAzCop91suWfrid8RFaFNYJlzS7fNSNr59NW8Sj1sQf4fjkQMpiLC/J2ePdHxrCPhWfhivaE+Uqb4f+3K5p6YRE+qrE6zF7jPWBJKScgQ== 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:(13230031)(376005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-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IaDBsSHACW0597HzM/1VOHsFYcOP0oJzYXIgmrocyU4Xb6c6tLERwtWnFY65WXgRKk5FCGLQVg9dqMBXW6Vyba8OZ8G543uIUGwJvhV7/g+4XogZMwIdojwNQuYkwaQKjo8Fxg8posV+uaeMoohaU/4qzNfdt2p4yxJWe2gTkpLiz4fknUZEVGvbNUDg743JPoozIw2/MM9zAZau40wL3zWp3sXLUoKHcxIZEnoxYrolx9mFNp90Ifr1XfyWsW7H7fVLnR/Ze/7cv+oLjKgRETCtWKVKKY/gK7SaJ0+Uui3aWJYOlItIM4HjcISVGKRVPyV1vxon2puGG5IE7v5GeOrr70632cCM9DWP2fbHMxCi6TQC3qIXdqRvAXjPJ5Qq1UfD5aUkeKgyTdgAq3jcGh2jAgvKdCTYbec3gkxCxSL/zHHiwRyR8BDWEPchZP+2fAlt/U7JixeOO/0H1Jhnav1eYD/Os9XTup1/kNXxLma6/PrVc2Yo/u8fMmgU+1+Myj9PK/O0wYszYUSQDLuLLmWFqiQn6yhma7/K82xTXK49H6vcRek3q84SAOk6/hQUgt26FuMo8gtVcdiXmaZJw5PE5dQ0/ml4XrQuv2+6jSRGbo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42dcd7fb-1fd1-447f-5aa6-08dc7ed3cf6f X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2024 05:05:36.3814 (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: pa74cp8LBCQ92RS7ju0m6ZWUfCfI6SvwQudO/uz5oT3VmReYPXEiEDi4unDweCIqMVWh1tamQe4lezGnLUcIn7QQnOtearfFf6W2WBqspBlu6R6XLVHnT0XhX69tIIXJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB7090 Message-ID-Hash: FZKGZEBS4KUN25ANVF3ERSPIYMEWOD6M X-Message-ID-Hash: FZKGZEBS4KUN25ANVF3ERSPIYMEWOD6M X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Current audio-graph-card is using of_get_parent() to get "port" from "ep", or get "ports" from "port". But it is difficlut to understand, and "ports" might not exist. This patch adds ep_to_port() to get "port" from "ep", and port_to_ports() to get "ports" from "port". "ports" will be NULL if not exist. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 83e3ba773fbd6..552b94908cf7c 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -19,6 +19,18 @@ #define DPCM_SELECTABLE 1 +#define ep_to_port(ep) of_get_parent(ep) +static struct device_node *port_to_ports(struct device_node *port) +{ + struct device_node *ports = of_get_parent(port); + + if (!of_node_name_eq(ports, "ports")) { + of_node_put(ports); + return NULL; + } + return ports; +} + static int graph_outdrv_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) @@ -68,8 +80,8 @@ static void graph_parse_convert(struct device *dev, struct simple_util_data *adata) { struct device_node *top = dev->of_node; - struct device_node *port = of_get_parent(ep); - struct device_node *ports = of_get_parent(port); + 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); simple_util_parse_convert(top, NULL, adata); @@ -87,8 +99,8 @@ static void graph_parse_mclk_fs(struct device_node *top, struct device_node *ep, struct simple_dai_props *props) { - struct device_node *port = of_get_parent(ep); - struct device_node *ports = of_get_parent(port); + struct device_node *port = ep_to_port(ep); + struct device_node *ports = port_to_ports(port); of_property_read_u32(top, "mclk-fs", &props->mclk_fs); if (of_node_name_eq(ports, "ports")) @@ -231,8 +243,8 @@ 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 = of_get_parent(ep); - ports = of_get_parent(port); + port = ep_to_port(ep); + ports = port_to_ports(port); snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, "prefix"); if (of_node_name_eq(ports, "ports")) @@ -350,7 +362,7 @@ static int __graph_for_each_link(struct simple_util_priv *priv, /* get codec */ codec_ep = of_graph_get_remote_endpoint(cpu_ep); - codec_port = of_get_parent(codec_ep); + codec_port = ep_to_port(codec_ep); /* get convert-xxx property */ memset(&adata, 0, sizeof(adata));