Re: [PATCH v3 2/6] ALSA: aoa: Use helper function for_each_child_of_node_scoped()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ai,

On Tue, 27 May 2025 at 12:52, Ai Chao <aichao@xxxxxxxxxx> wrote:
> The for_each_child_of_node_scoped() helper provides a scope-based
> clean-up functionality to put the device_node automatically.
>
> Signed-off-by: Ai Chao <aichao@xxxxxxxxxx>

Thanks for your patch!

> --- a/sound/aoa/soundbus/i2sbus/core.c
> +++ b/sound/aoa/soundbus/i2sbus/core.c
> @@ -155,7 +155,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
>                           struct device_node *np)
>  {
>         struct i2sbus_dev *dev;
> -       struct device_node *child, *sound = NULL;
> +       struct device_node *sound = NULL;
>         struct resource *r;
>         int i, layout = 0, rlen, ok = force;
>         char node_name[8];
> @@ -178,7 +178,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
>                 return 0;
>
>         i = 0;
> -       for_each_child_of_node(np, child) {
> +       for_each_child_of_node_scoped(np, child) {
>                 if (of_node_name_eq(child, "sound")) {
>                         i++;
>                         sound = child;

As people pointed out before, the original (and new) code is buggy,
as child is saved to sound, and the latter is used after this loop.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux