Received: by 10.223.176.46 with SMTP id f43csp3516677wra; Mon, 22 Jan 2018 16:06:12 -0800 (PST) X-Google-Smtp-Source: AH8x224lb9WJJ29uKBgvE4sMz+b2W8st1fvW5PeJ5gda1zCFF/9MJaDmPSf1rGrkc8AeOzb16Fkz X-Received: by 10.36.117.195 with SMTP id y186mr999079itc.111.1516665971923; Mon, 22 Jan 2018 16:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516665971; cv=none; d=google.com; s=arc-20160816; b=XUO8FifPWDM49FTuGXfaS7j+603BAOqxqSaGVw5f05PHRfUpOKmNytGyynr0iNZeHx P/+MkCbc/zRnLglYW0oPan+R835alrRvUlU+ANgiFJckr7oNRDoDZwWBJw7CryumqTyS 8lDzfCa9q/UVURXRDmgxU4m/eUiUySw6yImsfhef0u0L+/kDOqneFYnm8VN+RGC1fG+2 tNJylvnXbFKSsflJhgpTru7PLGm40pors9etgvbLtqjQGNp0x9KS67egB8JWA1t9f467 ajyxeycwmrMCCklq3ibAHIQqddjJZYwDO7w0VIB12IXzpeSQ06ygK4MQTfzVUXmLhqks 3UIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=pVGXNfgm4O2P/aZ4Zl8iZI75HYLizSzynbdlpiQGK90=; b=Gfm2LLEfAFChR0FPkET/wwf9HipzCLXT1jbSI6hr7ntyjBq4Eot/5zw+ISvpCZddbk t3lVQjsuI4e9R+rUbL87SA8/0GVMC4dalzHQdtI45FrVAtRch9bzv57x5zxrE4Hsi4Wq GkFJD8QX4v1jWWlUzzzctpkBFBO/6ISPYUEThXjKmIlKwFhttq2LR1aB/6DY2CBk0tFy h+0Hb3KlWMf7WUlItzZREPqn8EPG9VTLJsQ8TflXcevyt1xJZ9NiZxTVp8S0UmL+/sd4 cp0Hej7lcZxioIHlDkjpU+0fElP5mUgwB2c2wXnMQyW/sTrTlRk+tddIstHLRtRNOSf1 CltQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kao9gajq; 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 n100si7306998ioo.19.2018.01.22.16.05.59; Mon, 22 Jan 2018 16:06:11 -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=fail header.i=@gmail.com header.s=20161025 header.b=kao9gajq; 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 S1751290AbeAWAFa (ORCPT + 99 others); Mon, 22 Jan 2018 19:05:30 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:44809 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbeAWAF2 (ORCPT ); Mon, 22 Jan 2018 19:05:28 -0500 Received: by mail-ot0-f196.google.com with SMTP id t20so9144036ote.11; Mon, 22 Jan 2018 16:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=pVGXNfgm4O2P/aZ4Zl8iZI75HYLizSzynbdlpiQGK90=; b=kao9gajqAn6X9UbxVUdXAKoyexYp2l8UyRWybewRE6WMuhloYhtuBK30qSoM3wNh0T dk9qqjV9MxXErvaEr3V7PloLVBKQWvQhy4ZzYxOaJAfyP6M5gGx5z4/HD2X7XQJC8YXT exbhLiYATVn+KL7tRYUnb+QKCI4/7SLuXC7Kp0XkBTJ0b+DMrn6fjzCWcNXUDiYc2q0o fugVt1POdfzIgUE18yi9H+7KUIqao7uY8QL3hI4wCy8aej4Qyx7KBpgqzdsDyHCrZP1B NwqKngJamzMDeLpZbAEhiuAZD8QhK7B06CQNAuoPXEWllVnZHWjJq0t2DybNxHi4uWNs +FlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=pVGXNfgm4O2P/aZ4Zl8iZI75HYLizSzynbdlpiQGK90=; b=mPzGhGlo1/aHCShjZ1sLrjMO+6o3/aCFozGcma9iY5ZNKiU8ruuq8o8vsd3W06G22H oIajE1okKOm7eEm5AcIi494Hoaz9L6hZSMMpWaGtUJGxYJb22nCesWryIDaO1GVeFxer w5JjRshpC1RjzJlzK+ovm93N7BV5MeVMLzO1chnf1gel3E8II8jUPWkwlbTy+7M5/VAq T8fbxfNSSOo6JZcxMq0ba1J0euUBgscQ+xCOUcc0EbL4XBlgsbOka6bPschho5QayraQ bGp96IFBAxicrpWWC2eZm2pDefHZetdKSVpI1v7xXkkTWj7TweopNX+vuHCXD8IAwonS 1cLA== X-Gm-Message-State: AKwxytexZy87aNgpq9HRxe1m3kwcMxykevMnSRYpB/5+2wfaKvVEH05O CD7BqJoZ9C+YlHSXHSdKkZC9y/YPwQyFms0vwDE= X-Received: by 10.157.46.117 with SMTP id c50mr6146193otd.310.1516665927356; Mon, 22 Jan 2018 16:05:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.11.88 with HTTP; Mon, 22 Jan 2018 16:05:26 -0800 (PST) In-Reply-To: <1516278704-17141-5-git-send-email-mw@semihalf.com> References: <1516278704-17141-1-git-send-email-mw@semihalf.com> <1516278704-17141-5-git-send-email-mw@semihalf.com> From: "Rafael J. Wysocki" Date: Tue, 23 Jan 2018 01:05:26 +0100 X-Google-Sender-Auth: hTQGHl88CuoniJq9ZOqZgqliJuM Message-ID: Subject: Re: [net-next: PATCH v4 4/7] device property: Allow iterating over available child fwnodes To: Marcin Wojtas Cc: Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, ACPI Devel Maling List , Graeme Gregory , David Miller , Russell King - ARM Linux , Rafael Wysocki , Andrew Lunn , Florian Fainelli , Antoine Tenart , Thomas Petazzoni , Gregory Clement , stefanc@marvell.com, Nadav Haklai , Neta Zur Hershkovits , Ard Biesheuvel , jaz@semihalf.com, Tomasz Nowicki Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 1:31 PM, Marcin Wojtas wrote: > 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); > > --