lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZNqdLAAYVsMAGm2@kuha.fi.intel.com>
Date:   Tue, 16 Nov 2021 10:23:16 +0200
From:   Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:     Colin Foster <colin.foster@...advantage.com>
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-gpio@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Vladimir Oltean <vladimir.oltean@....com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Steen Hegelund <Steen.Hegelund@...rochip.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [RFC PATCH v4 net-next 15/23] device property: add helper
 function fwnode_get_child_node_count

On Mon, Nov 15, 2021 at 10:23:20PM -0800, Colin Foster wrote:
> Functions existed for determining the node count by device, but not by
> fwnode_handle. In the case where a driver could either be defined as a
> standalone device or a node of a different device, parsing from the root of
> the device might not make sense. As such, it becomes necessary to parse
> from a child node instead of the device root node.
> 
> Signed-off-by: Colin Foster <colin.foster@...advantage.com>
> ---
>  drivers/base/property.c  | 20 ++++++++++++++++----
>  include/linux/property.h |  1 +
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index f1f35b48ab8b..2ee675e1529d 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -845,19 +845,31 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
>  EXPORT_SYMBOL_GPL(fwnode_device_is_available);
>  
>  /**
> - * device_get_child_node_count - return the number of child nodes for device
> - * @dev: Device to cound the child nodes for
> + * fwnode_get_child_node_count - return the number of child nodes for the fwnode
> + * @fwnode: Node to count the childe nodes for
>   */
> -unsigned int device_get_child_node_count(struct device *dev)
> +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode)
>  {
>  	struct fwnode_handle *child;
>  	unsigned int count = 0;
>  
> -	device_for_each_child_node(dev, child)
> +	fwnode_for_each_child_node(fwnode, child)
>  		count++;
>  
>  	return count;
>  }
> +EXPORT_SYMBOL_GPL(fwnode_get_child_node_count);
> +
> +/**
> + * device_get_child_node_count - return the number of child nodes for device
> + * @dev: Device to count the child nodes for
> + */
> +unsigned int device_get_child_node_count(struct device *dev)
> +{
> +	struct fwnode_handle *fwnode = dev_fwnode(dev);
> +
> +	return fwnode_get_child_node_count(fwnode);
> +}
>  EXPORT_SYMBOL_GPL(device_get_child_node_count);
>  
>  bool device_dma_supported(struct device *dev)
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 88fa726a76df..6dc71029cfc5 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -122,6 +122,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode);
>  
>  int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
>  
> +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode);
>  unsigned int device_get_child_node_count(struct device *dev);

You can now make device_get_child_node_count() an inline function:

static inline unsigned int device_get_child_node_count(struct device *dev)
{
	return fwnode_get_child_node_count(dev_fwnode(dev));
}

thanks,

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ