All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	Steen Hegelund <Steen.Hegelund@microchip.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count
Date: Tue, 16 Nov 2021 10:23:16 +0200	[thread overview]
Message-ID: <YZNqdLAAYVsMAGm2@kuha.fi.intel.com> (raw)
In-Reply-To: <20211116062328.1949151-16-colin.foster@in-advantage.com>

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@in-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

WARNING: multiple messages have this Message-ID (diff)
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	Steen Hegelund <Steen.Hegelund@microchip.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count
Date: Tue, 16 Nov 2021 10:23:16 +0200	[thread overview]
Message-ID: <YZNqdLAAYVsMAGm2@kuha.fi.intel.com> (raw)
In-Reply-To: <20211116062328.1949151-16-colin.foster@in-advantage.com>

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@in-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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-16  8:23 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16  6:23 [RFC PATCH v4 net-next 00/23] add support for VSC75XX control over SPI Colin Foster
2021-11-16  6:23 ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 01/23] net: dsa: ocelot: remove unnecessary pci_bar variables Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16 17:37   ` Florian Fainelli
2021-11-16 17:37     ` Florian Fainelli
2021-11-16  6:23 ` [RFC PATCH v4 net-next 02/23] net: mdio: mscc-miim: convert to a regmap implementation Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 03/23] net: dsa: ocelot: seville: utilize of_mdiobus_register Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16 11:21   ` Vladimir Oltean
2021-11-16 11:21     ` Vladimir Oltean
2021-11-16 23:51   ` Florian Fainelli
2021-11-16 23:51     ` Florian Fainelli
2021-11-16  6:23 ` [RFC PATCH v4 net-next 04/23] net: dsa: ocelot: felix: switch to mdio-mscc-miim driver for indirect mdio access Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 05/23] net: dsa: ocelot: felix: Remove requirement for PCS in felix devices Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 06/23] net: dsa: ocelot: felix: add interface for custom regmaps Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 07/23] net: dsa: ocelot: felix: add per-device-per-port quirks Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 08/23] net: mscc: ocelot: split register definitions to a separate file Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 09/23] net: mscc: ocelot: expose ocelot wm functions Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 10/23] pinctrl: ocelot: combine get resource and ioremap into single call Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 11/23] pinctrl: ocelot: update pinctrl to automatic base address Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16 17:36   ` Alexandre Belloni
2021-11-16 17:36     ` Alexandre Belloni
2021-11-17 13:47     ` Clément Léger
2021-11-17 13:47       ` Clément Léger
2021-11-19  2:16       ` Colin Foster
2021-11-19  2:16         ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 12/23] pinctrl: ocelot: convert pinctrl to regmap Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 13/23] pinctrl: ocelot: expose ocelot_pinctrl_core_probe interface Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-18 18:36   ` kernel test robot
2021-11-16  6:23 ` [RFC PATCH v4 net-next 14/23] pinctrl: microchip-sgpio: update to support regmap Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  8:23   ` Heikki Krogerus [this message]
2021-11-16  8:23     ` Heikki Krogerus
2021-11-16  6:23 ` [RFC PATCH v4 net-next 16/23] pinctrl: microchip-sgpio: change device tree matches to use nodes instead of device Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 17/23] pinctrl: microchip-sgpio: expose microchip_sgpio_core_probe interface Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-17 22:21   ` kernel test robot
2021-11-18  1:59   ` kernel test robot
2021-11-16  6:23 ` [RFC PATCH v4 net-next 18/23] net: phy: lynx: refactor Lynx PCS module to use generic phylink_pcs Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 19/23] net: dsa: felix: name change for clarity from pcs to mdio_device Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 20/23] net: dsa: seville: " Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 21/23] net: ethernet: enetc: " Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 22/23] net: pcs: lynx: use a common naming scheme for all lynx_pcs variables Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16  6:23 ` [RFC PATCH v4 net-next 23/23] net: dsa: ocelot: felix: add support for VSC75XX control over SPI Colin Foster
2021-11-16  6:23   ` Colin Foster
2021-11-16 10:34 ` [RFC PATCH v4 net-next 00/23] " Andy Shevchenko
2021-11-16 10:34   ` Andy Shevchenko
2021-11-16 15:04   ` Colin Foster
2021-11-16 15:04     ` Colin Foster
2021-11-16 17:05     ` Andy Shevchenko
2021-11-16 17:05       ` Andy Shevchenko
2021-11-16 11:10 ` Vladimir Oltean
2021-11-16 11:10   ` Vladimir Oltean
2021-11-16 15:32   ` Colin Foster
2021-11-16 15:32     ` Colin Foster
2021-11-16 17:41     ` Vladimir Oltean
2021-11-16 17:41       ` Vladimir Oltean
2021-11-16 22:56 ` Vladimir Oltean
2021-11-16 22:56   ` Vladimir Oltean
2021-11-16 23:44   ` Colin Foster
2021-11-16 23:44     ` Colin Foster
2021-11-16 23:47     ` Vladimir Oltean
2021-11-16 23:47       ` Vladimir Oltean
2021-11-19  1:58 ` Linus Walleij
2021-11-19  1:58   ` Linus Walleij
2021-11-19  2:14   ` Colin Foster
2021-11-19  2:14     ` Colin Foster
2021-11-21 23:59     ` Linus Walleij
2021-11-21 23:59       ` Linus Walleij
  -- strict thread matches above, loose matches on Subject: below --
2021-11-19  9:32 [RFC PATCH v4 net-next 04/23] net: dsa: ocelot: felix: switch to mdio-mscc-miim driver for indirect mdio access kernel test robot
2021-11-22 10:20 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZNqdLAAYVsMAGm2@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rafael@kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.