Hi Marek, On Wed, 12 Jan 2022 at 15:24, Marek Behún <ka...@kernel.org> wrote: > > On Wed, 12 Jan 2022 13:04:08 -0700 > Simon Glass <s...@chromium.org> wrote: > > > Hi Marek, > > > > On Mon, 10 Jan 2022 at 03:46, Marek Behún <ka...@kernel.org> wrote: > > > > > > From: Marek Behún <marek.be...@nic.cz> > > > > > > Add macro fdt_for_each_node_by_compatible() to allow iterating over > > > fdt nodes by compatible string. > > > > > > Convert various usages of > > > off = fdt_node_offset_by_compatible(fdt, start, compat); > > > while (off > 0) { > > > code(); > > > off = fdt_node_offset_by_compatible(fdt, off, compat); > > > } > > > and similar, to > > > fdt_for_each_node_by_compatible(off, fdt, start, compat) > > > code(); > > > > > > Signed-off-by: Marek Behún <marek.be...@nic.cz> > > > Reviewed-by: Stefan Roese <s...@denx.de> > > > --- > > > Simon, as in v1, this applies on top of marvell/next and we have another > > > patch for marvell/next that depends on this. > > > Could we let him apply it there after it is reviewed? > > > Thanks. > > > > > > Changes since v1: > > > - removed extra space after macro name: > > > fdt_for_each_node_by_compatible (...) > > > to > > > fdt_for_each_node_by_compatible(...) > > > as requested by Stefan > > > --- > > > arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 9 ++------- > > > arch/arm/cpu/armv8/fsl-layerscape/icid.c | 5 +---- > > > arch/arm/mach-tegra/gpu.c | 5 +---- > > > arch/mips/mach-octeon/octeon_fdt.c | 11 ++--------- > > > arch/powerpc/cpu/mpc85xx/liodn.c | 9 ++------- > > > board/Marvell/octeon_ebb7304/board.c | 9 +++------ > > > board/congatec/cgtqmx8/spl.c | 7 ++----- > > > board/freescale/lx2160a/lx2160a.c | 5 +---- > > > common/fdt_support.c | 22 ++++++++-------------- > > > drivers/misc/fsl_portals.c | 6 +----- > > > drivers/net/fm/fdt.c | 3 +-- > > > drivers/pci/pcie_layerscape_fixup_common.c | 12 ++---------- > > > drivers/phy/marvell/comphy_a3700.c | 10 +++++----- > > > drivers/video/meson/simplefb_common.c | 7 ++----- > > > drivers/video/sunxi/simplefb_common.c | 5 ++--- > > > include/fdt_support.h | 6 ++++++ > > > 16 files changed, 41 insertions(+), 90 deletions(-) > > > > Reviewed-by: Simon Glass <s...@chromium.org> > > > > In general we should not be doing this sort of thing. There should be > > a driver for each string, so we don't need this kind of ad-hoc code. > > Dear Simon, > > you are right for when this is used for U-Boot functionality. > > But when we need to fixup devicetree for Linux, this is the right thing > to do. > > I need this macro for ft_board_setup().
Yes, understood. I think some sort of driver interface would be nice, perhaps using driver model. Another option would be to register handlers using the compatible string and have a function that works through those. See also the event series here: https://patchwork.ozlabs.org/project/uboot/list/?series=278607 https://lore.kernel.org/u-boot/20211228082854.1255732-1-...@chromium.org/ Regards, Simon