Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758949AbcJQIhB (ORCPT ); Mon, 17 Oct 2016 04:37:01 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:33872 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758490AbcJQIgp (ORCPT ); Mon, 17 Oct 2016 04:36:45 -0400 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="223078934" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Message-ID: <878ttn4bzc.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 14/23] of_graph: add of_graph_get_port_parent() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Rob Herring , Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , Laurent , Guennadi , Grant Likely , Frank Rowand , Linux-DT , Linux-Kernel In-Reply-To: <87shrv4c8x.wl%kuninori.morimoto.gx@renesas.com> References: <87shrv4c8x.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Mon, 17 Oct 2016 08:36:30 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0002.apcprd02.prod.outlook.com (10.164.90.140) To HK2PR0601MB1443.apcprd06.prod.outlook.com (10.165.182.149) X-MS-Office365-Filtering-Correlation-Id: 2626d654-b861-49b2-c319-08d3f668b212 X-Microsoft-Exchange-Diagnostics: 1;HK2PR0601MB1443;2:ODcduqr4JleskZwouHOp0TrkvnDs0EFdZC6GHO88BoDSeu9kwXuiRDak6lwe9I5/tz6a7PqqE8Y/Jp/Zf34j+ydLRpRGSDJBT0mmKi/qdkooNnIdsjdrvubsJCBtKI4amHtjzG8wHiZXgqBlihtjHS3JGK3SaUur9OFfc6SMYpRdttvwiPPFjZPteQqX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ipe8RjPA+FWGSAXmx4rsw9V45toWoHeNIra+YzDSPhlhNlpmGKc2Pt0kU3aEp9CdrJO1t+GEFIOOfLabVb7PgDVFuLQfRtPiPF1ogI8rFDxmix6XZaGF3gWpVWuoHLb4AZBy60dVJ+ERh62adihHVro/pKWvqr2zwlnu5G4z5lYlPBjPl7dJcRzHNV4iN2J6cjlm5iUp2sySb40zGEFPUKiRyJPRLsBGBhMqmB/yn8d+6OPWOX6TnbYUnv3GvOKj9xBWtMp5XO1HygrkCKKMlN5A6YP3uSIY9Nmb9VkjeSeyCFSKcbpb+Ix8DY80IlvN2c/1MRuNda8glZZ42Aesx8itvOyu4P2yaPGculHU2m/6o89qOexuf8N35i8U89KU5cvC5ZnOBcN47MnakdgmgMgmNoy7ZtByvqtvr4pbwLVAMxgkO85Z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026);SRVR:HK2PR0601MB1443;BCL:0;PCL:0;RULEID:;SRVR:HK2PR0601MB1443; X-Microsoft-Exchange-Diagnostics: 1;HK2PR0601MB1443;4:bkc3eDT6K0RJ0y6Q2EeGu2lSkZ/kkQ0V1GWU25nSHv2gtbsw7gXGEK1CYmsqSBkVsYH+rmLu8hGJ2lt1wpjZPyLZD01ULEx/o8PGJswgM419escCZL6bGO9k/Iyg0srchwDbIUpzg/RUXv+z1D3hNDFOpJ781uPdhqF760PF6GxJQMqZHfMWOjjttnunnukMIb8xKL+avhgw1++esohcBCqMRxtprHmRTiNbMZ/I7Nx7gdAzCg3XBwHjXixPjgSbafNMvptq/tgI0mgPqJYxNwViWhs3dNssIG5yDPXZ0BoB1NTj/tRrFaBgIFEJUPFhDywOvq56GNtCvpGYd73Z/V1hOmRUcXm95sSPG2VhiinhgA+mT7iFQveay0DkKcGjvrdQQGwzjVAcHjmDC0CreQ2HYWf9EoEWrouTcM5q1tY= X-Forefront-PRVS: 0098BA6C6C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(7416002)(53416004)(4001350100001)(46406003)(305945005)(6116002)(101416001)(3846002)(23726003)(586003)(83506001)(36756003)(2906002)(4326007)(92566002)(86362001)(81156014)(8666005)(50466002)(7846002)(81166006)(33646002)(8676002)(7736002)(68736007)(229853001)(47776003)(69596002)(66066001)(50986999)(19580405001)(19580395003)(76176999)(5001770100001)(5660300001)(54356999)(106356001)(97736004)(105586002)(77096005)(189998001)(2950100002)(42186005)(7059030)(16060500001);DIR:OUT;SFP:1102;SCL:1;SRVR:HK2PR0601MB1443;H:morimoto-PC.renesas.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HK2PR0601MB1443;23:afKGgelMVrLP0IYLJYmVjBvcjrzBcyF/k7uFucH?= =?us-ascii?Q?XWRx3e5V6xqWsNHPJYmurKb7SVDzSHsr/Pgh3hOXbnBj2wcsk3kFq8R7JRQZ?= =?us-ascii?Q?SZFp2zqx3KhMjcW+8/OoXgjkTjLNyMsTC2r3gn2FbjI5EDd/AXp6suId6D/i?= =?us-ascii?Q?YnOxf7v7k0SrSExVwUmXSJKmXTsDAEXDRC2r9wYKTnq4BMvnJaGqiSRfWOAA?= =?us-ascii?Q?AVCmDRWZC/A6CvMEk7g+BvKXb3JeBlvE8ZVmtnbCQ6y3zM0z6dfFdU2nOP8/?= =?us-ascii?Q?w9jdslUlMnpWh9AgeBlmXVLOdY2LBdJeDiHkhZ9kkBR3MUpjv8SscGoWP4uV?= =?us-ascii?Q?lWin2SP8qlyVToA+hmJc3w42wHPMU6vWsUy9bxmGZv004K3LC2BUxxN3XIDy?= =?us-ascii?Q?lyZuGI0Qe0gTCY6ITZMtuubsZT/D7/8MTzN47aMmdW07p18+s5FuyFAvqoWD?= =?us-ascii?Q?p4PuAMxQkbUAhKU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GNlIsBgG+j+RKIlgpdahXboPgmpgLDsdjCFMrHITzKPJQqtIauiHen6Nq7sQ2PSqs7ag0U5lf7nG/TmLn68JrGPSCc2dE/1vBsP8nTNRPOSnVc= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2016 08:36:30.5801 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1443 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2962 Lines: 92 From: Kuninori Morimoto Linux kernel already has of_graph_get_remote_port_parent(), but, sometimes we want to get own port parent. This patch adds of_graph_get_port_parent() Signed-off-by: Kuninori Morimoto --- drivers/of/base.c | 30 ++++++++++++++++++++++-------- include/linux/of_graph.h | 7 +++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index b035cff4..9d22391 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2370,6 +2370,27 @@ struct device_node *of_graph_get_remote_endpoint(const struct device_node *node) EXPORT_SYMBOL(of_graph_get_remote_endpoint); /** + * of_graph_get_port_parent() - get port's parent node + * @node: pointer to a local endpoint device_node + * + * Return: device node associated with endpoint node linked + * to @node. Use of_node_put() on it when done. + */ +struct device_node *of_graph_get_port_parent(struct device_node *node) +{ + unsigned int depth; + + /* Walk 3 levels up only if there is 'ports' node. */ + for (depth = 3; depth && node; depth--) { + node = of_get_next_parent(node); + if (depth == 2 && of_node_cmp(node->name, "ports")) + break; + } + return node; +} +EXPORT_SYMBOL(of_graph_get_port_parent); + +/** * of_graph_get_remote_port_parent() - get remote port's parent node * @node: pointer to a local endpoint device_node * @@ -2380,18 +2401,11 @@ struct device_node *of_graph_get_remote_port_parent( const struct device_node *node) { struct device_node *np; - unsigned int depth; /* Get remote endpoint node. */ np = of_graph_get_remote_endpoint(node); - /* Walk 3 levels up only if there is 'ports' node. */ - for (depth = 3; depth && np; depth--) { - np = of_get_next_parent(np); - if (depth == 2 && of_node_cmp(np->name, "ports")) - break; - } - return np; + return of_graph_get_port_parent(np); } EXPORT_SYMBOL(of_graph_get_remote_port_parent); diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 0a06441..0f362ed 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -53,6 +53,7 @@ struct device_node *of_graph_get_endpoint_by_regs( const struct device_node *parent, int port_reg, int reg); struct device_node *of_graph_get_remote_endpoint( const struct device_node *node); +struct device_node *of_graph_get_port_parent(struct device_node *node); struct device_node *of_graph_get_remote_port_parent( const struct device_node *node); struct device_node *of_graph_get_remote_port(const struct device_node *node); @@ -94,6 +95,12 @@ static inline struct device_node *of_graph_get_remote_endpoint( return NULL; } +static inline struct device_node *of_graph_get_port_parent( + struct device_node *node) +{ + return NULL; +} + static inline struct device_node *of_graph_get_remote_port_parent( const struct device_node *node) { -- 1.9.1