Received: by 10.223.148.5 with SMTP id 5csp7361589wrq; Thu, 18 Jan 2018 04:39:16 -0800 (PST) X-Google-Smtp-Source: ACJfBotiJhRF4AvSBv8b95gZ38nyOUqNxyni7PpU/pJ7GHPUw/2guClBfjd3tXcqwLZ+Ym6LjALN X-Received: by 10.98.49.199 with SMTP id x190mr14132589pfx.1.1516279156728; Thu, 18 Jan 2018 04:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516279156; cv=none; d=google.com; s=arc-20160816; b=CjCWgeVo845dwVK7SCI4kh1N1XVY1xIBrin3FT081SoSDIfnFhXszOFyBynwklbtpb 9tXowM022rJTNBh3NpchCkZb04gmtY/hlG3lHDffpCmvM7d8dXXMKUnvhhkNQeqFNO5u B9w+O4ZDphYHbjIgG5rupI1rO+2/n0XMsLUMaAqQk/X183XlYTNFvFfOZU29AsxbQEYb 8eyTddMtl/fQSYelxwG9ElPlzuks03VuTDgD5enlILj2VPZ3zhtwgA7wb4UvMs6+r6iy 9FBqvPNK/hyKcJtv2zmjCWsf9RQBcIO3KG8DraM/+YqWhD5MJ/9qDzbfk2rlJ5og8zLx CBWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vBmkeplZGJ674fNCPWmr8uNujjkRpmku1X/2YBkQu3s=; b=kj8uhyd8SVp+LRHSFbomPQdlg+zUxocUxz5bmhmevBtDiYxIegp+7ajuM7rKQHd9Dv Mpwh1H0L/sFfgnP2LlOfktTyhpsLc217cEFcXNq4U6183Lv9xaf4rqjnU9ZXaQrM5zOq jJ5OkASs7g3TpdRH8Vl0b9x2d86lQoO9xDJlNqhQ3ej/8MHXY7KkQkp0CX3D+e0JwJX8 ylKaPbbZEvnQoLiat6vIJ8wMNP5xs5S/3iJesxMHNMW/Vb2eVgTVTWKIuKn5nUbV+BGv RsFQcMGcaiN+A9tlietAOIiFgj3oiTedptlPjm3OvMsQrgYxAcoVGsolMI3jmaGcBaJE h5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=eqWpImkc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si6705574pfl.272.2018.01.18.04.39.02; Thu, 18 Jan 2018 04:39:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=eqWpImkc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932490AbeARMdV (ORCPT + 99 others); Thu, 18 Jan 2018 07:33:21 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33157 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755674AbeARMcG (ORCPT ); Thu, 18 Jan 2018 07:32:06 -0500 Received: by mail-lf0-f68.google.com with SMTP id t139so11656358lff.0 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=CyTlhkCJWI8pQXdDR8+ZrDyf8t0zLTAMLqlbZvBm1YrV1+/TJ1JtVOkZ53J9lJ2tZY ckZOXVT8sO3i7Fjq7So074tERaZkHXOHvDuehDpSpwJmmwf/7pMwb9BwBiobJGQ9RHt1 FGm3dBOTu0tX25G60/jNfrs5c1WIuQCWobPCFU1hUVFvgW82mlluols+lsjVTr/2zwGU 3nhzBcrS1f8zpPvORjvEs1LtS/iZvcjmMzx6iiX+v8VukvWjgijzzwKmswIAmUjhj8TO ZN8mWWoUe3B26z1n4g5vXHN4EDe6Cv6zlYIPe08rAQKwiFlYYSL5Bia28qn8bXx7xL7B dPyw== X-Gm-Message-State: AKwxytel/27ZbSb2u1uQ/eIPwUpBKnjE0a0DW2ycuHl/vatLTwUWybgt g/Rt/BStoPj9ktraDKy36UbpDIBtHsg= 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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); -- 2.7.4