From patchwork Tue Nov 16 06:23:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12692704 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B205CC433EF for ; Tue, 16 Nov 2021 06:52:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76D5661B2A for ; Tue, 16 Nov 2021 06:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 76D5661B2A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=in-advantage.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qF6B44LNBUMQsRpjX7S6tODPsMd7q7LFou/uOrxjBLU=; b=CvzkZAYRotSfxv qwXPi28PydMIIVyPqdgJjo7csBhnEe8/KImAYfAx26lJvACR7i45J112Sayd+xnk3/kajgz29OW7W mmzoZkYAHZYWJLeklA4O94KqAIBcw3vK6yJeADZ2P0otQaaCaNz99Q3MEr8KFcoeVbPIk+H5zQ/BY 8TXx37kSto7aujBSu4O195TKZZxgCdKqNlyMWJ4oLaSrUmFU1b4N5AlAIPbTYPAT/sSMAJoNmy0iL mVFmpAtKF2IMRCEPMgZsjJvy0sLAPpkOOlSxEiSI8enX8ih5m7MxB0G3ge2+1kyEwLpLDiP5st1fn 8FC5RCCc0NuVy1SHy5hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mms3x-000RMI-60; Tue, 16 Nov 2021 06:35:30 +0000 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmrsy-000Ns5-Dz for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 06:24:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FGRxlJu0mxigTl2L1oYii/73zsaTSr8J1+/bn22tK2y9xMssQv3MjaCh7F3rBE5xGTnm3a7zqr1NCj5bFoUNNZedo0NjlUzub1dnmksJbe0RwLHPS1RC77f8hiOGnGDzaeR0hi6Ivjsff1k+TL6OO4P9tHNU+thNbyXmIj/VEO2hSdmKGw25LCUD1KexEC2aOEM9P9B97A91BEsFvhyNWZuLLO3BUOVq3Pbhc6SYCCdXvXhctR5uOCHPviuPOrU+A/+6nMKiptyl25rlMi2vSwgiNBbyY+KzcNvkhvl6FSuY+PI8yVESUeGvvyN4dNhXaw5A34vU7gIhIXEPwyHVNg== 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=kLCR3kk57HMWQWKJr/cxoP2rkhaqsgktRFvEAjqD2dw=; b=UUq+zabbGuIt5yQ2ejVvAsONrcK+mbaM3lrduqujXKVRNhC7OYNukYJp4zeWqFQxyLFe0xTwFluHoVFwLIlvqtxr+FUGqPn/JltQ7MGupqo5quZZV7FStWbTrCIdw+rtMixom4FchlYW/XdNDox4D9+ap7bJ9EoU/ue19zEv4QKKjF+KQVTY4Ew99ySs0CjFyfLXail31jaJSHVVCN2YSbd3Sjp1uCf9iJR7H/nQamtb5/KRUllRIVu1eZW8Uzo28dKX32whFy9b5KoCTk1A4OHEl8KZuhLE/6J8YNxuT68OKATZQF0sYgUQ8xJpyrq33okS12W4x6W6GmQCAftlVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kLCR3kk57HMWQWKJr/cxoP2rkhaqsgktRFvEAjqD2dw=; b=hsVKjZU2GTiPwOaxfHxWFo5S4B/RRUn0u5njfJcrUDSleuqyANUk6P91LLmXGmPkMMG40Q5HB3Bj2YeNvei6nM2LlLEbzyhxb/td1JJByT6UiKBK70GrrwcR+ZHXTi5NS3pxAZeU2SoRgkl/Y1JdFwUgLtJV7QsTtsc1YBgSJRM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by CO1PR10MB4722.namprd10.prod.outlook.com (2603:10b6:303:9e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 06:23:54 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4690.026; Tue, 16 Nov 2021 06:23:54 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Ioana Ciornei , Heiner Kallweit , Russell King , Lars Povlsen , Steen Hegelund , Linus Walleij , Philipp Zabel , Heikki Krogerus , Andy Shevchenko Subject: [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count Date: Mon, 15 Nov 2021 22:23:20 -0800 Message-Id: <20211116062328.1949151-16-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116062328.1949151-1-colin.foster@in-advantage.com> References: <20211116062328.1949151-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 06:23:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9659ca47-02da-4602-919f-08d9a8c9a9c5 X-MS-TrafficTypeDiagnostic: CO1PR10MB4722: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9OqdySCrX8o3GnfoLJSmRjIBnOqXZtwgNLQjnbpt7G9WUJbnsOY2p/z/W3l7iM3LwEFjunF7l5BjtQsDvscBWpVy0jjuzNE9tyX8oyVsFt9s8t9eeKC+OvM72X4f5HSh+Q8Z2FO/nENK0R7nw3GJI25csDP4naGoBOMX9nWHZMyD33s7TqGypPeCiDx0zmz/ocWlZM/Oacme0YvSNs5SiEkuM92a7EO7qRqvbxIzlAUThP5Gat+FEZgUG84/BnvukwQ6fXW6hjI3xOGzNhJBGA2fnUej0j+m6rGbjVjQ85wpOBDVGTONW1OcWlFYEi04kHwxcQeKfpGECMuF3L+VXiKu8svmLqbhAyUVLjs6ylpBSOJgVB6r4Fv0Q/YJD7pC3nn+miVJY+Tyo1bWvHoUswy0ro6wiAElcoq/MiOzD8dyBBvcciVSFIMGbVi0rypxC+abhkmE5mGkJ+HAl+Q05/MbQFNFfxoXavkjnyP6xk0Tos/iLYOa3RjbWyWXbTeAQgQqKqIX2hvuvVRgi+N50FLAsPzuZ7PuSUSotHxD2Xg2Jpgweo3HXY0PfCbVe2+XxJ9ZLW3s8RT4w3kTu9/hjb8yrT/FrE1JpUl0BO4rpIcKVhkSvZajVDG2iSYhvcraqWAlj3IZUSwTXx3S1nYa3mWY/L1KwJVr6t7/+brawIU9xD/DTPB3aYtUpyjpW7R/eu65S35MRswBP+gmY5CSsQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(136003)(366004)(396003)(39840400004)(346002)(83380400001)(6666004)(54906003)(5660300002)(2906002)(7416002)(6486002)(44832011)(956004)(86362001)(2616005)(4326008)(316002)(508600001)(8676002)(186003)(6512007)(38100700002)(38350700002)(1076003)(8936002)(52116002)(26005)(6506007)(36756003)(66556008)(66476007)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Ant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wDrdzO9IRotSOhzI0YjxpgtBuBUdPyKeW9vGu2iqrk1muMoeMEy/Q+p4RNqPOWs7XG5HU3It8bGCqatrqrc9WdN8ratm+j1+Dv4yzie17DXPXhg2KrMGWLDwa9ODdKvlPMm9tifqHYp5KwlJL8SNimo3MyV0BS5aLiravBlYidndDFqsRQ3q0msO+yLJj2dCSC6ZL6T6a+J9dWxstBR5KttG1H64jG/uxkK4bDLczmNA2hDJwj4DKCMWY7ZwXMqZt6xxVUjs+bj3048zYC4k6/RURVrHv4ezPHlA0f0PUpkLVcRSOl2Kh1M0xbEyEybPdj8zHW8NY9HpCEBd3mrx55ME+w2Di6lyP6qLRW6lpMX2o81c2c1FQF9WBK2OVIDrvlF/U7C8y2ZQB74upeUhYqWLVYHElvGxTkhQYTT3phklaOVjm9MH8fRqJ9qdV9bIoLBCUnmpxkvMK8BteFEGHN/rvXENDF2WQ017TsWwbAU9tI9gW7FNKTTovN4ZZkOzsS2f3m92YnHf09XDjlbX2yRjiKeU3v8uz6PAWA+2mZ7JgJu3+OyuXY4wNWrUK0/tWMS8gC53PIekuOQKTYaV3nYpWc2vvXvc/8xO5gltIjMoiwRbGXjGnWKRQ+kaPt6jc= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9659ca47-02da-4602-919f-08d9a8c9a9c5 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 06:23:54.1605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: z3vh5eA5mUXQw5NhTuyR/JpDbff2V2nK/tNWFm5xW7++Dh2EZgODz0tKOej2awYeyEWUI01Vc3y1m+ZwHNff2JNFHMJNj8RYe8CCQhjMv7c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4722 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211115_222404_508336_BCA95E06 X-CRM114-Status: GOOD ( 14.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Functions existed for determining the node count by device, but not by fwnode_handle. In the case where a driver could either be defined as a standalone device or a node of a different device, parsing from the root of the device might not make sense. As such, it becomes necessary to parse from a child node instead of the device root node. Signed-off-by: Colin Foster --- drivers/base/property.c | 20 ++++++++++++++++---- include/linux/property.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f1f35b48ab8b..2ee675e1529d 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -845,19 +845,31 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode) EXPORT_SYMBOL_GPL(fwnode_device_is_available); /** - * device_get_child_node_count - return the number of child nodes for device - * @dev: Device to cound the child nodes for + * fwnode_get_child_node_count - return the number of child nodes for the fwnode + * @fwnode: Node to count the childe nodes for */ -unsigned int device_get_child_node_count(struct device *dev) +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode) { struct fwnode_handle *child; unsigned int count = 0; - device_for_each_child_node(dev, child) + fwnode_for_each_child_node(fwnode, child) count++; return count; } +EXPORT_SYMBOL_GPL(fwnode_get_child_node_count); + +/** + * device_get_child_node_count - return the number of child nodes for device + * @dev: Device to count the child nodes for + */ +unsigned int device_get_child_node_count(struct device *dev) +{ + struct fwnode_handle *fwnode = dev_fwnode(dev); + + return fwnode_get_child_node_count(fwnode); +} EXPORT_SYMBOL_GPL(device_get_child_node_count); bool device_dma_supported(struct device *dev) diff --git a/include/linux/property.h b/include/linux/property.h index 88fa726a76df..6dc71029cfc5 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -122,6 +122,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode); int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode); unsigned int device_get_child_node_count(struct device *dev); static inline bool device_property_read_bool(struct device *dev,