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: 862841 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="eqWpImkc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMk034KgMz9s72 for ; Thu, 18 Jan 2018 23:33:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755686AbeARMdh (ORCPT ); Thu, 18 Jan 2018 07:33:37 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43616 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755867AbeARMcF (ORCPT ); Thu, 18 Jan 2018 07:32:05 -0500 Received: by mail-lf0-f67.google.com with SMTP id o89so22306492lfg.10 for ; Thu, 18 Jan 2018 04:32:04 -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=P1dS0Sq0IRg8R+fp5AVs8WIQeCoj4lWx5bMR++Nm8n9SJDBpO3QxHn9Y6iYcbJq7UJ +eoTRK0GztQpjvKYDHtCwjMceaOggstlA5s2oepog5l6T/ClpqUfh2d2hmJHqejLNsKc iSyaRPEVOKtqtWUIMf6boSuhs8CCP/tShBWnDgesV3B7Gfg8nxeh0BpIeiZgjJqaaF8n alRvZCJ2lxLL8cifjm5kf0todRmP8IvEx4jXQ/bbbsmL4dl8ZF3y1Ju2oRVbsWl80eSj j8SAitvS+qcUKbzBclwmqfcZzX+lT6OrVBS2tCBmvpSzFXJZGHJqArMv/G9QO5nnODH4 LeOQ== X-Gm-Message-State: AKwxyteHXoI9Vk/9q5/H8XZ9teGFom0WngybdQF+jRFiuFDFqTl1vRiW Gy++6d36tgqOvAuMEacpBcBGwA== 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 Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com 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> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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);