[PATCH u-boot-dm v2] fdt_support: Add fdt_for_each_node_by_compatible() helper macro

Marek Behún kabel at kernel.org
Wed Jan 12 23:24:26 CET 2022


On Wed, 12 Jan 2022 13:04:08 -0700
Simon Glass <sjg at chromium.org> wrote:

> Hi Marek,
> 
> On Mon, 10 Jan 2022 at 03:46, Marek Behún <kabel at kernel.org> wrote:
> >
> > From: Marek Behún <marek.behun at 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.behun at nic.cz>
> > Reviewed-by: Stefan Roese <sr at 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 <sjg at 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().

Marek


More information about the U-Boot mailing list