From patchwork Thu Jan 18 12:31:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10173087 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 C6712603B5 for ; Thu, 18 Jan 2018 12:33:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAAEF2013C for ; Thu, 18 Jan 2018 12:33:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADC6A27C2D; Thu, 18 Jan 2018 12:33:34 +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 420062013C for ; Thu, 18 Jan 2018 12:33:34 +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=LsEycpDVi8ma5npt/kYXDJHO+ki1NGhNgsyiKXN4520=; b=P5V1YNpK+ABJHjRvThyIZsOEDj jLXdUGx5tgWYC/FrtfSE/SUF92vtGWOh2w31DVTiSU1JoNLkY8EdVpUKF75aI+j7U+OEdbtdPA2Xh M6DcMdjr/oG7tH3cDB+xFogXl2v60TiYstY4Nu38jLYvDNo1s1ZfXdWxIqSy61XGndtTbqGQDkke0 ysOZ1eb5ZlFnqAcOSpnzJwKQnwsDNUTsMnP6IKc4Ao34U8QNljqtWntBhoMIaSMxE/yamVOCmtb25 Qi+BXk4lLO+XWRbPu4EuLOjLrJCodjNCRZXaYwHHALfrjoD7Fodr4OLj8Lqy58D8C8Zsj8f7MjxxB B/GoFvUg==; 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 1ec9Nq-0002GA-J7; Thu, 18 Jan 2018 12:33:30 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ec9Ma-0000jW-Tj for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2018 12:32:20 +0000 Received: by mail-lf0-x244.google.com with SMTP id h92so16097358lfi.7 for ; Thu, 18 Jan 2018 04:32: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=vBmkeplZGJ674fNCPWmr8uNujjkRpmku1X/2YBkQu3s=; b=eqWpImkc/AiZNRxnXoWD0Ie6vu+KOWVk7oBpwnuX7FKAoJSFeanJmqMTr9YnRBGQ8i Ao6r9fQN7xST7+2M23qxATQPKlpJw5necEWcNK3gxQpI2TF1F0LHLZQRNIGEip1nd2q5 zMaK1/Tf1wuSMB+w+jhKbWpj7pqp6u17Ut9bhsB2TTyrUyJwMcxdqVm9k0iO6roPjLaG xvIizmD0V+1+/HXUH3KkFRRJ+rpuN8sZee5jqytBOIwexOn2EEv+mHrQfhu63WUC1IM0 ylev2WmLy6yEKI+Hs7ReFrhXkDhExVIjH4JlTaX8Tkua+PZdDJQpifKOVJllmkJ0ZdbD DEvg== 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=vBmkeplZGJ674fNCPWmr8uNujjkRpmku1X/2YBkQu3s=; b=N4as0ZO7W9x+MOrAyVGQYZ+YYYaNuaCBYiBtUYmM70PEKfRCiOI4DXJr9LQAdC1EC+ 7em6mQHiGgX8SccsPZ6yJaTjvUp323j69fDkM64FkJNZxtnTibWvZafB1RGLNaEIfXAB nAFNE32nAVoXL2b1bId/mF1NYWmI7IcQYcoXO/UIr4U4S4E5Q+iqp8WHFiTUsyyB2QW9 9gfJhqxJTN9l+efAakyqentaLU7c8czHTGZAmFKqGEVYX3XxYQIYf7HescQ+grrrIa14 yf2VMS7VwLb2FW+Y7NnUSCvzM+2vcPvzSu8OSRvp7qrfnFz3Y7qvsh1QKUs/MgsZd4Zx tyOg== X-Gm-Message-State: AKwxytfyLsMNkRjnSs+yDRRC8deS/0YVJEBANTcJW2/yJyGjA5TNCWlq 9O6lrG2ODx1hXYk4zvsSS6k3RQ== X-Google-Smtp-Source: ACJfBosC0tEsnz3hHEGPxc8PjQkPn6S2SWnKPI9Isjg5vm2yaTvZ/tJ8yaf33hH58WMLhkVzjkfZRw== X-Received: by 10.46.54.15 with SMTP id d15mr8921159lja.26.1516278724128; Thu, 18 Jan 2018 04:32: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 s23sm1303906ljs.1.2018.01.18.04.32.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jan 2018 04:32: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 v4 4/7] device property: Allow iterating over available child fwnodes Date: Thu, 18 Jan 2018 13:31:41 +0100 Message-Id: <1516278704-17141-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516278704-17141-1-git-send-email-mw@semihalf.com> References: <1516278704-17141-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 Acked-by: Rafael J. Wysocki --- 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 1d6c9d9..613ba82 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);