From patchwork Wed Jan 17 16:55:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10170143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02858603B5 for ; Wed, 17 Jan 2018 16:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E423728533 for ; Wed, 17 Jan 2018 16:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D703728584; Wed, 17 Jan 2018 16:56:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5682728533 for ; Wed, 17 Jan 2018 16:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6Jq7msjYUKAOeK8uplFvp3tfIz+q3eTljeEMKvPKMXg=; b=JBpaWdSPrpoFCPnrvJpNo3xXkt mEZ1yBXDE88EGXaUgQddCjD6dxSF7/sBxbeVV306+aO/BQm7wLtvbQAJV2dsakuJTNYH00LhkFrsa yiLcNsNg/QRhcBh0QUhzZfINmfcPtuk3aA2qIZFNHfpAD9GGpPVtf217/6dIVUYOGKE3Qa5e9vzMl V+a7f1eWKMabWZO53D2eTqCJt8aGReBBwmNJFx80HNx8sgWmYctqtQYg8SPs/AaNsYsGAdPlpGNsm GRfqplOwr/3sGA9VrPZ2jjbjI8JHqZXHxpu9jkuM+xsst9mhxKUXd5YE9KsynqRKHbYhkJksWTqsY GS7MhZ3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebr0n-0005wH-1S; Wed, 17 Jan 2018 16:56:29 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebr0V-0005h0-Ty for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 16:56:13 +0000 Received: by mail-lf0-x243.google.com with SMTP id o89so18725597lfg.10 for ; Wed, 17 Jan 2018 08:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pxap/R5wa0XF20u/yQeInSOH0yKEnEjE91GRTWZpM9w=; b=pooGuAOOl4HqW5VyqETdROIjnzfG+30dvYyIJlb5raLD1XafllGmh9zYHy+eQbzsqJ iXIArqa54TRod+Mguz9I2Xs2MxuQPiVFU7cwAH8TbJqv/nuRbm93ieLiFusuSl6t+uXO NrsuJjQ6k7W6CeDgKMPvVPnKz3I2WLCmaiemsx1C1JXvpP0VfXQP58jpfy3dYVz8kZ1y Zde71uTrTYKGuJHSk3cL3hv3r0rUZS38YNu66JC5dtXRmSFQzM5AkL2CSZzU9mcDjZ11 0gZQ6Qj/DlPTwrUpoq9mFRzbpsD4mltenxQAvBF/eFLcbY+EhultDTOtI47WgXWnktSf syqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pxap/R5wa0XF20u/yQeInSOH0yKEnEjE91GRTWZpM9w=; b=AX+dKfR/FRdsUDLfUpU+12hpQNA91MCyCipXaMjdx2kHvykk8PmDj4XTv0DkWRMD8S E7rxtQumCFtUGsN19aLJCRVOby4y6Az7r9YwWZhevN3gLcurDFpwqPj2/kc5ELSZwwLv o1DunZ0QDVW0AO9frHmeKus9cxZtgU19/VvO+MtjXpsuuF9ATVf59yPEJYfJDymSgJvi Wk2YKueEz8fI60Vh/EKdwqrxqp/uleJvHudsjk3kzJskdqKJ/gPj2E2DPTMrMTabCT6S tgFI0f5IGTQKIh/X5GCyi9Py8yOvYWoOxj/pRd8zvpZqLqKs4uGB6JqTkKeqlD5K2OWr 6sjw== X-Gm-Message-State: AKwxytfTLofq8Ww2rIIbv0kRPOhdCDT8p/n5qqUtyvfEl8KpPts5KiFe C3yW1jNs7l6y3eBCDtvfWmyusA== X-Google-Smtp-Source: ACJfBosYfcM9QzmuKpYVRZwTxHMzRy2QSaxQAp9pP+pRQkxwEWgIi9Zg9fZJtnsgWqg8z+QPTGZhyw== X-Received: by 10.46.2.221 with SMTP id y90mr6312568lje.39.1516208164340; Wed, 17 Jan 2018 08:56:04 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:03 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [net-next: PATCH v3 4/7] device property: Allow iterating over available child fwnodes Date: Wed, 17 Jan 2018 17:55:43 +0100 Message-Id: <1516208146-4144-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, f.fainelli@gmail.com, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, jaz@semihalf.com, antoine.tenart@free-electrons.com, rafael.j.wysocki@intel.com, linux@armlinux.org.uk, nadavh@marvell.com, neta@marvell.com, tn@semihalf.com, gregory.clement@free-electrons.com, stefanc@marvell.com, mw@semihalf.com, davem@davemloft.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a new helper function fwnode_get_next_available_child_node(), which enables obtaining next enabled child fwnode, which works on a similar basis to OF's of_get_next_available_child(). This commit also introduces a macro, thanks to which it is possible to iterate over the available fwnodes, using the new function described above. Signed-off-by: Marcin Wojtas --- drivers/base/property.c | 26 ++++++++++++++++++++ include/linux/property.h | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index adb3893..2343906 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -998,6 +998,32 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode, EXPORT_SYMBOL_GPL(fwnode_get_next_child_node); /** + * fwnode_get_next_available_child_node - Return the next + * available child node handle for a node + * @fwnode: Firmware node to find the next child node for. + * @child: Handle to one of the node's child nodes or a %NULL handle. + */ +struct fwnode_handle * +fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode, + struct fwnode_handle *child) +{ + struct fwnode_handle *next_child = child; + + if (!fwnode) + return NULL; + + do { + next_child = fwnode_get_next_child_node(fwnode, next_child); + + if (!next_child || fwnode_device_is_available(next_child)) + break; + } while (next_child); + + return next_child; +} +EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node); + +/** * device_get_next_child_node - Return the next child node handle for a device * @dev: Device to find the next child node for. * @child: Handle to one of the device's child nodes or a null handle. diff --git a/include/linux/property.h b/include/linux/property.h index e05889f..5b0563a 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -83,11 +83,17 @@ struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_child_node( const struct fwnode_handle *fwnode, struct fwnode_handle *child); +struct fwnode_handle *fwnode_get_next_available_child_node( + const struct fwnode_handle *fwnode, struct fwnode_handle *child); #define fwnode_for_each_child_node(fwnode, child) \ for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ child = fwnode_get_next_child_node(fwnode, child)) +#define fwnode_for_each_available_child_node(fwnode, child) \ + for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ + child = fwnode_get_next_available_child_node(fwnode, child)) + struct fwnode_handle *device_get_next_child_node( struct device *dev, struct fwnode_handle *child);