Re: [PATCH v2 10/13] kho: Update FDT dynamically for subtree addition/removal

Mike Rapoport
2025-11-15T09:40:17Z

On Fri, Nov 14, 2025 at 01:59:59PM -0500, Pasha Tatashin wrote:
> - struct kho_sub_fdt *sub_fdt;
> + phys_addr_t phys = virt_to_phys(fdt);
> + void *root_fdt = kho_out.fdt;
> + int err = -ENOMEM;
> + int off, fdt_err;
>
> - sub_fdt = kmalloc(sizeof(*sub_fdt), GFP_KERNEL);
> - if (!sub_fdt)
> - return -ENOMEM;
> + guard(mutex)(&kho_out.lock);
> +
> + fdt_err = fdt_open_into(root_fdt, root_fdt, PAGE_SIZE);
> + if (fdt_err < 0)
> + return err;
>
> - INIT_LIST_HEAD(&sub_fdt->l);
> - sub_fdt->name = name;
> - sub_fdt->fdt = fdt;
> + off = fdt_add_subnode(root_fdt, 0, name);

Why not
fdt_err = fdt_add_subnode()

as I asked in v1 review?

> + if (off < 0) {
> + if (off == -FDT_ERR_EXISTS)
> + err = -EEXIST;
> + goto out_pack;
> + }

--
Sincerely yours,
Mike.