]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
backlight: 88pm860x_bl: Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Thu, 22 Aug 2024 06:25:46 +0000 (14:25 +0800)
committerLee Jones <lee@kernel.org>
Wed, 2 Oct 2024 12:46:34 +0000 (13:46 +0100)
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240822062546.3490076-1-ruanjinjie@huawei.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/88pm860x_bl.c

index 25e409bbb1a2e3241a97d885126a86a7c9e7ee50..720b5ada7fe850aff18231097359a0543c1be2e9 100644 (file)
@@ -151,7 +151,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev,
                                    struct pm860x_backlight_data *data,
                                    char *name)
 {
-       struct device_node *nproot, *np;
+       struct device_node *nproot;
        int iset = 0;
 
        nproot = of_get_child_by_name(pdev->dev.parent->of_node, "backlights");
@@ -159,14 +159,13 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev,
                dev_err(&pdev->dev, "failed to find backlights node\n");
                return -ENODEV;
        }
-       for_each_child_of_node(nproot, np) {
+       for_each_child_of_node_scoped(nproot, np) {
                if (of_node_name_eq(np, name)) {
                        of_property_read_u32(np, "marvell,88pm860x-iset",
                                             &iset);
                        data->iset = PM8606_WLED_CURRENT(iset);
                        of_property_read_u32(np, "marvell,88pm860x-pwm",
                                             &data->pwm);
-                       of_node_put(np);
                        break;
                }
        }