mbox series

[v1,0/4] leds: Introduce and use fwnode_get_child_node_count()

Message ID 20250310150835.3139322-1-andriy.shevchenko@linux.intel.com
Headers show
Series leds: Introduce and use fwnode_get_child_node_count() | expand

Message

Andy Shevchenko March 10, 2025, 2:54 p.m. UTC
This series was inspired during review of "Support ROHM BD79124 ADC" [1].
The three conversion patches are the examples of the new API in use.

Since the first two examples of LEDS, in case of posotove response it may
be routed via that tree and immutable branch/tag shared with others, e.g.,
IIO which Matti's series is targeting and might be dependent on. The USB
patch can be applied later separately, up to the respective maintainers.

Link: https://lore.kernel.org/r/cover.1741610847.git.mazziesaccount@gmail.com> [1]

Andy Shevchenko (4):
  device property: Split fwnode_get_child_node_count()
  leds: pwm-multicolor: Use fwnode_get_child_node_count()
  leds: ncp5623: Use fwnode_get_child_node_count()
  usb: typec: tcpm: Use fwnode_get_child_node_count()

 drivers/base/property.c                | 12 ++++++------
 drivers/leds/rgb/leds-ncp5623.c        |  5 ++---
 drivers/leds/rgb/leds-pwm-multicolor.c |  7 +++----
 drivers/usb/typec/tcpm/tcpm.c          |  6 ++----
 include/linux/property.h               |  7 ++++++-
 5 files changed, 19 insertions(+), 18 deletions(-)

Comments

Jonathan Cameron March 11, 2025, 9:54 a.m. UTC | #1
On Mon, 10 Mar 2025 16:54:53 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Since fwnode_get_child_node_count() was split from its device property
> counterpart, we may utilise it in the driver and drop custom implementation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/leds/rgb/leds-ncp5623.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/rgb/leds-ncp5623.c b/drivers/leds/rgb/leds-ncp5623.c
> index f18156683375..7c7d44623a9e 100644
> --- a/drivers/leds/rgb/leds-ncp5623.c
> +++ b/drivers/leds/rgb/leds-ncp5623.c
> @@ -155,9 +155,9 @@ static int ncp5623_probe(struct i2c_client *client)
>  	struct device *dev = &client->dev;
>  	struct fwnode_handle *mc_node, *led_node;
>  	struct led_init_data init_data = { };
> -	int num_subleds = 0;
>  	struct ncp5623 *ncp;
>  	struct mc_subled *subled_info;
> +	unsigned int num_subleds;
I have no idea what the scheme is for ordering here. My gut
feeling would have been to leave it in original location but it's
not something I feel strongly about.


Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

>  	u32 color_index;
>  	u32 reg;
>  	int ret;
> @@ -172,8 +172,7 @@ static int ncp5623_probe(struct i2c_client *client)
>  	if (!mc_node)
>  		return -EINVAL;
>  
> -	fwnode_for_each_child_node(mc_node, led_node)
> -		num_subleds++;
> +	num_subleds = fwnode_get_child_node_count(mc_node);
>  
>  	subled_info = devm_kcalloc(dev, num_subleds, sizeof(*subled_info), GFP_KERNEL);
>  	if (!subled_info) {