On Fri, Apr 28, 2023 at 08:09:06PM +0200, Uwe Kleine-König wrote: > Hello, > > On Wed, Apr 26, 2023 at 12:02:31PM +0200, Uwe Kleine-König wrote: > > -static int overlay_adjust_node_phandles(void *fdto, int node, > > - uint32_t delta) > > +static int overlay_adjust_node_phandles(void *fdto, int nodeo, > > + uint32_t delta, void *fdtbase, int basenode, uint32_t *phandlemap) > > { > > - int child; > > + int childo; > > int ret; > > + const fdt32_t *phandlebase; > > + int phandlebaselen; > > > > - ret = overlay_phandle_add_offset(fdto, node, "phandle", delta); > > - if (ret && ret != -FDT_ERR_NOTFOUND) > > - return ret; > > + /* > > + * If the base fdt has a phandle already reuse the value to not break > > + * references that already exist in the base fdt. > > + */ > > + if (fdtbase) { > > + phandlebase = fdt_getprop(fdtbase, basenode, "phandle", &phandlebaselen); > > + if (!phandlebase && phandlebaselen != -FDT_ERR_NOTFOUND) > > + return phandlebaselen; > > + if (!phandlebase) { > > + phandlebase = fdt_getprop(fdtbase, basenode, "linux,phandle", &phandlebaselen); > > + if (!phandlebase && phandlebaselen != -FDT_ERR_NOTFOUND) > > + return phandlebaselen; > > + } > > + if (phandlebase && phandlebaselen != sizeof(*phandlebase)) > > + return -FDT_ERR_BADPHANDLE; > > + } > > > > - ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta); > > - if (ret && ret != -FDT_ERR_NOTFOUND) > > - return ret; > > + if (fdtbase && phandlebase) { > > + ret = overlay_phandle_set(fdto, nodeo, "phandle", fdt32_to_cpu(*phandlebase), phandlemap); > > Compiling that on Ubuntu stable emits a warning here that phandlebase > might be uninitialized (see > https://github.com/ukleinek/dtc/actions/runs/4831386302/jobs/8608771064). > > While looking into that, I think the code is correct, but can be > simplified by using fdt_get_phandle() instead of open coding it. I'll > rework the code and test a bit more. So please don't apply this version > of the patch. Ok, will do. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature