]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: ncp5623: Use fwnode_get_child_node_count()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 10 Mar 2025 14:54:53 +0000 (16:54 +0200)
committerLee Jones <lee@kernel.org>
Thu, 10 Apr 2025 09:12:24 +0000 (10:12 +0100)
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>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20250310150835.3139322-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/rgb/leds-ncp5623.c

index f181566833758dcbf165492cbad6419b6c8b404d..7c7d44623a9e4fd5c251bc97e3ea5e3a7c3a2199 100644 (file)
@@ -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;
        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) {