All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/26] dm: Preparation for enhanced of-platdata (part C)
@ 2020-12-19 17:39 ` Simon Glass
  0 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

At present various driver model data structures are accessed outside the
core driver mode code. This makes it harder to adjust how certain values
are stored, which is needed for of-platdata.

This series updates several a few more fields so that they are only
accessed via functions.

This series also includes some changes to sandbox and x86 drivers to get
them ready for the new of-platdata.

It is available at u-boot-dm/prepc-working


Simon Glass (26):
  sandbox: serial: Move priv into a header file
  sandbox: i2c: Move priv into a header file
  sandbox: Add a compatible string for spltest
  sandbox: Update dts files to reduce SPL size
  x86: apl: Move priv/plat structs to headers
  x86: Move priv/plat structs for intel_common to headers
  x86: spl: Move priv/plat structs to headers
  spi: Tidy up get/set of device node
  spi: Tweak a few strange SPI NOR features for of-platdata
  x86: apl: Use struct spi_nor instead of struct spi_flash
  dm: core: Move priv/plat structs for simple_bus to headers
  x86: sysreset: Move priv/plat structs to headers
  x86: apl: Adjust how the UART gets its platform data
  x86: coral: Remove unwanted nodes from SPL/TPL
  x86: Drop rtc from SPL
  dm: core: Split out alloc code into a new function
  dm: core: Rename sqq to seq_
  dm: core: Access device flags through functions
  dm: core: Rename device flags to indicate it is private
  dm: core: Rename dev_has_of_node() to dev_has_ofnode()
  dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  dm: core: Access device ofnode through functions
  dm: core: Rename device node to indicate it is private
  dm: core: Split out scanning code to dm_scan()
  dm: core: Allow the uclass list to move
  dm: core: Add logging when lists_bind_fdt() fails

 arch/arm/mach-stm32mp/pwr_regulator.c         |   2 +-
 arch/sandbox/dts/sandbox.dts                  |   4 +-
 arch/sandbox/dts/sandbox.dtsi                 |  11 +-
 arch/sandbox/include/asm/i2c.h                |  14 ++
 arch/sandbox/include/asm/serial.h             |  30 ++++
 arch/x86/cpu/apollolake/hostbridge.c          |  20 +--
 arch/x86/cpu/apollolake/pmc.c                 |   8 +-
 arch/x86/cpu/apollolake/spl.c                 |   2 +-
 arch/x86/cpu/apollolake/uart.c                |  43 +++---
 arch/x86/cpu/intel_common/itss.c              |  19 ---
 arch/x86/cpu/intel_common/p2sb.c              |   9 +-
 arch/x86/dts/chromebook_coral.dts             |  17 ++-
 arch/x86/dts/rtc.dtsi                         |   2 +-
 arch/x86/include/asm/arch-apollolake/gpio.h   |  18 +++
 .../include/asm/arch-apollolake/hostbridge.h  |  28 ++++
 arch/x86/include/asm/arch-apollolake/pmc.h    |  16 +++
 arch/x86/include/asm/arch-apollolake/uart.h   |  19 ++-
 arch/x86/include/asm/itss.h                   |  21 +++
 arch/x86/include/asm/p2sb.h                   |  18 +++
 arch/x86/include/asm/sysreset.h               |  18 +++
 board/synopsys/hsdk/clk-lib.c                 |   2 +-
 cmd/remoteproc.c                              |   2 +-
 drivers/ata/mtk_ahci.c                        |   3 +-
 drivers/clk/clk-uclass.c                      |   2 +-
 drivers/clk/clk.c                             |   2 +-
 drivers/clk/meson/axg.c                       |   2 +-
 drivers/clk/meson/g12a.c                      |   2 +-
 drivers/clk/meson/gxbb.c                      |   2 +-
 drivers/core/device-remove.c                  |  18 +--
 drivers/core/device.c                         | 135 ++++++++++--------
 drivers/core/devres.c                         |   4 +-
 drivers/core/dump.c                           |   6 +-
 drivers/core/lists.c                          |   2 +-
 drivers/core/root.c                           |  58 +++++---
 drivers/core/simple-bus.c                     |   7 +-
 drivers/core/uclass.c                         |  12 +-
 drivers/gpio/mpc8xxx_gpio.c                   |   4 +-
 drivers/gpio/octeon_gpio.c                    |   2 +-
 drivers/gpio/sandbox.c                        |   2 +-
 drivers/i2c/designware_i2c_pci.c              |   4 +-
 drivers/i2c/i2c-uclass.c                      |   2 +-
 drivers/i2c/sandbox_i2c.c                     |   5 +-
 drivers/misc/spltest_sandbox.c                |   6 +
 drivers/misc/swap_case.c                      |   2 +-
 drivers/mmc/octeontx_hsmmc.c                  |  25 ++--
 drivers/mmc/pci_mmc.c                         |   2 +-
 drivers/mtd/nand/raw/octeontx_nand.c          |   4 +-
 drivers/mtd/nand/spi/core.c                   |   2 +-
 drivers/mtd/spi/sf-uclass.c                   |   2 +-
 drivers/mtd/spi/sf_probe.c                    |   2 +-
 drivers/net/fm/eth.c                          |   4 +-
 drivers/net/fsl_enetc.c                       |   8 +-
 drivers/net/fsl_enetc_mdio.c                  |   2 +-
 drivers/net/mdio-ipq4019.c                    |   4 +-
 drivers/net/mdio_mux_i2creg.c                 |   2 +-
 drivers/net/mvmdio.c                          |   4 +-
 drivers/net/octeontx/smi.c                    |   2 +-
 drivers/net/tsec.c                            |   3 +-
 drivers/pci/pci-uclass.c                      |   8 +-
 drivers/phy/phy-ti-am654.c                    |   2 +-
 drivers/pinctrl/intel/pinctrl_apl.c           |  12 --
 drivers/pinctrl/pinctrl-uclass.c              |   4 +-
 drivers/power/domain/meson-ee-pwrc.c          |   4 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c      |   4 +-
 drivers/power/regulator/pbias_regulator.c     |   3 +-
 drivers/pwm/pwm-meson.c                       |   9 +-
 drivers/remoteproc/rproc-uclass.c             |   2 +-
 drivers/reset/reset-socfpga.c                 |   2 +-
 drivers/serial/sandbox.c                      |  16 +--
 drivers/serial/serial-uclass.c                |   2 +-
 drivers/spi/fsl_dspi.c                        |   6 +-
 drivers/spi/ich.c                             |  11 --
 drivers/spi/ich.h                             |  11 ++
 drivers/spi/spi-uclass.c                      |   2 +-
 drivers/sysreset/sysreset_sandbox.c           |   2 +-
 drivers/sysreset/sysreset_x86.c               |   5 +-
 drivers/tee/optee/core.c                      |   2 +-
 drivers/timer/timer-uclass.c                  |   2 +-
 drivers/usb/cdns3/core.c                      |   4 +-
 drivers/usb/dwc3/core.c                       |   2 +-
 drivers/usb/dwc3/dwc3-generic.c               |   6 +-
 drivers/usb/dwc3/dwc3-meson-g12a.c            |   2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c             |   2 +-
 drivers/usb/gadget/dwc2_udc_otg.c             |   4 +-
 drivers/usb/host/dwc3-octeon-glue.c           |   2 +-
 drivers/usb/host/dwc3-sti-glue.c              |   5 +-
 drivers/usb/host/ehci-mx6.c                   |   2 +-
 drivers/usb/host/usb-uclass.c                 |   4 +-
 drivers/usb/host/xhci-dwc3.c                  |   2 +-
 drivers/usb/mtu3/mtu3_core.c                  |   2 +-
 drivers/usb/mtu3/mtu3_plat.c                  |   4 +-
 drivers/usb/musb-new/ti-musb.c                |   2 +-
 drivers/video/nexell_display.c                |   2 +-
 drivers/video/rockchip/rk_mipi.c              |   2 +-
 include/asm-generic/global_data.h             |   8 +-
 include/dm/device-internal.h                  |   1 +
 include/dm/device.h                           |  74 ++++++++--
 include/dm/read.h                             |  18 +--
 include/dm/simple_bus.h                       |  15 ++
 include/linux/mtd/mtd.h                       |   9 +-
 include/linux/mtd/nand.h                      |  14 ++
 include/linux/mtd/spi-nor.h                   |   6 +-
 include/linux/mtd/spinand.h                   |  15 ++
 include/virtio.h                              |   2 +-
 net/mdio-mux-uclass.c                         |   2 +-
 net/mdio-uclass.c                             |   8 +-
 test/dm/bus.c                                 |  10 +-
 test/dm/core.c                                |  26 ++--
 test/dm/cpu.c                                 |   2 +-
 test/dm/pci.c                                 |   6 +-
 test/dm/test-fdt.c                            |  20 +--
 test/dm/virtio.c                              |   2 +-
 112 files changed, 655 insertions(+), 410 deletions(-)
 create mode 100644 arch/sandbox/include/asm/i2c.h
 create mode 100644 arch/sandbox/include/asm/serial.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/hostbridge.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/pmc.h
 create mode 100644 arch/x86/include/asm/p2sb.h
 create mode 100644 arch/x86/include/asm/sysreset.h
 create mode 100644 include/dm/simple_bus.h

-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 00/26] dm: Preparation for enhanced of-platdata (part C)
@ 2020-12-19 17:39 ` Simon Glass
  0 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Aaron Williams, Alexey Brodkin, Anatolij Gustschin,
	Andy Shevchenko, Baruch Siach, Bernhard Messerklinger, Bin Meng,
	Chunfeng Yun, Daniel Schwierzeck, Eugeniy Paltsev, Frank Wang,
	Frank Wunderlich, GSS_MTK_Uboot_upstream, Heiko Schocher,
	Heinrich Schuchardt, Jaehoon Chung, Jagan Teki,
	Jagannadha Sutradharudu Teki, Jens Wiklander, Joe Hershberger,
	Kever Yang, Ley Foon Tan, Lokesh Vutla, Luka Kovacic,
	Luka Perkov, Lukasz Majewski, Madalin Bucur, Marek Vasut,
	Masahiro Yamada, Michael Walle, Michal Simek, Neil Armstrong,
	Ovidiu Panait, Patrice Chotard, Patrick Delaunay, Pavel Herrmann,
	Peng Fan, Philipp Tomsich, Philippe Reynes, Priyanka Jain,
	Rasmus Villemoes, Rayagonda Kokatanur, Rick Chen, Robert Marko,
	Ryder Lee, Sean Anderson, Shivamurthy Shastri,
	Siva Durga Prasad Paladugu, Stefan Bosch, Stefan Roese,
	Sughosh Ganu, Suneel Garapati, Vignesh R, Walter Lozano,
	Weijie Gao, Wolfgang Wallner, Ye Li, hui.song, u-boot-amlogic,
	uboot-snps-arc, uboot-stm32

At present various driver model data structures are accessed outside the
core driver mode code. This makes it harder to adjust how certain values
are stored, which is needed for of-platdata.

This series updates several a few more fields so that they are only
accessed via functions.

This series also includes some changes to sandbox and x86 drivers to get
them ready for the new of-platdata.

It is available at u-boot-dm/prepc-working


Simon Glass (26):
  sandbox: serial: Move priv into a header file
  sandbox: i2c: Move priv into a header file
  sandbox: Add a compatible string for spltest
  sandbox: Update dts files to reduce SPL size
  x86: apl: Move priv/plat structs to headers
  x86: Move priv/plat structs for intel_common to headers
  x86: spl: Move priv/plat structs to headers
  spi: Tidy up get/set of device node
  spi: Tweak a few strange SPI NOR features for of-platdata
  x86: apl: Use struct spi_nor instead of struct spi_flash
  dm: core: Move priv/plat structs for simple_bus to headers
  x86: sysreset: Move priv/plat structs to headers
  x86: apl: Adjust how the UART gets its platform data
  x86: coral: Remove unwanted nodes from SPL/TPL
  x86: Drop rtc from SPL
  dm: core: Split out alloc code into a new function
  dm: core: Rename sqq to seq_
  dm: core: Access device flags through functions
  dm: core: Rename device flags to indicate it is private
  dm: core: Rename dev_has_of_node() to dev_has_ofnode()
  dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  dm: core: Access device ofnode through functions
  dm: core: Rename device node to indicate it is private
  dm: core: Split out scanning code to dm_scan()
  dm: core: Allow the uclass list to move
  dm: core: Add logging when lists_bind_fdt() fails

 arch/arm/mach-stm32mp/pwr_regulator.c         |   2 +-
 arch/sandbox/dts/sandbox.dts                  |   4 +-
 arch/sandbox/dts/sandbox.dtsi                 |  11 +-
 arch/sandbox/include/asm/i2c.h                |  14 ++
 arch/sandbox/include/asm/serial.h             |  30 ++++
 arch/x86/cpu/apollolake/hostbridge.c          |  20 +--
 arch/x86/cpu/apollolake/pmc.c                 |   8 +-
 arch/x86/cpu/apollolake/spl.c                 |   2 +-
 arch/x86/cpu/apollolake/uart.c                |  43 +++---
 arch/x86/cpu/intel_common/itss.c              |  19 ---
 arch/x86/cpu/intel_common/p2sb.c              |   9 +-
 arch/x86/dts/chromebook_coral.dts             |  17 ++-
 arch/x86/dts/rtc.dtsi                         |   2 +-
 arch/x86/include/asm/arch-apollolake/gpio.h   |  18 +++
 .../include/asm/arch-apollolake/hostbridge.h  |  28 ++++
 arch/x86/include/asm/arch-apollolake/pmc.h    |  16 +++
 arch/x86/include/asm/arch-apollolake/uart.h   |  19 ++-
 arch/x86/include/asm/itss.h                   |  21 +++
 arch/x86/include/asm/p2sb.h                   |  18 +++
 arch/x86/include/asm/sysreset.h               |  18 +++
 board/synopsys/hsdk/clk-lib.c                 |   2 +-
 cmd/remoteproc.c                              |   2 +-
 drivers/ata/mtk_ahci.c                        |   3 +-
 drivers/clk/clk-uclass.c                      |   2 +-
 drivers/clk/clk.c                             |   2 +-
 drivers/clk/meson/axg.c                       |   2 +-
 drivers/clk/meson/g12a.c                      |   2 +-
 drivers/clk/meson/gxbb.c                      |   2 +-
 drivers/core/device-remove.c                  |  18 +--
 drivers/core/device.c                         | 135 ++++++++++--------
 drivers/core/devres.c                         |   4 +-
 drivers/core/dump.c                           |   6 +-
 drivers/core/lists.c                          |   2 +-
 drivers/core/root.c                           |  58 +++++---
 drivers/core/simple-bus.c                     |   7 +-
 drivers/core/uclass.c                         |  12 +-
 drivers/gpio/mpc8xxx_gpio.c                   |   4 +-
 drivers/gpio/octeon_gpio.c                    |   2 +-
 drivers/gpio/sandbox.c                        |   2 +-
 drivers/i2c/designware_i2c_pci.c              |   4 +-
 drivers/i2c/i2c-uclass.c                      |   2 +-
 drivers/i2c/sandbox_i2c.c                     |   5 +-
 drivers/misc/spltest_sandbox.c                |   6 +
 drivers/misc/swap_case.c                      |   2 +-
 drivers/mmc/octeontx_hsmmc.c                  |  25 ++--
 drivers/mmc/pci_mmc.c                         |   2 +-
 drivers/mtd/nand/raw/octeontx_nand.c          |   4 +-
 drivers/mtd/nand/spi/core.c                   |   2 +-
 drivers/mtd/spi/sf-uclass.c                   |   2 +-
 drivers/mtd/spi/sf_probe.c                    |   2 +-
 drivers/net/fm/eth.c                          |   4 +-
 drivers/net/fsl_enetc.c                       |   8 +-
 drivers/net/fsl_enetc_mdio.c                  |   2 +-
 drivers/net/mdio-ipq4019.c                    |   4 +-
 drivers/net/mdio_mux_i2creg.c                 |   2 +-
 drivers/net/mvmdio.c                          |   4 +-
 drivers/net/octeontx/smi.c                    |   2 +-
 drivers/net/tsec.c                            |   3 +-
 drivers/pci/pci-uclass.c                      |   8 +-
 drivers/phy/phy-ti-am654.c                    |   2 +-
 drivers/pinctrl/intel/pinctrl_apl.c           |  12 --
 drivers/pinctrl/pinctrl-uclass.c              |   4 +-
 drivers/power/domain/meson-ee-pwrc.c          |   4 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c      |   4 +-
 drivers/power/regulator/pbias_regulator.c     |   3 +-
 drivers/pwm/pwm-meson.c                       |   9 +-
 drivers/remoteproc/rproc-uclass.c             |   2 +-
 drivers/reset/reset-socfpga.c                 |   2 +-
 drivers/serial/sandbox.c                      |  16 +--
 drivers/serial/serial-uclass.c                |   2 +-
 drivers/spi/fsl_dspi.c                        |   6 +-
 drivers/spi/ich.c                             |  11 --
 drivers/spi/ich.h                             |  11 ++
 drivers/spi/spi-uclass.c                      |   2 +-
 drivers/sysreset/sysreset_sandbox.c           |   2 +-
 drivers/sysreset/sysreset_x86.c               |   5 +-
 drivers/tee/optee/core.c                      |   2 +-
 drivers/timer/timer-uclass.c                  |   2 +-
 drivers/usb/cdns3/core.c                      |   4 +-
 drivers/usb/dwc3/core.c                       |   2 +-
 drivers/usb/dwc3/dwc3-generic.c               |   6 +-
 drivers/usb/dwc3/dwc3-meson-g12a.c            |   2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c             |   2 +-
 drivers/usb/gadget/dwc2_udc_otg.c             |   4 +-
 drivers/usb/host/dwc3-octeon-glue.c           |   2 +-
 drivers/usb/host/dwc3-sti-glue.c              |   5 +-
 drivers/usb/host/ehci-mx6.c                   |   2 +-
 drivers/usb/host/usb-uclass.c                 |   4 +-
 drivers/usb/host/xhci-dwc3.c                  |   2 +-
 drivers/usb/mtu3/mtu3_core.c                  |   2 +-
 drivers/usb/mtu3/mtu3_plat.c                  |   4 +-
 drivers/usb/musb-new/ti-musb.c                |   2 +-
 drivers/video/nexell_display.c                |   2 +-
 drivers/video/rockchip/rk_mipi.c              |   2 +-
 include/asm-generic/global_data.h             |   8 +-
 include/dm/device-internal.h                  |   1 +
 include/dm/device.h                           |  74 ++++++++--
 include/dm/read.h                             |  18 +--
 include/dm/simple_bus.h                       |  15 ++
 include/linux/mtd/mtd.h                       |   9 +-
 include/linux/mtd/nand.h                      |  14 ++
 include/linux/mtd/spi-nor.h                   |   6 +-
 include/linux/mtd/spinand.h                   |  15 ++
 include/virtio.h                              |   2 +-
 net/mdio-mux-uclass.c                         |   2 +-
 net/mdio-uclass.c                             |   8 +-
 test/dm/bus.c                                 |  10 +-
 test/dm/core.c                                |  26 ++--
 test/dm/cpu.c                                 |   2 +-
 test/dm/pci.c                                 |   6 +-
 test/dm/test-fdt.c                            |  20 +--
 test/dm/virtio.c                              |   2 +-
 112 files changed, 655 insertions(+), 410 deletions(-)
 create mode 100644 arch/sandbox/include/asm/i2c.h
 create mode 100644 arch/sandbox/include/asm/serial.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/hostbridge.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/pmc.h
 create mode 100644 arch/x86/include/asm/p2sb.h
 create mode 100644 arch/x86/include/asm/sysreset.h
 create mode 100644 include/dm/simple_bus.h

-- 
2.29.2.684.gfbc64c5ab5-goog


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 01/26] sandbox: serial: Move priv into a header file
  2020-12-19 17:39 ` Simon Glass
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  2020-12-21 11:38   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  -1 siblings, 2 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

Move this struct into a header file so that dtoc can include it in its
dt-platdata.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/include/asm/serial.h | 30 ++++++++++++++++++++++++++++++
 drivers/serial/sandbox.c          | 16 +---------------
 2 files changed, 31 insertions(+), 15 deletions(-)
 create mode 100644 arch/sandbox/include/asm/serial.h

diff --git a/arch/sandbox/include/asm/serial.h b/arch/sandbox/include/asm/serial.h
new file mode 100644
index 00000000000..bc82aebd0ea
--- /dev/null
+++ b/arch/sandbox/include/asm/serial.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __asm_serial_h
+#define __asm_serial_h
+
+#include <dt-structs.h>
+
+struct sandbox_serial_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_sandbox_serial dtplat;
+#endif
+	int colour;	/* Text colour to use for output, -1 for none */
+};
+
+/**
+ * struct sandbox_serial_priv - Private data for this driver
+ *
+ * @buf: holds input characters available to be read by this driver
+ */
+struct sandbox_serial_priv {
+	struct membuff buf;
+	char serial_buf[16];
+	bool start_of_line;
+};
+
+#endif /* __asm_serial_h */
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index a05c56458b0..19368ba2560 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -17,25 +17,11 @@
 #include <serial.h>
 #include <video.h>
 #include <linux/compiler.h>
+#include <asm/serial.h>
 #include <asm/state.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct sandbox_serial_plat {
-	int colour;	/* Text colour to use for output, -1 for none */
-};
-
-/**
- * struct sandbox_serial_priv - Private data for this driver
- *
- * @buf: holds input characters available to be read by this driver
- */
-struct sandbox_serial_priv {
-	struct membuff buf;
-	char serial_buf[16];
-	bool start_of_line;
-};
-
 /**
  * output_ansi_colour() - Output an ANSI colour code
  *
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 02/26] sandbox: i2c: Move priv into a header file
  2020-12-19 17:39 ` Simon Glass
  (?)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

Move this struct into a header file so that dtoc can include it in its
dt-platdata.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/include/asm/i2c.h | 14 ++++++++++++++
 drivers/i2c/sandbox_i2c.c      |  5 +----
 2 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 arch/sandbox/include/asm/i2c.h

diff --git a/arch/sandbox/include/asm/i2c.h b/arch/sandbox/include/asm/i2c.h
new file mode 100644
index 00000000000..b482be485ca
--- /dev/null
+++ b/arch/sandbox/include/asm/i2c.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __asn_i2c_h
+#define __asn_i2c_h
+
+struct sandbox_i2c_priv {
+	bool test_mode;
+};
+
+#endif /* __asn_i2c_h */
diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index a61dfc096b3..c99e6de9332 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -10,15 +10,12 @@
 #include <errno.h>
 #include <i2c.h>
 #include <log.h>
+#include <asm/i2c.h>
 #include <asm/test.h>
 #include <dm/acpi.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 
-struct sandbox_i2c_priv {
-	bool test_mode;
-};
-
 static int get_emul(struct udevice *dev, struct udevice **devp,
 		    struct dm_i2c_ops **opsp)
 {
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 03/26] sandbox: Add a compatible string for spltest
  2020-12-19 17:39 ` Simon Glass
                   ` (2 preceding siblings ...)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

At present this driver does not have a compatible string. For it to be
used with the coming of-platadata, it must have one. Update it
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/spltest_sandbox.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/spltest_sandbox.c b/drivers/misc/spltest_sandbox.c
index 3ae6707593e..6b9701a06ae 100644
--- a/drivers/misc/spltest_sandbox.c
+++ b/drivers/misc/spltest_sandbox.c
@@ -8,8 +8,14 @@
 #include <dm.h>
 #include <dt-structs.h>
 
+static const struct udevice_id sandbox_spl_ids[] = {
+	{ .compatible = "sandbox,spl-test", },
+	{}  /* sentinel */
+};
+
 U_BOOT_DRIVER(sandbox_spl_test) = {
 	.name	= "sandbox_spl_test",
 	.id	= UCLASS_MISC,
+	.of_match = sandbox_spl_ids,
 	.flags	= DM_FLAG_PRE_RELOC,
 };
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 04/26] sandbox: Update dts files to reduce SPL size
  2020-12-19 17:39 ` Simon Glass
                   ` (3 preceding siblings ...)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

At present there are require a few devices in the devicetree which are
not actually used in SPL. This will cause problems with the new
of-platdata, since it will try to instantiate devices which are not
compiled into U-Boot.

Update the devicetree to remove these devices from SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox.dts  |  4 ++--
 arch/sandbox/dts/sandbox.dtsi | 11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 8b50a402898..a8938a3accb 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -41,7 +41,7 @@
 
 	cros_ec: cros-ec {
 		reg = <0 0>;
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		compatible = "google,cros-ec-sandbox";
 	};
 
@@ -83,7 +83,7 @@
 	};
 
 	spi: spi at 0 {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		#address-cells = <1>;
 		#size-cells = <0>;
 		reg = <0 0>;
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7b4fc94495a..d842f021760 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -56,7 +56,7 @@
 	};
 
 	gpio_a: gpios at 0 {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		gpio-controller;
 		compatible = "sandbox,gpio";
 		#gpio-cells = <1>;
@@ -65,7 +65,7 @@
 	};
 
 	gpio_b: gpios at 1 {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		gpio-controller;
 		compatible = "sandbox,gpio";
 		#gpio-cells = <2>;
@@ -120,7 +120,7 @@
 	};
 
 	lcd {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		compatible = "sandbox,lcd-sdl";
 		xres = <1366>;
 		yres = <768>;
@@ -209,7 +209,7 @@
 
 	spi at 0 {
 		firmware_storage_spi: flash at 0 {
-			u-boot,dm-pre-reloc;
+			u-boot,dm-pre-proper;
 			reg = <0>;
 			compatible = "spansion,m25p16", "jedec,spi-nor";
 			spi-max-frequency = <40000000>;
@@ -278,7 +278,6 @@
 	};
 
 	tpm {
-		u-boot,dm-pre-reloc;
 		compatible = "google,sandbox-tpm";
 	};
 
@@ -415,6 +414,6 @@
 	};
 
 	keyboard-controller {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 	};
 };
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 05/26] x86: apl: Move priv/plat structs to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (4 preceding siblings ...)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/hostbridge.c          | 20 +------------
 arch/x86/cpu/apollolake/pmc.c                 |  8 +-----
 arch/x86/include/asm/arch-apollolake/gpio.h   | 18 ++++++++++++
 .../include/asm/arch-apollolake/hostbridge.h  | 28 +++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/pmc.h    | 16 +++++++++++
 drivers/pinctrl/intel/pinctrl_apl.c           | 12 --------
 6 files changed, 64 insertions(+), 38 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-apollolake/hostbridge.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/pmc.h

diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c
index 9ec2309d086..9decab7aa33 100644
--- a/arch/x86/cpu/apollolake/hostbridge.c
+++ b/arch/x86/cpu/apollolake/hostbridge.c
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 #include <asm/pci.h>
 #include <asm/arch/acpi.h>
+#include <asm/arch/hostbridge.h>
 #include <asm/arch/systemagent.h>
 #include <dt-bindings/sound/nhlt.h>
 #include <dm/acpi.h>
@@ -41,25 +42,6 @@ enum {
 	TOLUD			= 0xbc,
 };
 
-/**
- * struct apl_hostbridge_plat - platform data for hostbridge
- *
- * @dtplat: Platform data for of-platdata
- * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1)
- * @early_pads_count: Number of pads to process
- * @pciex_region_size: BAR length in bytes
- * @bdf: Bus/device/function of hostbridge
- */
-struct apl_hostbridge_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_intel_apl_hostbridge dtplat;
-#endif
-	u32 *early_pads;
-	int early_pads_count;
-	uint pciex_region_size;
-	pci_dev_t bdf;
-};
-
 #if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 static const struct nhlt_format_config dmic_1ch_formats[] = {
 	/* 48 KHz 16-bits per sample. */
diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index e033baf1205..e23d38ea072 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -16,6 +16,7 @@
 #include <acpi/acpi_s3.h>
 #include <asm/io.h>
 #include <asm/pci.h>
+#include <asm/arch/pmc.h>
 #include <linux/bitops.h>
 #include <power/acpi_pmc.h>
 
@@ -53,13 +54,6 @@ enum {
 	CF9_GLB_RST	= 1 << 20,
 };
 
-struct apl_pmc_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_intel_apl_pmc dtplat;
-#endif
-	pci_dev_t bdf;
-};
-
 static int apl_pmc_fill_power_state(struct udevice *dev)
 {
 	struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev);
diff --git a/arch/x86/include/asm/arch-apollolake/gpio.h b/arch/x86/include/asm/arch-apollolake/gpio.h
index ab5860c0fd0..762160da882 100644
--- a/arch/x86/include/asm/arch-apollolake/gpio.h
+++ b/arch/x86/include/asm/arch-apollolake/gpio.h
@@ -485,4 +485,22 @@
 /* This is needed by ACPI */
 #define GPIO_NUM_PAD_CFG_REGS   2 /* DW0, DW1 */
 
+#ifndef __ASSEMBLY__
+
+#include <dt-structs.h>
+
+/**
+ * struct apl_gpio_plat - platform data for each device
+ *
+ * @dtplat: of-platdata data from C struct
+ */
+struct apl_gpio_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	/* Put this first since driver model will copy the data here */
+	struct dtd_intel_apl_pinctrl dtplat;
+#endif
+};
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* _ASM_ARCH_GPIO_H_ */
diff --git a/arch/x86/include/asm/arch-apollolake/hostbridge.h b/arch/x86/include/asm/arch-apollolake/hostbridge.h
new file mode 100644
index 00000000000..f4dce0d5224
--- /dev/null
+++ b/arch/x86/include/asm/arch-apollolake/hostbridge.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef _ASM_ARCH_HOSTBRIDGE_H_
+#define _ASM_ARCH_HOSTBRIDGE_H_
+
+/**
+ * struct apl_hostbridge_plat - platform data for hostbridge
+ *
+ * @dtplat: Platform data for of-platdata
+ * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1)
+ * @early_pads_count: Number of pads to process
+ * @pciex_region_size: BAR length in bytes
+ * @bdf: Bus/device/function of hostbridge
+ */
+struct apl_hostbridge_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_intel_apl_hostbridge dtplat;
+#endif
+	u32 *early_pads;
+	int early_pads_count;
+	uint pciex_region_size;
+	pci_dev_t bdf;
+};
+
+#endif /* _ASM_ARCH_HOSTBRIDGE_H_ */
diff --git a/arch/x86/include/asm/arch-apollolake/pmc.h b/arch/x86/include/asm/arch-apollolake/pmc.h
new file mode 100644
index 00000000000..23ac8fe7e20
--- /dev/null
+++ b/arch/x86/include/asm/arch-apollolake/pmc.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef ASM_ARCH_PMC_H
+#define ASM_ARCH_PMC_H
+
+struct apl_pmc_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_intel_apl_pmc dtplat;
+#endif
+	pci_dev_t bdf;
+};
+
+#endif	/* ASM_ARCH_PMC_H */
diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c
index b512a85f3e6..acaa55d2e7f 100644
--- a/drivers/pinctrl/intel/pinctrl_apl.c
+++ b/drivers/pinctrl/intel/pinctrl_apl.c
@@ -17,18 +17,6 @@
 #include <asm-generic/gpio.h>
 #include <asm/intel_pinctrl_defs.h>
 
-/**
- * struct apl_gpio_plat - platform data for each device
- *
- * @dtplat: of-platdata data from C struct
- */
-struct apl_gpio_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	/* Put this first since driver model will copy the data here */
-	struct dtd_intel_apl_pinctrl dtplat;
-#endif
-};
-
 static const struct reset_mapping rst_map[] = {
 	{ .logical = PAD_CFG0_LOGICAL_RESET_PWROK, .chipset = 0U << 30 },
 	{ .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30 },
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 06/26] x86: Move priv/plat structs for intel_common to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (5 preceding siblings ...)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/intel_common/itss.c | 19 -------------------
 arch/x86/cpu/intel_common/p2sb.c |  9 +--------
 arch/x86/include/asm/itss.h      | 21 +++++++++++++++++++++
 arch/x86/include/asm/p2sb.h      | 18 ++++++++++++++++++
 4 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 arch/x86/include/asm/p2sb.h

diff --git a/arch/x86/cpu/intel_common/itss.c b/arch/x86/cpu/intel_common/itss.c
index 6515d1f471f..ae4de4ca8c6 100644
--- a/arch/x86/cpu/intel_common/itss.c
+++ b/arch/x86/cpu/intel_common/itss.c
@@ -19,25 +19,6 @@
 #include <spl.h>
 #include <asm/itss.h>
 
-struct itss_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	/* Put this first since driver model will copy the data here */
-	struct dtd_intel_itss dtplat;
-#endif
-};
-
-/* struct pmc_route - Routing for PMC to GPIO */
-struct pmc_route {
-	u32 pmc;
-	u32 gpio;
-};
-
-struct itss_priv {
-	struct pmc_route *route;
-	uint route_count;
-	u32 irq_snapshot[NUM_IPC_REGS];
-};
-
 static int set_polarity(struct udevice *dev, uint irq, bool active_low)
 {
 	u32 mask;
diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c
index cb901f265e2..d73ae438bbb 100644
--- a/arch/x86/cpu/intel_common/p2sb.c
+++ b/arch/x86/cpu/intel_common/p2sb.c
@@ -13,20 +13,13 @@
 #include <log.h>
 #include <p2sb.h>
 #include <spl.h>
+#include <asm/p2sb.h>
 #include <asm/pci.h>
 #include <linux/bitops.h>
 
 #define PCH_P2SB_E0		0xe0
 #define HIDE_BIT		BIT(0)
 
-struct p2sb_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_intel_p2sb dtplat;
-#endif
-	ulong mmio_base;
-	pci_dev_t bdf;
-};
-
 /* PCI config space registers */
 #define HPTC_OFFSET		0x60
 #define HPTC_ADDR_ENABLE_BIT	BIT(7)
diff --git a/arch/x86/include/asm/itss.h b/arch/x86/include/asm/itss.h
index f7d32403849..6d4793277e6 100644
--- a/arch/x86/include/asm/itss.h
+++ b/arch/x86/include/asm/itss.h
@@ -11,6 +11,8 @@
 #ifndef _ASM_ARCH_ITSS_H
 #define _ASM_ARCH_ITSS_H
 
+#include <irq.h>
+
 #define GPIO_IRQ_START	50
 #define GPIO_IRQ_END	ITSS_MAX_IRQ
 
@@ -42,4 +44,23 @@
 /* ITSS Power reduction control */
 #define PCR_ITSS_ITSSPRC	0x3300
 
+struct itss_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	/* Put this first since driver model will copy the data here */
+	struct dtd_intel_itss dtplat;
+#endif
+};
+
+/* struct pmc_route - Routing for PMC to GPIO */
+struct pmc_route {
+	u32 pmc;
+	u32 gpio;
+};
+
+struct itss_priv {
+	struct pmc_route *route;
+	uint route_count;
+	u32 irq_snapshot[NUM_IPC_REGS];
+};
+
 #endif /* _ASM_ARCH_ITSS_H */
diff --git a/arch/x86/include/asm/p2sb.h b/arch/x86/include/asm/p2sb.h
new file mode 100644
index 00000000000..6f63eae8e27
--- /dev/null
+++ b/arch/x86/include/asm/p2sb.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef ASM_P2SB_H
+#define ASM_P2SB_H
+
+/* Platform data for the P2SB */
+struct p2sb_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_intel_p2sb dtplat;
+#endif
+	ulong mmio_base;
+	pci_dev_t bdf;
+};
+
+#endif	/* ASM_P2SB_H */
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 07/26] x86: spl: Move priv/plat structs to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (6 preceding siblings ...)
  (?)
@ 2020-12-19 17:39 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:39 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/spi/ich.c | 11 -----------
 drivers/spi/ich.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index e02850e9f22..1cd410493b0 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -38,17 +38,6 @@
 #define debug_trace(x, args...)
 #endif
 
-struct ich_spi_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_intel_fast_spi dtplat;
-#endif
-	enum ich_version ich_version;	/* Controller version, 7 or 9 */
-	bool lockdown;			/* lock down controller settings? */
-	ulong mmio_base;		/* Base of MMIO registers */
-	pci_dev_t bdf;			/* PCI address used by of-platdata */
-	bool hwseq;			/* Use hardware sequencing (not s/w) */
-};
-
 static u8 ich_readb(struct ich_spi_priv *priv, int reg)
 {
 	u8 value = readb(priv->base + reg);
diff --git a/drivers/spi/ich.h b/drivers/spi/ich.h
index 23c7827740b..8fd150d44a4 100644
--- a/drivers/spi/ich.h
+++ b/drivers/spi/ich.h
@@ -230,4 +230,15 @@ struct ich_spi_priv {
 	struct udevice *pch;	/* PCH, used to control SPI access */
 };
 
+struct ich_spi_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_intel_fast_spi dtplat;
+#endif
+	enum ich_version ich_version;	/* Controller version, 7 or 9 */
+	bool lockdown;			/* lock down controller settings? */
+	ulong mmio_base;		/* Base of MMIO registers */
+	pci_dev_t bdf;			/* PCI address used by of-platdata */
+	bool hwseq;			/* Use hardware sequencing (not s/w) */
+};
+
 #endif /* _ICH_H_ */
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 08/26] spi: Tidy up get/set of device node
  2020-12-19 17:39 ` Simon Glass
                   ` (7 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

This code is a bit odd in that it only reads and updates the livetree
version of the device ofnode. This means it won't work with flattree.
Update the code to work as it was presumably intended.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/nand/spi/core.c |  2 +-
 include/linux/mtd/mtd.h     |  9 ++++-----
 include/linux/mtd/nand.h    | 14 ++++++++++++++
 include/linux/mtd/spi-nor.h |  2 ++
 include/linux/mtd/spinand.h | 15 +++++++++++++++
 5 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index fc9d4edbe04..ab9a24ed5b5 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
 		return -ENOMEM;
 	sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
 	spinand->slave = slave;
-	spinand_set_of_node(spinand, dev->node.np);
+	spinand_set_ofnode(spinand, dev->node);
 #endif
 
 	ret = spinand_init(spinand);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 1b9151714c0..54d03d02402 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -332,15 +332,14 @@ struct mtd_info {
 };
 
 #if IS_ENABLED(CONFIG_DM)
-static inline void mtd_set_of_node(struct mtd_info *mtd,
-				   const struct device_node *np)
+static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
 {
-	mtd->dev->node.np = np;
+	mtd->dev->node = node;
 }
 
-static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
 {
-	return mtd->dev->node.np;
+	return mtd->dev->node;
 }
 #else
 struct device_node;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 13e8dd11035..7774c17ad5d 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -389,6 +389,7 @@ static inline int nanddev_unregister(struct nand_device *nand)
 	return mtd_device_unregister(nand->mtd);
 }
 
+#ifndef __UBOOT__
 /**
  * nanddev_set_of_node() - Attach a DT node to a NAND device
  * @nand: NAND device
@@ -412,6 +413,19 @@ static inline const struct device_node *nanddev_get_of_node(struct nand_device *
 {
 	return mtd_get_of_node(nand->mtd);
 }
+#else
+/**
+ * nanddev_set_of_node() - Attach a DT node to a NAND device
+ * @nand: NAND device
+ * @node: ofnode
+ *
+ * Attach a DT node to a NAND device.
+ */
+static inline void nanddev_set_ofnode(struct nand_device *nand, ofnode node)
+{
+	mtd_set_ofnode(nand->mtd, node);
+}
+#endif /* __UBOOT__ */
 
 /**
  * nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 233fdc341a7..2642bf91d00 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -352,6 +352,7 @@ struct spi_nor {
 	u32 erase_size;
 };
 
+#ifndef __UBOOT__
 static inline void spi_nor_set_flash_node(struct spi_nor *nor,
 					  const struct device_node *np)
 {
@@ -363,6 +364,7 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor)
 {
 	return mtd_get_of_node(&nor->mtd);
 }
+#endif /* __UBOOT__ */
 
 /**
  * struct spi_nor_hwcaps - Structure for describing the hardware capabilies
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 88bacde91e5..15bcd59f341 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -412,6 +412,7 @@ spinand_to_nand(struct spinand_device *spinand)
 	return &spinand->base;
 }
 
+#ifndef __UBOOT__
 /**
  * spinand_set_of_node - Attach a DT node to a SPI NAND device
  * @spinand: SPI NAND device
@@ -424,6 +425,20 @@ static inline void spinand_set_of_node(struct spinand_device *spinand,
 {
 	nanddev_set_of_node(&spinand->base, np);
 }
+#else
+/**
+ * spinand_set_of_node - Attach a DT node to a SPI NAND device
+ * @spinand: SPI NAND device
+ * @node: ofnode
+ *
+ * Attach a DT node to a SPI NAND device.
+ */
+static inline void spinand_set_ofnode(struct spinand_device *spinand,
+				      ofnode node)
+{
+	nanddev_set_ofnode(&spinand->base, node);
+}
+#endif /* __UBOOT__ */
 
 int spinand_match_and_init(struct spinand_device *dev,
 			   const struct spinand_info *table,
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata
  2020-12-19 17:39 ` Simon Glass
                   ` (8 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

The #define of one struct to another has been around for a while. It
confuses dtoc and makes it think that struct spi_flash does not exist.

Make a few changes to improve things while we wait for migration to be
completed:

- Move the 'struct spi_flash' to column 1 so dtoc scans it
- Remove the #define when compiling dt-platdata.c
- Update the strange mtd_get/set_of_node() functions
- Use struct spi_nor in the drivers, so dtoc sees the correct struct

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sf-uclass.c | 2 +-
 drivers/mtd/spi/sf_probe.c  | 2 +-
 include/linux/mtd/spi-nor.h | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index ed629f1d458..3017022abbb 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -100,5 +100,5 @@ UCLASS_DRIVER(spi_flash) = {
 	.id		= UCLASS_SPI_FLASH,
 	.name		= "spi_flash",
 	.post_bind	= spi_flash_post_bind,
-	.per_device_auto	= sizeof(struct spi_flash),
+	.per_device_auto	= sizeof(struct spi_nor),
 };
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index c8bcec3c589..630787df1bf 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -166,7 +166,7 @@ U_BOOT_DRIVER(jedec_spi_nor) = {
 	.of_match	= spi_flash_std_ids,
 	.probe		= spi_flash_std_probe,
 	.remove		= spi_flash_std_remove,
-	.priv_auto	= sizeof(struct spi_flash),
+	.priv_auto	= sizeof(struct spi_nor),
 	.ops		= &spi_flash_std_ops,
 };
 
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 2642bf91d00..363f2749d7d 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -258,11 +258,13 @@ struct flash_info;
 /*
  * TODO: Remove, once all users of spi_flash interface are moved to MTD
  *
- * struct spi_flash {
+struct spi_flash {
  *	Defined below (keep this text to enable searching for spi_flash decl)
  * }
  */
+#ifndef DT_PLATDATA_C
 #define spi_flash spi_nor
+#endif
 
 /**
  * struct spi_nor - Structure for defining a the SPI NOR layer
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash
  2020-12-19 17:39 ` Simon Glass
                   ` (9 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

This construct effectively uses struct spi_nor due to a #define in
spi-nor.h so we may as well use that struct here. This allows dtoc to
parse it correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/apollolake/spl.c b/arch/x86/cpu/apollolake/spl.c
index 16a2f15c6bc..8991d5e648e 100644
--- a/arch/x86/cpu/apollolake/spl.c
+++ b/arch/x86/cpu/apollolake/spl.c
@@ -97,7 +97,7 @@ U_BOOT_DRIVER(winbond_w25q128fw) = {
 	.id		= UCLASS_SPI_FLASH,
 	.of_match	= apl_flash_ids,
 	.probe		= apl_flash_probe,
-	.priv_auto	= sizeof(struct spi_flash),
+	.priv_auto	= sizeof(struct spi_nor),
 	.ops		= &apl_flash_ops,
 };
 
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (10 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/simple-bus.c |  7 +------
 include/dm/simple_bus.h   | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 include/dm/simple_bus.h

diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index 7dbcbecd948..b0c2c209587 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -5,12 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
-
-struct simple_bus_plat {
-	u32 base;
-	u32 size;
-	u32 target;
-};
+#include <dm/simple_bus.h>
 
 fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr)
 {
diff --git a/include/dm/simple_bus.h b/include/dm/simple_bus.h
new file mode 100644
index 00000000000..4ad4cc4051d
--- /dev/null
+++ b/include/dm/simple_bus.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef __DM_SIMPLE_BUS_H
+#define __DM_SIMPLE_BUS_H
+
+struct simple_bus_plat {
+	u32 base;
+	u32 size;
+	u32 target;
+};
+
+#endif
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 12/26] x86: sysreset: Move priv/plat structs to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (11 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  2020-12-21 11:38   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  -1 siblings, 2 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them and add the dtd struct too.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/include/asm/sysreset.h | 18 ++++++++++++++++++
 drivers/sysreset/sysreset_x86.c |  5 +----
 2 files changed, 19 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/include/asm/sysreset.h

diff --git a/arch/x86/include/asm/sysreset.h b/arch/x86/include/asm/sysreset.h
new file mode 100644
index 00000000000..5e586f51c00
--- /dev/null
+++ b/arch/x86/include/asm/sysreset.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+#ifndef _X86_ASM_SYSRESET_H_
+#define _X86_ASM_SYSRESET_H_
+
+#include <dt-structs.h>
+
+struct x86_sysreset_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_x86_reset dtplat;
+#endif
+
+	struct udevice *pch;
+};
+
+#endif	/* _X86_ASM_SYSRESET_H_ */
diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c
index 8f9970301e5..8042f3994fe 100644
--- a/drivers/sysreset/sysreset_x86.c
+++ b/drivers/sysreset/sysreset_x86.c
@@ -13,10 +13,7 @@
 #include <acpi/acpi_s3.h>
 #include <asm/io.h>
 #include <asm/processor.h>
-
-struct x86_sysreset_plat {
-	struct udevice *pch;
-};
+#include <asm/sysreset.h>
 
 /*
  * Power down the machine by using the power management sleep control
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data
  2020-12-19 17:39 ` Simon Glass
                   ` (12 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

At present this driver calls malloc() to start a new platform data
structure, fills it in and tells driver model to use it.

We want to avoid malloc, particularly with the new version of of-platdata.
Create a new struct which encompasses both the dtd struct and the ns16550
one, to avoid this. Unfortunately we must copy the data into the right
place for the ns16550 driver. Add some comments about this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/uart.c              | 43 ++++++++++++---------
 arch/x86/include/asm/arch-apollolake/uart.h | 19 ++++++++-
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index 69e5899235b..876fa592b8d 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -17,6 +17,7 @@
 #include <asm/pci.h>
 #include <asm/lpss.h>
 #include <dm/device-internal.h>
+#include <asm/arch/uart.h>
 
 /* Low-power Subsystem (LPSS) clock register */
 enum {
@@ -69,7 +70,7 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
  * This driver uses its own compatible string but almost everything else from
  * the standard ns16550 driver. This allows us to provide an of-platdata
  * implementation, since the platdata produced by of-platdata does not match
- * struct ns16550_plat.
+ * struct apl_ns16550_plat.
  *
  * When running with of-platdata (generally TPL), the platdata is converted to
  * something that ns16550 expects. When running withoutof-platdata (SPL, U-Boot
@@ -78,10 +79,10 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
 
 static int apl_ns16550_probe(struct udevice *dev)
 {
-	struct ns16550_plat *plat = dev_get_plat(dev);
+	struct apl_ns16550_plat *plat = dev_get_plat(dev);
 
 	if (!CONFIG_IS_ENABLED(PCI))
-		apl_uart_init(plat->bdf, plat->base);
+		apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
 
 	return ns16550_serial_probe(dev);
 }
@@ -89,24 +90,28 @@ static int apl_ns16550_probe(struct udevice *dev)
 static int apl_ns16550_of_to_plat(struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_intel_apl_ns16550 *dtplat = dev_get_plat(dev);
-	struct ns16550_plat *plat;
+	struct dtd_intel_apl_ns16550 *dtplat;
+	struct apl_ns16550_plat *plat = dev_get_plat(dev);
+	struct ns16550_plat ns;
 
 	/*
-	 * Convert our plat to the ns16550's plat, so we can just use
-	 * that driver
+	 * The device's plat uses struct apl_ns16550_plat which starts with the
+	 * dtd struct, but the ns16550 driver expects it to be struct ns16550.
+	 * Set up what that driver expects. Note that this means that the values
+	 * cannot be read in this driver when using of-platdata.
+	 *
+	 * TODO(sjg at chromium.org): Consider having a separate plat pointer for
+	 * of-platdata so that it is not necessary to overwrite this.
 	 */
-	plat = malloc(sizeof(*plat));
-	if (!plat)
-		return -ENOMEM;
-	plat->base = dtplat->early_regs[0];
-	plat->reg_width = 1;
-	plat->reg_shift = dtplat->reg_shift;
-	plat->reg_offset = 0;
-	plat->clock = dtplat->clock_frequency;
-	plat->fcr = UART_FCR_DEFVAL;
-	plat->bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
-	dev_set_plat(dev, plat);
+	dtplat = &plat->dtplat;
+	ns.base = dtplat->early_regs[0];
+	ns.reg_width = 1;
+	ns.reg_shift = dtplat->reg_shift;
+	ns.reg_offset = 0;
+	ns.clock = dtplat->clock_frequency;
+	ns.fcr = UART_FCR_DEFVAL;
+	ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+	memcpy(plat, &ns, sizeof(ns));
 #else
 	int ret;
 
@@ -129,7 +134,7 @@ U_BOOT_DRIVER(intel_apl_ns16550) = {
 	.name	= "intel_apl_ns16550",
 	.id	= UCLASS_SERIAL,
 	.of_match = of_match_ptr(apl_ns16550_serial_ids),
-	.plat_auto	= sizeof(struct ns16550_plat),
+	.plat_auto	= sizeof(struct apl_ns16550_plat),
 	.priv_auto	= sizeof(struct ns16550),
 	.ops	= &ns16550_serial_ops,
 	.of_to_plat = apl_ns16550_of_to_plat,
diff --git a/arch/x86/include/asm/arch-apollolake/uart.h b/arch/x86/include/asm/arch-apollolake/uart.h
index d4fffe6525c..38335b04903 100644
--- a/arch/x86/include/asm/arch-apollolake/uart.h
+++ b/arch/x86/include/asm/arch-apollolake/uart.h
@@ -6,6 +6,23 @@
 #ifndef _ASM_ARCH_UART_H
 #define _ASM_ARCH_UART_H
 
+#include <ns16550.h>
+
+/**
+ * struct apl_ns16550_plat - platform data for the APL UART
+ *
+ * Note that when of-platdata is in use, apl_ns16550_of_to_plat() actually
+ * copies the ns16550_plat contents to the start of this struct, meaning that
+ * dtplat is no-longer valid. This is done so that the ns16550 driver can use
+ * dev_get_plat() without any offsets or adjustments.
+ */
+struct apl_ns16550_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_intel_apl_ns16550 dtplat;
+#endif
+	struct ns16550_plat ns16550;
+};
+
 /**
  * apl_uart_init() - Set up the APL UART device and clock
  *
@@ -15,6 +32,6 @@
  * The UART won't actually work unless the GPIO settings are correct and the
  * signals actually exit the SoC. See board_debug_uart_init() for that.
  */
-int apl_uart_init(pci_dev_t bdf, ulong base);
+void apl_uart_init(pci_dev_t bdf, ulong base);
 
 #endif
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL
  2020-12-19 17:39 ` Simon Glass
                   ` (13 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

Some devices are not needed in SPL/TPL. For TPL this causes the
generation of unnecessary of-platadata structs. Make some adjustments to
fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/chromebook_coral.dts | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts
index 3c8fdf23809..a8460220957 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -102,12 +102,13 @@
 	};
 
 	cpus {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		#address-cells = <1>;
 		#size-cells = <0>;
 
 		cpu_0: cpu at 0 {
-			u-boot,dm-pre-reloc;
+			u-boot,dm-pre-proper;
+			u-boot,dm-spl;
 			device_type = "cpu";
 			compatible = "intel,apl-cpu";
 			reg = <0>;
@@ -184,12 +185,14 @@
 		};
 
 		punit at 0,1 {
-			u-boot,dm-pre-reloc;
+			u-boot,dm-pre-proper;
+			u-boot,dm-spl;
 			reg = <0x00000800 0 0 0 0>;
 			compatible = "intel,apl-punit";
 		};
 
 		gma at 2,0 {
+			u-boot,dm-pre-proper;
 			reg = <0x00001000 0 0 0 0>;
 			compatible = "fsp-fb";
 		};
@@ -324,7 +327,8 @@
 		};
 
 		spi: fast-spi at d,2 {
-			u-boot,dm-pre-reloc;
+			u-boot,dm-pre-proper;
+			u-boot,dm-spl;
 			reg = <0x02006a10 0 0 0 0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
@@ -335,7 +339,8 @@
 			fwstore_spi: spi-flash at 0 {
 				#size-cells = <1>;
 				#address-cells = <1>;
-				u-boot,dm-pre-reloc;
+				u-boot,dm-pre-proper;
+				u-boot,dm-spl;
 				reg = <0>;
 				compatible = "winbond,w25q128fw",
 					 "jedec,spi-nor";
@@ -577,7 +582,7 @@
 				#size-cells = <0>;
 				u-boot,dm-pre-reloc;
 				cros_ec: cros-ec {
-					u-boot,dm-pre-reloc;
+					u-boot,dm-pre-proper;
 					compatible = "google,cros-ec-lpc";
 					reg = <0x204 1 0x200 1 0x880 0x80>;
 
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 15/26] x86: Drop rtc from SPL
  2020-12-19 17:39 ` Simon Glass
                   ` (14 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

The RTC is not currently used in SPL. Drop it so that it does not take up
space.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/rtc.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/dts/rtc.dtsi b/arch/x86/dts/rtc.dtsi
index d0bbd84e509..942cc937dc4 100644
--- a/arch/x86/dts/rtc.dtsi
+++ b/arch/x86/dts/rtc.dtsi
@@ -1,7 +1,7 @@
 / {
 	rtc: rtc {
 		compatible = "motorola,mc146818";
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		reg = <0x70 2>;
 	};
 };
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 16/26] dm: core: Split out alloc code into a new function
  2020-12-19 17:39 ` Simon Glass
                   ` (15 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

Add a new function to handle the allocation of private/platform data for
a device. This will make it easier to skip this feature when using the new
of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 89 +++++++++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 37 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index a4c8310f812..72169632c88 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -323,34 +323,17 @@ static void *alloc_priv(int size, uint flags)
 	return priv;
 }
 
-int device_of_to_plat(struct udevice *dev)
+/**
+ * device_alloc_priv() - Allocate priv/plat data required by the device
+ *
+ * @dev: Device to process
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+static int device_alloc_priv(struct udevice *dev)
 {
 	const struct driver *drv;
-	int size = 0;
 	void *ptr;
-	int ret;
-
-	if (!dev)
-		return -EINVAL;
-
-	if (dev->flags & DM_FLAG_PLATDATA_VALID)
-		return 0;
-
-	/* Ensure all parents have ofdata */
-	if (dev->parent) {
-		ret = device_of_to_plat(dev->parent);
-		if (ret)
-			goto fail;
-
-		/*
-		 * The device might have already been probed during
-		 * the call to device_probe() on its parent device
-		 * (e.g. PCI bridge devices). Test the flags again
-		 * so that we don't mess up the device.
-		 */
-		if (dev->flags & DM_FLAG_PLATDATA_VALID)
-			return 0;
-	}
+	int size;
 
 	drv = dev->driver;
 	assert(drv);
@@ -358,20 +341,17 @@ int device_of_to_plat(struct udevice *dev)
 	/* Allocate private data if requested and not reentered */
 	if (drv->priv_auto && !dev_get_priv(dev)) {
 		ptr = alloc_priv(drv->priv_auto, drv->flags);
-		if (!ptr) {
-			ret = -ENOMEM;
-			goto fail;
-		}
+		if (!ptr)
+			return -ENOMEM;
 		dev_set_priv(dev, ptr);
 	}
+
 	/* Allocate private data if requested and not reentered */
 	size = dev->uclass->uc_drv->per_device_auto;
 	if (size && !dev_get_uclass_priv(dev)) {
 		ptr = alloc_priv(size, dev->uclass->uc_drv->flags);
-		if (!ptr) {
-			ret = -ENOMEM;
-			goto fail;
-		}
+		if (!ptr)
+			return -ENOMEM;
 		dev_set_uclass_priv(dev, ptr);
 	}
 
@@ -382,14 +362,49 @@ int device_of_to_plat(struct udevice *dev)
 			size = dev->parent->uclass->uc_drv->per_child_auto;
 		if (size && !dev_get_parent_priv(dev)) {
 			ptr = alloc_priv(size, drv->flags);
-			if (!ptr) {
-				ret = -ENOMEM;
-				goto fail;
-			}
+			if (!ptr)
+				return -ENOMEM;
 			dev_set_parent_priv(dev, ptr);
 		}
 	}
 
+	return 0;
+}
+
+int device_of_to_plat(struct udevice *dev)
+{
+	const struct driver *drv;
+	int ret;
+
+	if (!dev)
+		return -EINVAL;
+
+	if (dev->flags & DM_FLAG_PLATDATA_VALID)
+		return 0;
+
+	/* Ensure all parents have ofdata */
+	if (dev->parent) {
+		ret = device_of_to_plat(dev->parent);
+		if (ret)
+			goto fail;
+
+		/*
+		 * The device might have already been probed during
+		 * the call to device_probe() on its parent device
+		 * (e.g. PCI bridge devices). Test the flags again
+		 * so that we don't mess up the device.
+		 */
+		if (dev->flags & DM_FLAG_PLATDATA_VALID)
+			return 0;
+	}
+
+	ret = device_alloc_priv(dev);
+	if (ret)
+		goto fail;
+
+	drv = dev->driver;
+	assert(drv);
+
 	if (drv->of_to_plat &&
 	    (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
 		ret = drv->of_to_plat(dev);
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 17/26] dm: core: Rename sqq to seq_
  2020-12-19 17:39 ` Simon Glass
                   ` (16 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  2020-12-21 11:41   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  -1 siblings, 2 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

Now that the sequence-numbering migration is complete, rename this member
back to seq_, adding an underscore to indicate it is internal to driver
model.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c    | 8 ++++----
 drivers/core/dump.c      | 2 +-
 drivers/core/uclass.c    | 8 ++++----
 drivers/pci/pci-uclass.c | 2 +-
 include/dm/device.h      | 9 +++++----
 test/dm/core.c           | 6 +++---
 6 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 72169632c88..f4ae7786ee9 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -73,7 +73,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	dev->driver = drv;
 	dev->uclass = uc;
 
-	dev->sqq = -1;
+	dev->seq_ = -1;
 	if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
 	    (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
 		/*
@@ -83,13 +83,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 		if (CONFIG_IS_ENABLED(OF_CONTROL) &&
 		    !CONFIG_IS_ENABLED(OF_PLATDATA)) {
 			if (uc->uc_drv->name && ofnode_valid(node)) {
-				if (!dev_read_alias_seq(dev, &dev->sqq))
+				if (!dev_read_alias_seq(dev, &dev->seq_))
 					auto_seq = false;
 			}
 		}
 	}
 	if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
-		dev->sqq = uclass_find_next_free_seq(uc);
+		dev->seq_ = uclass_find_next_free_seq(uc);
 
 	if (drv->plat_auto) {
 		bool alloc = !plat;
@@ -658,7 +658,7 @@ int device_find_child_by_seq(const struct udevice *parent, int seq,
 	*devp = NULL;
 
 	list_for_each_entry(dev, &parent->child_head, sibling_node) {
-		if (dev->sqq == seq) {
+		if (dev->seq_ == seq) {
 			*devp = dev;
 			return 0;
 		}
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 7784ec02dea..1d4628abc74 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -69,7 +69,7 @@ static void dm_display_line(struct udevice *dev, int index)
 	printf("%-3i %c %s @ %08lx", index,
 	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
 	       dev->name, (ulong)map_to_sysmem(dev));
-	if (dev->sqq != -1)
+	if (dev->seq_ != -1)
 		printf(", seq %d", dev_seq(dev));
 	puts("\n");
 }
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index f60bc9a8504..e773e34833e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -297,8 +297,8 @@ int uclass_find_next_free_seq(struct uclass *uc)
 
 	/* Avoid conflict with existing devices */
 	list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-		if (dev->sqq > max)
-			max = dev->sqq;
+		if (dev->seq_ > max)
+			max = dev->seq_;
 	}
 	/*
 	 * At this point, max will be -1 if there are no existing aliases or
@@ -323,8 +323,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq, struct udevice **devp)
 		return ret;
 
 	uclass_foreach_dev(dev, uc) {
-		log_debug("   - %d '%s'\n", dev->sqq, dev->name);
-		if (dev->sqq == seq) {
+		log_debug("   - %d '%s'\n", dev->seq_, dev->name);
+		if (dev->seq_ == seq) {
 			*devp = dev;
 			log_debug("   - found\n");
 			return 0;
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 37a233878d0..1f6c51f1e8d 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 		ret = uclass_get(UCLASS_PCI, &uc);
 		if (ret)
 			return ret;
-		bus->sqq = uclass_find_next_free_seq(uc);
+		bus->seq_ = uclass_find_next_free_seq(uc);
 	}
 
 	/* For bridges, use the top-level PCI controller */
diff --git a/include/dm/device.h b/include/dm/device.h
index daebd6eb68d..a063bbaa176 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -136,11 +136,12 @@ enum {
  * @child_head: List of children of this device
  * @sibling_node: Next device in list of all devices
  * @flags: Flags for this device DM_FLAG_...
- * @seq: Allocated sequence number for this device (-1 = none). This is set up
+ * @seq_: Allocated sequence number for this device (-1 = none). This is set up
  * when the device is bound and is unique within the device's uclass. If the
  * device has an alias in the devicetree then that is used to set the sequence
  * number. Otherwise, the next available number is used. Sequence numbers are
- * used by certain commands that need device to be numbered (e.g. 'mmc dev')
+ * used by certain commands that need device to be numbered (e.g. 'mmc dev').
+ * (do not access outside driver model)
  * @devres_head: List of memory allocations associated with this device.
  *		When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
  *		add to this list. Memory so-allocated will be freed
@@ -163,7 +164,7 @@ struct udevice {
 	struct list_head child_head;
 	struct list_head sibling_node;
 	uint32_t flags;
-	int sqq;
+	int seq_;
 #ifdef CONFIG_DEVRES
 	struct list_head devres_head;
 #endif
@@ -190,7 +191,7 @@ static inline bool dev_has_of_node(struct udevice *dev)
 
 static inline int dev_seq(const struct udevice *dev)
 {
-	return dev->sqq;
+	return dev->seq_;
 }
 
 /**
diff --git a/test/dm/core.c b/test/dm/core.c
index cf66e27db4e..b274b043882 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1075,10 +1075,10 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
 
 	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
 		list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-			if (dev->sqq == -1)
+			if (dev->seq_ == -1)
 				printf("Device '%s' has no seq (%d)\n",
-				       dev->name, dev->sqq);
-			ut_assert(dev->sqq != -1);
+				       dev->name, dev->seq_);
+			ut_assert(dev->seq_ != -1);
 		}
 	}
 
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 18/26] dm: core: Access device flags through functions
  2020-12-19 17:39 ` Simon Glass
                   ` (17 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

At present flags are stored as part of the device. In preparation for
storing them separately, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/remoteproc.c                     |  2 +-
 drivers/clk/clk.c                    |  2 +-
 drivers/core/device-remove.c         | 18 ++++++++--------
 drivers/core/device.c                | 32 ++++++++++++++--------------
 drivers/core/devres.c                |  4 ++--
 drivers/core/dump.c                  |  4 ++--
 drivers/mtd/nand/raw/octeontx_nand.c |  2 +-
 drivers/remoteproc/rproc-uclass.c    |  2 +-
 drivers/serial/serial-uclass.c       |  2 +-
 include/dm/device.h                  | 15 +++++++++++++
 include/virtio.h                     |  2 +-
 test/dm/bus.c                        | 10 ++++-----
 test/dm/core.c                       | 14 ++++++------
 test/dm/cpu.c                        |  2 +-
 test/dm/test-fdt.c                   | 20 ++++++++---------
 test/dm/virtio.c                     |  2 +-
 16 files changed, 74 insertions(+), 59 deletions(-)

diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index 5f9ba925609..b3ddcebe314 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -35,7 +35,7 @@ static int print_remoteproc_list(void)
 		uc_pdata = dev_get_uclass_plat(dev);
 
 		/* Do not print if rproc is not probed */
-		if (!(dev->flags & DM_FLAG_ACTIVATED))
+		if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
 			continue;
 
 		switch (uc_pdata->mem_type) {
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index eb75132f27e..1efb7fe9f3e 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -67,7 +67,7 @@ const char *clk_hw_get_name(const struct clk *hw)
 
 bool clk_dev_binded(struct clk *clk)
 {
-	if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND))
+	if (clk->dev && (dev_get_flags(clk->dev) & DM_FLAG_BOUND))
 		return true;
 
 	return false;
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index e15ab051be7..44eaa67d566 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -69,10 +69,10 @@ int device_unbind(struct udevice *dev)
 	if (!dev)
 		return log_msg_ret("dev", -EINVAL);
 
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return log_msg_ret("active", -EINVAL);
 
-	if (!(dev->flags & DM_FLAG_BOUND))
+	if (!(dev_get_flags(dev) & DM_FLAG_BOUND))
 		return log_msg_ret("not-bound", -EINVAL);
 
 	drv = dev->driver;
@@ -88,15 +88,15 @@ int device_unbind(struct udevice *dev)
 	if (ret)
 		return log_msg_ret("child unbind", ret);
 
-	if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
 		free(dev_get_plat(dev));
 		dev_set_plat(dev, NULL);
 	}
-	if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
 		free(dev_get_uclass_plat(dev));
 		dev_set_uclass_plat(dev, NULL);
 	}
-	if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
 		free(dev_get_parent_plat(dev));
 		dev_set_parent_plat(dev, NULL);
 	}
@@ -109,7 +109,7 @@ int device_unbind(struct udevice *dev)
 
 	devres_release_all(dev);
 
-	if (dev->flags & DM_FLAG_NAME_ALLOCED)
+	if (dev_get_flags(dev) & DM_FLAG_NAME_ALLOCED)
 		free((char *)dev->name);
 	free(dev);
 
@@ -144,7 +144,7 @@ void device_free(struct udevice *dev)
 			dev_set_parent_priv(dev, NULL);
 		}
 	}
-	dev->flags &= ~DM_FLAG_PLATDATA_VALID;
+	dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID);
 
 	devres_release_probe(dev);
 }
@@ -166,7 +166,7 @@ int device_remove(struct udevice *dev, uint flags)
 	if (!dev)
 		return -EINVAL;
 
-	if (!(dev->flags & DM_FLAG_ACTIVATED))
+	if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
 		return 0;
 
 	drv = dev->driver;
@@ -207,7 +207,7 @@ int device_remove(struct udevice *dev, uint flags)
 	if (flags_remove(flags, drv->flags)) {
 		device_free(dev);
 
-		dev->flags &= ~DM_FLAG_ACTIVATED;
+		dev_bic_flags(dev, DM_FLAG_ACTIVATED);
 	}
 
 	return ret;
diff --git a/drivers/core/device.c b/drivers/core/device.c
index f4ae7786ee9..ba50d46effe 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -96,13 +96,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 
 		if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
 			if (of_plat_size) {
-				dev->flags |= DM_FLAG_OF_PLATDATA;
+				dev_or_flags(dev, DM_FLAG_OF_PLATDATA);
 				if (of_plat_size < drv->plat_auto)
 					alloc = true;
 			}
 		}
 		if (alloc) {
-			dev->flags |= DM_FLAG_ALLOC_PDATA;
+			dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
 			ptr = calloc(1, drv->plat_auto);
 			if (!ptr) {
 				ret = -ENOMEM;
@@ -116,7 +116,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 
 	size = uc->uc_drv->per_device_plat_auto;
 	if (size) {
-		dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA;
+		dev_or_flags(dev, DM_FLAG_ALLOC_UCLASS_PDATA);
 		ptr = calloc(1, size);
 		if (!ptr) {
 			ret = -ENOMEM;
@@ -131,7 +131,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 			size = parent->uclass->uc_drv->per_child_plat_auto;
 		}
 		if (size) {
-			dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA;
+			dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
 			ptr = calloc(1, size);
 			if (!ptr) {
 				ret = -ENOMEM;
@@ -169,7 +169,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	if (devp)
 		*devp = dev;
 
-	dev->flags |= DM_FLAG_BOUND;
+	dev_or_flags(dev, DM_FLAG_BOUND);
 
 	return 0;
 
@@ -193,18 +193,18 @@ fail_bind:
 fail_uclass_bind:
 	if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
 		list_del(&dev->sibling_node);
-		if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+		if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
 			free(dev_get_parent_plat(dev));
 			dev_set_parent_plat(dev, NULL);
 		}
 	}
 fail_alloc3:
-	if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
 		free(dev_get_uclass_plat(dev));
 		dev_set_uclass_plat(dev, NULL);
 	}
 fail_alloc2:
-	if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
 		free(dev_get_plat(dev));
 		dev_set_plat(dev, NULL);
 	}
@@ -379,7 +379,7 @@ int device_of_to_plat(struct udevice *dev)
 	if (!dev)
 		return -EINVAL;
 
-	if (dev->flags & DM_FLAG_PLATDATA_VALID)
+	if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 		return 0;
 
 	/* Ensure all parents have ofdata */
@@ -394,7 +394,7 @@ int device_of_to_plat(struct udevice *dev)
 		 * (e.g. PCI bridge devices). Test the flags again
 		 * so that we don't mess up the device.
 		 */
-		if (dev->flags & DM_FLAG_PLATDATA_VALID)
+		if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 			return 0;
 	}
 
@@ -412,7 +412,7 @@ int device_of_to_plat(struct udevice *dev)
 			goto fail;
 	}
 
-	dev->flags |= DM_FLAG_PLATDATA_VALID;
+	dev_or_flags(dev, DM_FLAG_PLATDATA_VALID);
 
 	return 0;
 fail:
@@ -429,7 +429,7 @@ int device_probe(struct udevice *dev)
 	if (!dev)
 		return -EINVAL;
 
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return 0;
 
 	drv = dev->driver;
@@ -451,11 +451,11 @@ int device_probe(struct udevice *dev)
 		 * (e.g. PCI bridge devices). Test the flags again
 		 * so that we don't mess up the device.
 		 */
-		if (dev->flags & DM_FLAG_ACTIVATED)
+		if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 			return 0;
 	}
 
-	dev->flags |= DM_FLAG_ACTIVATED;
+	dev_or_flags(dev, DM_FLAG_ACTIVATED);
 
 	/*
 	 * Process pinctrl for everything except the root device, and
@@ -515,7 +515,7 @@ fail_uclass:
 			__func__, dev->name);
 	}
 fail:
-	dev->flags &= ~DM_FLAG_ACTIVATED;
+	dev_bic_flags(dev, DM_FLAG_ACTIVATED);
 
 	device_free(dev);
 
@@ -965,7 +965,7 @@ bool device_is_last_sibling(const struct udevice *dev)
 
 void device_set_name_alloced(struct udevice *dev)
 {
-	dev->flags |= DM_FLAG_NAME_ALLOCED;
+	dev_or_flags(dev, DM_FLAG_NAME_ALLOCED);
 }
 
 int device_set_name(struct udevice *dev, const char *name)
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 522b07d613f..313ddc7089c 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -107,9 +107,9 @@ void devres_add(struct udevice *dev, void *res)
 
 	devres_log(dev, dr, "ADD");
 	assert_noisy(list_empty(&dr->entry));
-	if (dev->flags & DM_FLAG_PLATDATA_VALID)
+	if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 		dr->phase = DEVRES_PHASE_PROBE;
-	else if (dev->flags & DM_FLAG_BOUND)
+	else if (dev_get_flags(dev) & DM_FLAG_BOUND)
 		dr->phase = DEVRES_PHASE_OFDATA;
 	else
 		dr->phase = DEVRES_PHASE_BIND;
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 1d4628abc74..f8afea30a93 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -14,7 +14,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
 {
 	int i, is_last;
 	struct udevice *child;
-	u32 flags = dev->flags;
+	u32 flags = dev_get_flags(dev);
 
 	/* print the first 20 characters to not break the tree-format. */
 	printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s  %d  [ %c ]   %s  " :
@@ -67,7 +67,7 @@ void dm_dump_all(void)
 static void dm_display_line(struct udevice *dev, int index)
 {
 	printf("%-3i %c %s @ %08lx", index,
-	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+	       dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ',
 	       dev->name, (ulong)map_to_sysmem(dev));
 	if (dev->seq_ != -1)
 		printf(", seq %d", dev_seq(dev));
diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
index b1ed4d910a7..96a5fe6592a 100644
--- a/drivers/mtd/nand/raw/octeontx_nand.c
+++ b/drivers/mtd/nand/raw/octeontx_nand.c
@@ -2187,7 +2187,7 @@ int octeontx_pci_nand_deferred_probe(void)
 	debug("%s: Performing deferred probing\n", __func__);
 	list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) {
 		debug("%s: Probing %s\n", __func__, pdev->dev->name);
-		pdev->dev->flags &= ~DM_FLAG_ACTIVATED;
+		dev_get_flags(pdev->dev) &= ~DM_FLAG_ACTIVATED;
 		rc = device_probe(pdev->dev);
 		if (rc && rc != -ENODEV) {
 			printf("%s: Error %d with deferred probe of %s\n",
diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c
index 773b8119f4f..c2d6a4e0c17 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -247,7 +247,7 @@ static int _rproc_dev_is_probed(struct udevice *dev,
 			    struct dm_rproc_uclass_pdata *uc_pdata,
 			    const void *data)
 {
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return 0;
 
 	return -EAGAIN;
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index b6457242dea..58a6541d8cc 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -123,7 +123,7 @@ static void serial_find_console_or_panic(void)
 #ifdef CONFIG_SERIAL_SEARCH_ALL
 		if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
-			if (dev->flags & DM_FLAG_ACTIVATED) {
+			if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
 				return;
 			}
diff --git a/include/dm/device.h b/include/dm/device.h
index a063bbaa176..4ec423e9618 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -179,6 +179,21 @@ struct udevice {
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)	((dev)->flags & DM_FLAG_ACTIVATED)
 
+static inline u32 dev_get_flags(const struct udevice *dev)
+{
+	return dev->flags;
+}
+
+static inline void dev_or_flags(struct udevice *dev, u32 or)
+{
+	dev->flags |= or;
+}
+
+static inline void dev_bic_flags(struct udevice *dev, u32 bic)
+{
+	dev->flags &= ~bic;
+}
+
 static inline int dev_of_offset(const struct udevice *dev)
 {
 	return ofnode_to_offset(dev->node);
diff --git a/include/virtio.h b/include/virtio.h
index 10a9c073ba1..a42bdad6b87 100644
--- a/include/virtio.h
+++ b/include/virtio.h
@@ -492,7 +492,7 @@ static inline void __virtio_clear_bit(struct udevice *udev, unsigned int fbit)
  */
 static inline bool virtio_has_feature(struct udevice *vdev, unsigned int fbit)
 {
-	if (!(vdev->flags & DM_FLAG_BOUND))
+	if (!(dev_get_flags(vdev) & DM_FLAG_BOUND))
 		WARN_ON(true);
 
 	return __virtio_test_bit(vdev->parent, fbit);
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 785ccfc25d1..e768eab6957 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -55,16 +55,16 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)
 	ut_assertok(device_get_child(bus, 0, &dev));
 	ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev));
 	ut_assertok(device_get_child_by_seq(bus, 5, &dev));
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 	ut_asserteq_str("c-test at 5", dev->name);
 
 	/* Device with sequence number 0 should be accessible */
 	ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev));
 	ut_assertok(device_find_child_by_seq(bus, 0, &dev));
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 	ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
 	ut_assertok(device_get_child_by_seq(bus, 0, &dev));
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 	ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
 
 	/* There is no device with sequence number 2 */
@@ -96,10 +96,10 @@ static int dm_test_bus_children_of_offset(struct unit_test_state *uts)
 	ut_assert(node > 0);
 	ut_assertok(device_find_child_by_of_offset(bus, node, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 	ut_assertok(device_get_child_by_of_offset(bus, node, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 	return 0;
 }
diff --git a/test/dm/core.c b/test/dm/core.c
index b274b043882..565896ed504 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -131,7 +131,7 @@ static int dm_test_autobind(struct unit_test_state *uts)
 
 	/* No devices should be probed */
 	list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node)
-		ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+		ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 
 	/* Our test driver should have been bound 3 times */
 	ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3);
@@ -212,7 +212,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
 	ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
 
 	/* The root device should not be activated until needed */
-	ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
 
 	/*
 	 * We should be able to find the three test devices, and they should
@@ -222,17 +222,17 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
 	for (i = 0; i < 3; i++) {
 		ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+		ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
 			   "Driver %d/%s already activated", i, dev->name);
 
 		/* This should activate it */
 		ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 		/* Activating a device should activate the root device */
 		if (!i)
-			ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+			ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
 	}
 
 	/*
@@ -460,10 +460,10 @@ static int dm_test_remove(struct unit_test_state *uts)
 	for (i = 0; i < 3; i++) {
 		ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assertf(dev->flags & DM_FLAG_ACTIVATED,
+		ut_assertf(dev_get_flags(dev) & DM_FLAG_ACTIVATED,
 			   "Driver %d/%s not activated", i, dev->name);
 		ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
-		ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+		ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
 			   "Driver %d/%s should have deactivated", i,
 			   dev->name);
 		ut_assert(!dev_get_priv(dev));
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index 28869c1d6ff..ed12cafee2b 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -25,7 +25,7 @@ static int dm_test_cpu(struct unit_test_state *uts)
 	for (uclass_find_first_device(UCLASS_CPU, &dev);
 	     dev;
 	     uclass_find_next_device(&dev))
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
 	ut_asserteq_ptr(cpu_get_current_dev(), dev);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 633256821c2..711bf20a9c5 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -1031,8 +1031,8 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)
 	ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
 	count = 0;
 	device_foreach_child_of_to_plat(dev, bus) {
-		ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-		ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+		ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+		ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 		count++;
 	}
 	ut_asserteq(3, count);
@@ -1050,8 +1050,8 @@ static int dm_test_first_child_probe(struct unit_test_state *uts)
 	ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
 	count = 0;
 	device_foreach_child_probe(dev, bus) {
-		ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 		count++;
 	}
 	ut_asserteq(3, count);
@@ -1067,19 +1067,19 @@ static int dm_test_ofdata_order(struct unit_test_state *uts)
 
 	ut_assertok(uclass_find_first_device(UCLASS_I2C, &bus));
 	ut_assertnonnull(bus);
-	ut_assert(!(bus->flags & DM_FLAG_PLATDATA_VALID));
+	ut_assert(!(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID));
 
 	ut_assertok(device_find_first_child(bus, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(!(dev->flags & DM_FLAG_PLATDATA_VALID));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID));
 
 	/* read the child's ofdata which should cause the parent's to be read */
 	ut_assertok(device_of_to_plat(dev));
-	ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-	ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+	ut_assert(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID);
 
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
-	ut_assert(!(bus->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(bus) & DM_FLAG_ACTIVATED));
 
 	return 0;
 }
diff --git a/test/dm/virtio.c b/test/dm/virtio.c
index 2e876c36e43..ad355981cf4 100644
--- a/test/dm/virtio.c
+++ b/test/dm/virtio.c
@@ -122,7 +122,7 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
 	ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
 
 	/* check the device can be successfully removed */
-	dev->flags |= DM_FLAG_ACTIVATED;
+	dev_or_flags(dev, DM_FLAG_ACTIVATED);
 	ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL));
 
 	return 0;
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 19/26] dm: core: Rename device flags to indicate it is private
  2020-12-19 17:39 ` Simon Glass
                   ` (18 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

To avoid having people accidentally access this member, add a trailing
underscore.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/dm/device.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/dm/device.h b/include/dm/device.h
index 4ec423e9618..a0c1752cddc 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -135,7 +135,8 @@ enum {
  * @uclass_node: Used by uclass to link its devices
  * @child_head: List of children of this device
  * @sibling_node: Next device in list of all devices
- * @flags: Flags for this device DM_FLAG_...
+ * @flags_: Flags for this device DM_FLAG_... (do not access outside driver
+ *	model)
  * @seq_: Allocated sequence number for this device (-1 = none). This is set up
  * when the device is bound and is unique within the device's uclass. If the
  * device has an alias in the devicetree then that is used to set the sequence
@@ -163,7 +164,7 @@ struct udevice {
 	struct list_head uclass_node;
 	struct list_head child_head;
 	struct list_head sibling_node;
-	uint32_t flags;
+	u32 flags_;
 	int seq_;
 #ifdef CONFIG_DEVRES
 	struct list_head devres_head;
@@ -176,24 +177,24 @@ struct udevice {
 /* Returns the operations for a device */
 #define device_get_ops(dev)	(dev->driver->ops)
 
-/* Returns non-zero if the device is active (probed and not removed) */
-#define device_active(dev)	((dev)->flags & DM_FLAG_ACTIVATED)
-
 static inline u32 dev_get_flags(const struct udevice *dev)
 {
-	return dev->flags;
+	return dev->flags_;
 }
 
 static inline void dev_or_flags(struct udevice *dev, u32 or)
 {
-	dev->flags |= or;
+	dev->flags_ |= or;
 }
 
 static inline void dev_bic_flags(struct udevice *dev, u32 bic)
 {
-	dev->flags &= ~bic;
+	dev->flags_ &= ~bic;
 }
 
+/* Returns non-zero if the device is active (probed and not removed) */
+#define device_active(dev)	(dev_get_flags(dev) & DM_FLAG_ACTIVATED)
+
 static inline int dev_of_offset(const struct udevice *dev)
 {
 	return ofnode_to_offset(dev->node);
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode()
  2020-12-19 17:39 ` Simon Glass
                   ` (19 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

We use 'ofnode' rather than 'of_node' in U-Boot. Rename this function to
fit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c            | 2 +-
 drivers/mmc/octeontx_hsmmc.c     | 2 +-
 drivers/pinctrl/pinctrl-uclass.c | 2 +-
 drivers/usb/host/usb-uclass.c    | 2 +-
 include/dm/device.h              | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index ba50d46effe..8c7ce220f84 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -406,7 +406,7 @@ int device_of_to_plat(struct udevice *dev)
 	assert(drv);
 
 	if (drv->of_to_plat &&
-	    (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
+	    (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_ofnode(dev))) {
 		ret = drv->of_to_plat(dev);
 		if (ret)
 			goto fail;
diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
index 57d107aac32..f3da6af9090 100644
--- a/drivers/mmc/octeontx_hsmmc.c
+++ b/drivers/mmc/octeontx_hsmmc.c
@@ -3752,7 +3752,7 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
 	host->dev = dev;
 	debug("%s(%s): Base address: %p\n", __func__, dev->name,
 	      host->base_addr);
-	if (!dev_has_of_node(dev)) {
+	if (!dev_has_ofnode(dev)) {
 		pr_err("%s: No device tree information found\n", __func__);
 		return -1;
 	}
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 4e474cbff73..4653e86ba46 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -305,7 +305,7 @@ int pinctrl_select_state(struct udevice *dev, const char *statename)
 	 * Some device which is logical like mmc.blk, do not have
 	 * a valid ofnode.
 	 */
-	if (!dev_has_of_node(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 	/*
 	 * Try full-implemented pinctrl first.
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 17db5eb0609..ae6b1450d3a 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -517,7 +517,7 @@ static ofnode usb_get_ofnode(struct udevice *hub, int port)
 	ofnode node;
 	u32 reg;
 
-	if (!dev_has_of_node(hub))
+	if (!dev_has_ofnode(hub))
 		return ofnode_null();
 
 	/*
diff --git a/include/dm/device.h b/include/dm/device.h
index a0c1752cddc..b15a14ec330 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -200,7 +200,7 @@ static inline int dev_of_offset(const struct udevice *dev)
 	return ofnode_to_offset(dev->node);
 }
 
-static inline bool dev_has_of_node(struct udevice *dev)
+static inline bool dev_has_ofnode(struct udevice *dev)
 {
 	return ofnode_valid(dev->node);
 }
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  2020-12-19 17:39 ` Simon Glass
                   ` (20 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  2020-12-21 11:41   ` Andy Shevchenko
                     ` (2 more replies)
  -1 siblings, 3 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

We have two functions which do the same thing. Standardise on
dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in
normal operation: it is either null or missing.

Also move the functions into one place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/clk/clk-uclass.c            |  2 +-
 drivers/core/device.c               |  2 +-
 drivers/gpio/sandbox.c              |  2 +-
 drivers/i2c/designware_i2c_pci.c    |  4 ++--
 drivers/i2c/i2c-uclass.c            |  2 +-
 drivers/mmc/pci_mmc.c               |  2 +-
 drivers/pci/pci-uclass.c            |  6 +++---
 drivers/pinctrl/pinctrl-uclass.c    |  2 +-
 drivers/spi/spi-uclass.c            |  2 +-
 drivers/sysreset/sysreset_sandbox.c |  2 +-
 drivers/timer/timer-uclass.c        |  2 +-
 drivers/usb/host/usb-uclass.c       |  2 +-
 include/dm/device.h                 | 13 ++++++++++++-
 include/dm/read.h                   | 16 ----------------
 test/dm/pci.c                       |  6 +++---
 15 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index ac954a34d27..5cfd00ce771 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -345,7 +345,7 @@ int clk_set_defaults(struct udevice *dev, int stage)
 {
 	int ret;
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	/* If this not in SPL and pre-reloc state, don't take any action. */
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 8c7ce220f84..bd4ecc9e24d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -485,7 +485,7 @@ int device_probe(struct udevice *dev)
 	}
 
 	/* Only handle devices that have a valid ofnode */
-	if (dev_of_valid(dev)) {
+	if (dev_has_ofnode(dev)) {
 		/*
 		 * Process 'assigned-{clocks/clock-parents/clock-rates}'
 		 * properties
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 489271b560e..f8fa4baa2c3 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -294,7 +294,7 @@ static int gpio_sandbox_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		/* Tell the uclass how many GPIOs we have */
 		uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
 
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index 18eef625f0f..ec0cdf62207 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -92,7 +92,7 @@ static int designware_i2c_pci_bind(struct udevice *dev)
 {
 	char name[20];
 
-	if (dev_of_valid(dev))
+	if (dev_has_ofnode(dev))
 		return 0;
 
 	sprintf(name, "i2c_designware#%u", dev_seq(dev));
@@ -152,7 +152,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
 	int ret;
 
 	/* If no device-tree node, ignore this since we assume it isn't used */
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	ret = acpi_device_path(dev, path, sizeof(path));
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 456cf3b85fb..be56785217c 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -678,7 +678,7 @@ static int i2c_child_post_bind(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 	return i2c_chip_of_to_plat(dev, plat);
 #else
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index fc09ad99e5e..c71c495d581 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -75,7 +75,7 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
 	struct acpi_dp *dp;
 	int ret;
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	ret = gpio_get_acpi(&priv->cd_gpio, &gpio);
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 1f6c51f1e8d..4cdd06b1257 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -540,7 +540,7 @@ int pci_auto_config_devices(struct udevice *bus)
 		int ret;
 
 		debug("%s: device %s\n", __func__, dev->name);
-		if (dev_of_valid(dev) &&
+		if (dev_has_ofnode(dev) &&
 		    dev_read_bool(dev, "pci,no-autoconfig"))
 			continue;
 		ret = dm_pciauto_config_device(dev);
@@ -1036,7 +1036,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 	hose->bus = bus;
 	hose->first_busno = dev_seq(bus);
 	hose->last_busno = dev_seq(bus);
-	if (dev_of_valid(bus)) {
+	if (dev_has_ofnode(bus)) {
 		hose->skip_auto_config_until_reloc =
 			dev_read_bool(bus,
 				      "u-boot,skip-auto-config-until-reloc");
@@ -1091,7 +1091,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
 {
 	struct pci_child_plat *pplat;
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	pplat = dev_get_parent_plat(dev);
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 4653e86ba46..7919e54e8de 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -112,7 +112,7 @@ static int pinconfig_post_bind(struct udevice *dev)
 	ofnode node;
 	int ret;
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	dev_for_each_subnode(node, dev) {
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index f3b8ffad425..8bd35a551b8 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -155,7 +155,7 @@ static int spi_child_post_bind(struct udevice *dev)
 {
 	struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev);
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	return spi_slave_of_to_plat(dev, plat);
diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
index 7026a48c4b2..8eca7d8bfda 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -50,7 +50,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
 	 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
 	 * If we are that device, return an error.
 	 */
-	if (state->fdt_fname && !dev_of_valid(dev))
+	if (state->fdt_fname && !dev_has_ofnode(dev))
 		return -ENODEV;
 
 	switch (type) {
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 8e63c17e9f3..da1a72f0252 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -54,7 +54,7 @@ static int timer_pre_probe(struct udevice *dev)
 	ulong ret;
 
 	/* It is possible that a timer device has a null ofnode */
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	err = clk_get_by_index(dev, 0, &timer_clk);
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index ae6b1450d3a..e3b616c3266 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -773,7 +773,7 @@ static int usb_child_post_bind(struct udevice *dev)
 	struct usb_dev_plat *plat = dev_get_parent_plat(dev);
 	int val;
 
-	if (!dev_of_valid(dev))
+	if (!dev_has_ofnode(dev))
 		return 0;
 
 	/* We only support matching a few things */
diff --git a/include/dm/device.h b/include/dm/device.h
index b15a14ec330..4a1224bcc26 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -192,6 +192,17 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
 	dev->flags_ &= ~bic;
 }
 
+/**
+ * dev_ofnode() - get the DT node reference associated with a udevice
+ *
+ * @dev:	device to check
+ * @return reference of the the device's DT node
+ */
+static inline ofnode dev_ofnode(const struct udevice *dev)
+{
+	return dev->node;
+}
+
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)	(dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 
@@ -200,7 +211,7 @@ static inline int dev_of_offset(const struct udevice *dev)
 	return ofnode_to_offset(dev->node);
 }
 
-static inline bool dev_has_ofnode(struct udevice *dev)
+static inline bool dev_has_ofnode(const struct udevice *dev)
 {
 	return ofnode_valid(dev->node);
 }
diff --git a/include/dm/read.h b/include/dm/read.h
index 0585eb12281..d5cdd87911d 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -30,22 +30,6 @@ static inline const struct device_node *dev_np(const struct udevice *dev)
 }
 #endif
 
-/**
- * dev_ofnode() - get the DT node reference associated with a udevice
- *
- * @dev:	device to check
- * @return reference of the the device's DT node
- */
-static inline ofnode dev_ofnode(const struct udevice *dev)
-{
-	return dev->node;
-}
-
-static inline bool dev_of_valid(const struct udevice *dev)
-{
-	return ofnode_valid(dev_ofnode(dev));
-}
-
 #ifndef CONFIG_DM_DEV_READ_INLINE
 
 /**
diff --git a/test/dm/pci.c b/test/dm/pci.c
index 76490befdf5..fa2e4a85596 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -120,13 +120,13 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts)
 
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(dev_of_valid(swap));
+	ut_assertok(dev_has_ofnode(swap));
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(dev_of_valid(swap));
+	ut_assertok(dev_has_ofnode(swap));
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x10, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(!dev_of_valid(swap));
+	ut_assertok(!dev_has_ofnode(swap));
 
 	return 0;
 }
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 22/26] dm: core: Access device ofnode through functions
  2020-12-19 17:39 ` Simon Glass
@ 2020-12-19 17:40   ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
 board/synopsys/hsdk/clk-lib.c             |  2 +-
 drivers/ata/mtk_ahci.c                    |  3 ++-
 drivers/clk/meson/axg.c                   |  2 +-
 drivers/clk/meson/g12a.c                  |  2 +-
 drivers/clk/meson/gxbb.c                  |  2 +-
 drivers/core/device.c                     |  2 +-
 drivers/core/root.c                       |  2 +-
 drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
 drivers/gpio/octeon_gpio.c                |  2 +-
 drivers/misc/swap_case.c                  |  2 +-
 drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
 drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
 drivers/mtd/nand/spi/core.c               |  2 +-
 drivers/net/fm/eth.c                      |  4 ++--
 drivers/net/fsl_enetc.c                   |  8 ++++----
 drivers/net/fsl_enetc_mdio.c              |  2 +-
 drivers/net/mdio-ipq4019.c                |  4 ++--
 drivers/net/mdio_mux_i2creg.c             |  2 +-
 drivers/net/mvmdio.c                      |  4 ++--
 drivers/net/octeontx/smi.c                |  2 +-
 drivers/net/tsec.c                        |  3 ++-
 drivers/phy/phy-ti-am654.c                |  2 +-
 drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
 drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
 drivers/power/regulator/pbias_regulator.c |  3 ++-
 drivers/pwm/pwm-meson.c                   |  9 ++++++---
 drivers/reset/reset-socfpga.c             |  2 +-
 drivers/spi/fsl_dspi.c                    |  6 ++++--
 drivers/tee/optee/core.c                  |  2 +-
 drivers/usb/cdns3/core.c                  |  4 ++--
 drivers/usb/dwc3/core.c                   |  2 +-
 drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
 drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
 drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
 drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
 drivers/usb/host/ehci-mx6.c               |  2 +-
 drivers/usb/host/xhci-dwc3.c              |  2 +-
 drivers/usb/mtu3/mtu3_core.c              |  2 +-
 drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
 drivers/usb/musb-new/ti-musb.c            |  2 +-
 drivers/video/nexell_display.c            |  2 +-
 drivers/video/rockchip/rk_mipi.c          |  2 +-
 include/dm/device.h                       | 23 +++++++++++++++++++++--
 include/dm/read.h                         |  2 +-
 include/linux/mtd/mtd.h                   |  4 ++--
 net/mdio-mux-uclass.c                     |  2 +-
 net/mdio-uclass.c                         |  8 ++++----
 50 files changed, 113 insertions(+), 82 deletions(-)

diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
index af6ea439646..766ed95f1a6 100644
--- a/arch/arm/mach-stm32mp/pwr_regulator.c
+++ b/arch/arm/mach-stm32mp/pwr_regulator.c
@@ -81,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
 {
 	int children;
 
-	children = pmic_bind_children(dev, dev->node, pwr_children_info);
+	children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
 	if (!children)
 		dev_dbg(dev, "no child found\n");
 
diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
index 1c74bfb93a3..bd43179fc79 100644
--- a/board/synopsys/hsdk/clk-lib.c
+++ b/board/synopsys/hsdk/clk-lib.c
@@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
 	/* Dummy fmeas device, just to be able to use standard clk_* api */
 	struct udevice fmeas = {
 		.name = "clk-fmeas",
-		.node = ofnode_path("/clk-fmeas"),
 	};
+	dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
 
 	ret = clk_get_by_name(&fmeas, name, &clk);
 	if (ret) {
diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index cd28e0cae37..46b7677783f 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
 				   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
 	}
 
-	ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
+	ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
+			&hpriv->port_map);
 	return 0;
 }
 
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 82068578ffb..d6da59d269b 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index 01b22abc34d..5058db1a47b 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 2a20541dcb4..e379540deee 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/core/device.c b/drivers/core/device.c
index bd4ecc9e24d..6a9bee093d0 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	dev_set_plat(dev, plat);
 	dev->driver_data = driver_data;
 	dev->name = name;
-	dev->node = node;
+	dev_set_ofnode(dev, node);
 	dev->parent = parent;
 	dev->driver = drv;
 	dev->uclass = uc;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 9ef242979ba..fe7359433f6 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -148,7 +148,7 @@ int dm_init(bool of_live)
 	if (ret)
 		return ret;
 	if (CONFIG_IS_ENABLED(OF_CONTROL))
-		DM_ROOT_NON_CONST->node = ofnode_root();
+		dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
 	ret = device_probe(DM_ROOT_NON_CONST);
 	if (ret)
 		return ret;
diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
index 2bc1a0d5716..a964347fa32 100644
--- a/drivers/gpio/mpc8xxx_gpio.c
+++ b/drivers/gpio/mpc8xxx_gpio.c
@@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
 	u32 i;
 	u32 reg[4];
 
-	if (ofnode_read_bool(dev->node, "little-endian"))
+	if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))
 		data->little_endian = true;
 
 	if (data->little_endian)
@@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
 	if (!str)
 		return -ENOMEM;
 
-	if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
+	if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
 		unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
 			- sizeof(u32);
 
diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c
index 958516d8f8e..42eae79d8c4 100644
--- a/drivers/gpio/octeon_gpio.c
+++ b/drivers/gpio/octeon_gpio.c
@@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
 			GPIO_CONST_GPIOS_MASK;
 	} else {
 		priv->base = dev_remap_addr(dev);
-		uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
+		uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
 							      "nr-gpios", 32);
 	}
 
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index abea0e76139..3cbc8f37ec5 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -54,7 +54,7 @@ struct swap_case_priv {
 
 static int sandbox_swap_case_use_ea(const struct udevice *dev)
 {
-	return !!ofnode_get_property(dev->node, "use-ea", NULL);
+	return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);
 }
 
 /* Please keep these macros in sync with ea_regs below */
diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
index f3da6af9090..442ca493d76 100644
--- a/drivers/mmc/octeontx_hsmmc.c
+++ b/drivers/mmc/octeontx_hsmmc.c
@@ -3439,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
  */
 static bool octeontx_mmc_get_valid(struct udevice *dev)
 {
-	const char *stat = ofnode_read_string(dev->node, "status");
+	const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
 
 	if (!stat || !strncmp(stat, "ok", 2))
 		return true;
@@ -3461,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 	uint low, high;
 	char env_name[32];
 	int err;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	int bus_width = 1;
 	ulong new_max_freq;
 
 	debug("%s(%s)", __func__, dev->name);
 	slot->cfg.name = dev->name;
 
-	slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
+	slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
+						  "max-frequency",
 						  26000000);
 	snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
 		 slot->bus_id);
@@ -3486,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 
 	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
 		slot->hs400_tuning_block =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs400-tuning-block",
 						-1);
 		debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
 		      dev->name, slot->hs400_tuning_block);
 
 		slot->hs200_tap_adj =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs200-tap-adjust", 0);
 		debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs200_tap_adj);
 		slot->hs400_tap_adj =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs400-tap-adjust", 0);
 		debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs400_tap_adj);
 	}
 
-	err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
+	err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
+				    voltages, 2);
 	if (err) {
 		slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 	} else {
@@ -3756,14 +3758,15 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
 		pr_err("%s: No device tree information found\n", __func__);
 		return -1;
 	}
-	host->node = dev->node;
+	host->node = dev_ofnode(dev);
 	host->last_slotid = -1;
 	if (otx_is_platform(PLATFORM_ASIM))
 		host->is_asim = true;
 	if (otx_is_platform(PLATFORM_EMULATOR))
 		host->is_emul = true;
 	host->dma_wait_delay =
-		ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
+		ofnode_read_u32_default(dev_ofnode(dev),
+					"marvell,dma-wait-delay", 1);
 	/* Force reset of eMMC */
 	writeq(0, host->base_addr + MIO_EMM_CFG());
 	debug("%s: Clearing MIO_EMM_CFG\n", __func__);
@@ -3824,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
 	struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
 	struct octeontx_mmc_slot *slot;
 	struct mmc_uclass_priv *upriv;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	u32 bus_id;
 	char name[16];
 	int err;
diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
index 96a5fe6592a..64433cf6ccc 100644
--- a/drivers/mtd/nand/raw/octeontx_nand.c
+++ b/drivers/mtd/nand/raw/octeontx_nand.c
@@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
 static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
 {
 	struct udevice *dev = tn->dev;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	ofnode nand_node;
 	int nr_chips = of_get_child_count(node);
 	int ret;
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index ab9a24ed5b5..cd12376ab82 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
 		return -ENOMEM;
 	sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
 	spinand->slave = slave;
-	spinand_set_ofnode(spinand, dev->node);
+	spinand_set_ofnode(spinand, dev_ofnode(dev));
 #endif
 
 	ret = spinand_init(spinand);
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index a10f87eefc5..0e89e663f71 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -957,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
 {
 	const char *if_str;
 
-	if_str = ofnode_read_string(dev->node, "phy-connection-type");
+	if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
 	debug("MAC system interface mode %s\n", if_str);
 
 	return phy_get_interface_by_name(if_str);
@@ -969,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
 	char mac_name[11];
 	u32 fm, num;
 
-	if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
+	if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
 		printf("FMan node property cell-index missing\n");
 		return -EINVAL;
 	}
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 2e684e58393..f6fc7801b95 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
 	 * and some are not, use different naming scheme - enetc-N based on
 	 * PCI function # and enetc#N based on interface count
 	 */
-	if (ofnode_valid(dev->node))
+	if (ofnode_valid(dev_ofnode(dev)))
 		sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
 	else
 		sprintf(name, "enetc#%u", eth_num_devices++);
@@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
 			mdio_register(&priv->imdio);
 	}
 
-	if (!ofnode_valid(dev->node)) {
+	if (!ofnode_valid(dev_ofnode(dev))) {
 		enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
 		return;
 	}
 
-	if_str = ofnode_read_string(dev->node, "phy-mode");
+	if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
 	if (if_str)
 		priv->if_type = phy_get_interface_by_name(if_str);
 	else
@@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
 {
 	struct enetc_priv *priv = dev_get_priv(dev);
 
-	if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
+	if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
 		enetc_dbg(dev, "interface disabled\n");
 		return -ENODEV;
 	}
diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
index 4da97b61d17..3eb6ac9fc8f 100644
--- a/drivers/net/fsl_enetc_mdio.c
+++ b/drivers/net/fsl_enetc_mdio.c
@@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
 	 * and some are not, use different naming scheme - enetc-N based on
 	 * PCI function # and enetc#N based on interface count
 	 */
-	if (ofnode_valid(dev->node))
+	if (ofnode_valid(dev_ofnode(dev)))
 		sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
 	else
 		sprintf(name, "emdio#%u", eth_num_devices++);
diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c
index 13a8856286a..50134b4d9b6 100644
--- a/drivers/net/mdio-ipq4019.c
+++ b/drivers/net/mdio-ipq4019.c
@@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
 
 static int ipq4019_mdio_bind(struct udevice *dev)
 {
-	if (ofnode_valid(dev->node))
-		device_set_name(dev, ofnode_get_name(dev->node));
+	if (ofnode_valid(dev_ofnode(dev)))
+		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
 	return 0;
 }
diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c
index f8557dd2c49..3654230118f 100644
--- a/drivers/net/mdio_mux_i2creg.c
+++ b/drivers/net/mdio_mux_i2creg.c
@@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
 	}
 
 	/* parent should be an I2C chip, grandparent should be an I2C bus */
-	chip_node = ofnode_get_parent(dev->node);
+	chip_node = ofnode_get_parent(dev_ofnode(dev));
 	bus_node = ofnode_get_parent(chip_node);
 
 	err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c
index 005f28f1b25..96f8dc62b56 100644
--- a/drivers/net/mvmdio.c
+++ b/drivers/net/mvmdio.c
@@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
  */
 static int mvmdio_bind(struct udevice *dev)
 {
-	if (ofnode_valid(dev->node))
-		device_set_name(dev, ofnode_get_name(dev->node));
+	if (ofnode_valid(dev_ofnode(dev)))
+		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
 	return 0;
 }
diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
index d1582b968bf..58436419f1b 100644
--- a/drivers/net/octeontx/smi.c
+++ b/drivers/net/octeontx/smi.c
@@ -313,7 +313,7 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-	int ret, subnode, cnt = 0, node = dev->node.of_offset;
+	int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
 	struct mii_dev *bus;
 	struct octeontx_smi_priv *priv;
 	pci_dev_t bdf = dm_pci_get_bdf(dev);
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 2d124732cf0..ec486893725 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -707,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
 		tsec_configure_serdes(priv);
 
 #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
-	if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
+	if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
+					     "fixed-link")))
 		phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
 	else
 		phydev = dm_eth_phy_connect(priv->dev);
diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
index 8e35ea14750..82010e7c96e 100644
--- a/drivers/phy/phy-ti-am654.c
+++ b/drivers/phy/phy-ti-am654.c
@@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
 
 	ret = device_bind_driver_to_node(dev->parent,
 					 "ti-serdes-am654-mux-clk",
-					 dev_read_name(dev), dev->node,
+					 dev_read_name(dev), dev_ofnode(dev),
 					 NULL);
 	if (ret) {
 		dev_err(dev, "%s: not able to bind clock driver\n", __func__);
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index 2e7ab671286..ef8274ce96d 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
 	if (!priv->data)
 		return -EINVAL;
 
-	priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->regmap_hhi))
 		return PTR_ERR(priv->regmap_hhi);
 
-	ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
+	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
 			      &ao_phandle);
 	if (ret)
 		return ret;
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index 40947c66f31..eb94af2cf83 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
 	ofnode hhi_node;
 	int ret;
 
-	priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->regmap_ao))
 		return PTR_ERR(priv->regmap_ao);
 
-	ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
+	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
 			      &hhi_phandle);
 	if (ret)
 		return ret;
diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
index 6f0d0a59ff4..5bf186e4d4c 100644
--- a/drivers/power/regulator/pbias_regulator.c
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -103,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
 {
 	int children;
 
-	children = pmic_bind_children(dev, dev->node, pmic_children_info);
+	children = pmic_bind_children(dev, dev_ofnode(dev),
+				      pmic_children_info);
 	if (!children)
 		debug("%s: %s - no child found\n", __func__, dev->name);
 
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 58b7469f977..03eeacc286d 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
 					if (strcmp(cdev->driver->name, "fixed_rate_clock"))
 						continue;
 
-					str = ofnode_read_string(cdev->node, "clock-output-names");
+					str = ofnode_read_string(dev_ofnode(cdev),
+								 "clock-output-names");
 					if (!str)
 						continue;
 
 					if (!strcmp(str, "xtal")) {
 						err = uclass_get_device_by_ofnode(UCLASS_CLK,
-										  cdev->node,
+										  dev_ofnode(cdev),
 										  &cdev);
 						if (err) {
 							printf("%s%d: Failed to get xtal clk\n", __func__, i);
@@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
 					return -EINVAL;
 				}
 
-				err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
+				err = uclass_get_device_by_ofnode(UCLASS_CLK,
+								  dev_ofnode(cdev),
+								  &cdev);
 				if (err) {
 					printf("%s%d: Failed to get clk controller\n", __func__, i);
 					return err;
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index c64c9b5917c..98450db94b2 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
 	 * Bind it to the node, too, so that it can get its base address.
 	 */
 	ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
-					 dev->node, &sys_child);
+					 dev_ofnode(dev), &sys_child);
 	if (ret)
 		debug("Warning: No sysreset driver: ret=%d\n", ret);
 
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index b8c0216b39d..c17a5522bcc 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
-	ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
+	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
+			&cs_sck_delay);
+	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
+			&sck_cs_delay);
 
 	/* Set PCS to SCK delay scale values */
 	ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 7c38d6e0527..b898c32edc0 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
 	const char *method;
 
 	debug("optee: looking for conduit method in DT.\n");
-	method = ofnode_get_property(dev->node, "method", NULL);
+	method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
 	if (!method) {
 		debug("optee: missing \"method\" property\n");
 		return ERR_PTR(-ENXIO);
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index e861c82f7e1..798a21793f7 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 	enum usb_dr_mode dr_mode;
 	int ret = 0;
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 	cdns->role = USB_ROLE_NONE;
 
 	/*
@@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	node = ofnode_by_compatible(parent->node, "cdns,usb3");
+	node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
 	if (!ofnode_valid(node)) {
 		ret = -ENODEV;
 		goto fail;
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 2e003530a15..dfd7cf683f7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
 	 */
 	hird_threshold = 12;
 
-	dwc->hsphy_mode = usb_get_phy_mode(dev->node);
+	dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
 
 	dwc->has_lpm_erratum = dev_read_bool(dev,
 				"snps,has-lpm-erratum");
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 459add80c58..39e931f634d 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_of_to_plat(struct udevice *dev)
 {
 	struct dwc3_generic_plat *plat = dev_get_plat(dev);
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 
 	plat->base = dev_read_addr(dev);
 
@@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	ofnode_for_each_subnode(node, parent->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
 		const char *name = ofnode_get_name(node);
 		enum usb_dr_mode dr_mode;
 		struct udevice *dev;
@@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
 	while (child) {
 		enum usb_dr_mode dr_mode;
 
-		dr_mode = usb_get_dr_mode(child->node);
+		dr_mode = usb_get_dr_mode(dev_ofnode(child));
 		device_find_next_child(&child);
 		if (ops && ops->select_dr_mode)
 			ops->select_dr_mode(dev, index, dr_mode);
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index acc7866b64a..6f99fb27f3f 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -395,7 +395,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
 	}
 #endif
 
-	priv->otg_mode = usb_get_dr_mode(dev->node);
+	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	ret = dwc3_meson_g12a_usb_init(priv);
 	if (ret)
diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c
index b63cc235f7e..08467d6210b 100644
--- a/drivers/usb/dwc3/dwc3-meson-gxl.c
+++ b/drivers/usb/dwc3/dwc3-meson-gxl.c
@@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	priv->otg_mode = usb_get_dr_mode(dev->node);
+	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
 		priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 4771b1e9312..e3871e381e1 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
-	if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
-	    usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
+	if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}
diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c
index c3cac9c5abd..742e156cbb9 100644
--- a/drivers/usb/host/dwc3-octeon-glue.c
+++ b/drivers/usb/host/dwc3-octeon-glue.c
@@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
 
 	/* Find snps,dwc3 node from subnode */
 	dwc3_node = ofnode_null();
-	ofnode_for_each_subnode(node, dev->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
 		if (ofnode_device_is_compatible(node, "snps,dwc3"))
 			dwc3_node = node;
 	}
diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index deb820a0f84..e5c6a1a67d6 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
 	int ret;
 	u32 reg[4];
 
-	ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
+	ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
+				    ARRAY_SIZE(reg));
 	if (ret) {
 		pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
 		return ret;
@@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
 	ofnode node, dwc3_node;
 
 	/* Find snps,dwc3 node from subnode */
-	ofnode_for_each_subnode(node, dev->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
 		if (ofnode_device_is_compatible(node, "snps,dwc3"))
 			dwc3_node = node;
 	}
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index d2f49cf4690..ef3a63afa44 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
 	struct usb_plat *plat = dev_get_plat(dev);
 	enum usb_dr_mode dr_mode;
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	switch (dr_mode) {
 	case USB_DR_MODE_HOST:
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index 59408e4e50e..3e0ae80cece 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
 		dr_mode = USB_DR_MODE_HOST;
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 28136f88f45..2f5cc9b1480 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
 	mtu->ippc_base = ssusb->ippc_base;
 	mtu->mac_base = ssusb->mac_base;
 	mtu->ssusb = ssusb;
-	mtu->max_speed = usb_get_maximum_speed(dev->node);
+	mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
 	mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
 
 	ret = mtu3_hw_init(mtu);
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index c951107b201..b097471f3d4 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
 		return -ENODEV;
 	}
 
-	ssusb->dr_mode = usb_get_dr_mode(child->node);
+	ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
 
 	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
 		ssusb->dr_mode == USB_DR_MODE_OTG)
@@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
+	node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
 	if (!ofnode_valid(node))
 		return -ENODEV;
 
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 81b12fadfc1..75cf1811f7a 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	ofnode_for_each_subnode(node, parent->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
 		struct udevice *dev;
 		const char *name = ofnode_get_name(node);
 		enum usb_dr_mode dr_mode;
diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c
index 00e2c36f376..b47bef3578f 100644
--- a/drivers/video/nexell_display.c
+++ b/drivers/video/nexell_display.c
@@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
 		      __func__);
 		return NULL;
 	}
-	node = dev->node.of_offset;
+	node = dev_ofnode(dev).of_offset;
 
 	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
 		ret = nx_display_parse_dt(dev, dp, plat);
diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c
index d125a5ba737..159201a5916 100644
--- a/drivers/video/rockchip/rk_mipi.c
+++ b/drivers/video/rockchip/rk_mipi.c
@@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
 	rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
 	/* Set dpi color coding depth 24 bit */
-	timing_node = ofnode_find_subnode(dev->node, "display-timings");
+	timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");
 	node = ofnode_first_subnode(timing_node);
 
 	val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
diff --git a/include/dm/device.h b/include/dm/device.h
index 4a1224bcc26..1b274206ea3 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
  */
 static inline ofnode dev_ofnode(const struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	return dev->node;
+#else
+	return ofnode_null();
+#endif
 }
 
 /* Returns non-zero if the device is active (probed and not removed) */
@@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
 
 static inline int dev_of_offset(const struct udevice *dev)
 {
-	return ofnode_to_offset(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	return ofnode_to_offset(dev_ofnode(dev));
+#else
+	return -1;
+#endif
 }
 
 static inline bool dev_has_ofnode(const struct udevice *dev)
 {
-	return ofnode_valid(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	return ofnode_valid(dev_ofnode(dev));
+#else
+	return false;
+#endif
+}
+
+static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	dev->node = node;
+#endif
 }
 
 static inline int dev_seq(const struct udevice *dev)
diff --git a/include/dm/read.h b/include/dm/read.h
index d5cdd87911d..fc987f77598 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -21,7 +21,7 @@ struct resource;
 #if CONFIG_IS_ENABLED(OF_LIVE)
 static inline const struct device_node *dev_np(const struct udevice *dev)
 {
-	return ofnode_to_np(dev->node);
+	return ofnode_to_np(dev_ofnode(dev));
 }
 #else
 static inline const struct device_node *dev_np(const struct udevice *dev)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 54d03d02402..927854950a0 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -334,12 +334,12 @@ struct mtd_info {
 #if IS_ENABLED(CONFIG_DM)
 static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
 {
-	mtd->dev->node = node;
+	dev_set_ofnode(mtd->dev, node);
 }
 
 static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
 {
-	return mtd->dev->node;
+	return dev_ofnode(mtd->dev);
 }
 #else
 struct device_node;
diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
index 5f38f9fde41..780526c19e3 100644
--- a/net/mdio-mux-uclass.c
+++ b/net/mdio-mux-uclass.c
@@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
 	ofnode ch_node;
 	int err, first_err = 0;
 
-	if (!ofnode_valid(mux->node)) {
+	if (!dev_has_ofnode(mux)) {
 		debug("%s: no mux node found, no child MDIO busses set up\n",
 		      __func__);
 		return 0;
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index d062382c2a9..697e5f838d9 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
 	const char *dt_name;
 
 	/* set a custom name for the MDIO device, if present in DT */
-	if (ofnode_valid(dev->node)) {
-		dt_name = ofnode_read_string(dev->node, "device-name");
+	if (dev_has_ofnode(dev)) {
+		dt_name = dev_read_string(dev, "device-name");
 		if (dt_name) {
 			debug("renaming dev %s to %s\n", dev->name, dt_name);
 			device_set_name(dev, dt_name);
@@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 	struct phy_device *phy;
 	int i;
 
-	if (!ofnode_valid(ethdev->node)) {
+	if (!dev_has_ofnode(ethdev)) {
 		debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
 		return NULL;
 	}
 
 	interface = PHY_INTERFACE_MODE_NONE;
 	for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-		if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
+		if_str = dev_read_string(ethdev, phy_mode_str[i]);
 		if (if_str) {
 			interface = phy_get_interface_by_name(if_str);
 			break;
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 22/26] dm: core: Access device ofnode through functions
@ 2020-12-19 17:40   ` Simon Glass
  0 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Aaron Williams, Alexey Brodkin, Anatolij Gustschin,
	Bin Meng, Chunfeng Yun, Daniel Schwierzeck, Eugeniy Paltsev,
	Frank Wang, Frank Wunderlich, GSS_MTK_Uboot_upstream,
	Jaehoon Chung, Jagan Teki, Jens Wiklander, Joe Hershberger,
	Kever Yang, Ley Foon Tan, Lokesh Vutla, Luka Kovacic,
	Luka Perkov, Lukasz Majewski, Madalin Bucur, Marek Vasut,
	Masahiro Yamada, Michal Simek, Neil Armstrong, Patrice Chotard,
	Patrick Delaunay, Pavel Herrmann, Peng Fan, Philipp Tomsich,
	Priyanka Jain, Rasmus Villemoes, Robert Marko, Ryder Lee,
	Sean Anderson, Siva Durga Prasad Paladugu, Stefan Bosch,
	Stefan Roese, Suneel Garapati, Weijie Gao, hui.song,
	u-boot-amlogic, uboot-snps-arc, uboot-stm32

At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
 board/synopsys/hsdk/clk-lib.c             |  2 +-
 drivers/ata/mtk_ahci.c                    |  3 ++-
 drivers/clk/meson/axg.c                   |  2 +-
 drivers/clk/meson/g12a.c                  |  2 +-
 drivers/clk/meson/gxbb.c                  |  2 +-
 drivers/core/device.c                     |  2 +-
 drivers/core/root.c                       |  2 +-
 drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
 drivers/gpio/octeon_gpio.c                |  2 +-
 drivers/misc/swap_case.c                  |  2 +-
 drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
 drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
 drivers/mtd/nand/spi/core.c               |  2 +-
 drivers/net/fm/eth.c                      |  4 ++--
 drivers/net/fsl_enetc.c                   |  8 ++++----
 drivers/net/fsl_enetc_mdio.c              |  2 +-
 drivers/net/mdio-ipq4019.c                |  4 ++--
 drivers/net/mdio_mux_i2creg.c             |  2 +-
 drivers/net/mvmdio.c                      |  4 ++--
 drivers/net/octeontx/smi.c                |  2 +-
 drivers/net/tsec.c                        |  3 ++-
 drivers/phy/phy-ti-am654.c                |  2 +-
 drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
 drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
 drivers/power/regulator/pbias_regulator.c |  3 ++-
 drivers/pwm/pwm-meson.c                   |  9 ++++++---
 drivers/reset/reset-socfpga.c             |  2 +-
 drivers/spi/fsl_dspi.c                    |  6 ++++--
 drivers/tee/optee/core.c                  |  2 +-
 drivers/usb/cdns3/core.c                  |  4 ++--
 drivers/usb/dwc3/core.c                   |  2 +-
 drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
 drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
 drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
 drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
 drivers/usb/host/ehci-mx6.c               |  2 +-
 drivers/usb/host/xhci-dwc3.c              |  2 +-
 drivers/usb/mtu3/mtu3_core.c              |  2 +-
 drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
 drivers/usb/musb-new/ti-musb.c            |  2 +-
 drivers/video/nexell_display.c            |  2 +-
 drivers/video/rockchip/rk_mipi.c          |  2 +-
 include/dm/device.h                       | 23 +++++++++++++++++++++--
 include/dm/read.h                         |  2 +-
 include/linux/mtd/mtd.h                   |  4 ++--
 net/mdio-mux-uclass.c                     |  2 +-
 net/mdio-uclass.c                         |  8 ++++----
 50 files changed, 113 insertions(+), 82 deletions(-)

diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
index af6ea439646..766ed95f1a6 100644
--- a/arch/arm/mach-stm32mp/pwr_regulator.c
+++ b/arch/arm/mach-stm32mp/pwr_regulator.c
@@ -81,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
 {
 	int children;
 
-	children = pmic_bind_children(dev, dev->node, pwr_children_info);
+	children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
 	if (!children)
 		dev_dbg(dev, "no child found\n");
 
diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
index 1c74bfb93a3..bd43179fc79 100644
--- a/board/synopsys/hsdk/clk-lib.c
+++ b/board/synopsys/hsdk/clk-lib.c
@@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
 	/* Dummy fmeas device, just to be able to use standard clk_* api */
 	struct udevice fmeas = {
 		.name = "clk-fmeas",
-		.node = ofnode_path("/clk-fmeas"),
 	};
+	dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
 
 	ret = clk_get_by_name(&fmeas, name, &clk);
 	if (ret) {
diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index cd28e0cae37..46b7677783f 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
 				   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
 	}
 
-	ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
+	ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
+			&hpriv->port_map);
 	return 0;
 }
 
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 82068578ffb..d6da59d269b 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index 01b22abc34d..5058db1a47b 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 2a20541dcb4..e379540deee 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
 	struct meson_clk *priv = dev_get_priv(dev);
 
-	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
diff --git a/drivers/core/device.c b/drivers/core/device.c
index bd4ecc9e24d..6a9bee093d0 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	dev_set_plat(dev, plat);
 	dev->driver_data = driver_data;
 	dev->name = name;
-	dev->node = node;
+	dev_set_ofnode(dev, node);
 	dev->parent = parent;
 	dev->driver = drv;
 	dev->uclass = uc;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 9ef242979ba..fe7359433f6 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -148,7 +148,7 @@ int dm_init(bool of_live)
 	if (ret)
 		return ret;
 	if (CONFIG_IS_ENABLED(OF_CONTROL))
-		DM_ROOT_NON_CONST->node = ofnode_root();
+		dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
 	ret = device_probe(DM_ROOT_NON_CONST);
 	if (ret)
 		return ret;
diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
index 2bc1a0d5716..a964347fa32 100644
--- a/drivers/gpio/mpc8xxx_gpio.c
+++ b/drivers/gpio/mpc8xxx_gpio.c
@@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
 	u32 i;
 	u32 reg[4];
 
-	if (ofnode_read_bool(dev->node, "little-endian"))
+	if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))
 		data->little_endian = true;
 
 	if (data->little_endian)
@@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
 	if (!str)
 		return -ENOMEM;
 
-	if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
+	if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
 		unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
 			- sizeof(u32);
 
diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c
index 958516d8f8e..42eae79d8c4 100644
--- a/drivers/gpio/octeon_gpio.c
+++ b/drivers/gpio/octeon_gpio.c
@@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
 			GPIO_CONST_GPIOS_MASK;
 	} else {
 		priv->base = dev_remap_addr(dev);
-		uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
+		uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
 							      "nr-gpios", 32);
 	}
 
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index abea0e76139..3cbc8f37ec5 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -54,7 +54,7 @@ struct swap_case_priv {
 
 static int sandbox_swap_case_use_ea(const struct udevice *dev)
 {
-	return !!ofnode_get_property(dev->node, "use-ea", NULL);
+	return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);
 }
 
 /* Please keep these macros in sync with ea_regs below */
diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
index f3da6af9090..442ca493d76 100644
--- a/drivers/mmc/octeontx_hsmmc.c
+++ b/drivers/mmc/octeontx_hsmmc.c
@@ -3439,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
  */
 static bool octeontx_mmc_get_valid(struct udevice *dev)
 {
-	const char *stat = ofnode_read_string(dev->node, "status");
+	const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
 
 	if (!stat || !strncmp(stat, "ok", 2))
 		return true;
@@ -3461,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 	uint low, high;
 	char env_name[32];
 	int err;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	int bus_width = 1;
 	ulong new_max_freq;
 
 	debug("%s(%s)", __func__, dev->name);
 	slot->cfg.name = dev->name;
 
-	slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
+	slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
+						  "max-frequency",
 						  26000000);
 	snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
 		 slot->bus_id);
@@ -3486,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 
 	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
 		slot->hs400_tuning_block =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs400-tuning-block",
 						-1);
 		debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
 		      dev->name, slot->hs400_tuning_block);
 
 		slot->hs200_tap_adj =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs200-tap-adjust", 0);
 		debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs200_tap_adj);
 		slot->hs400_tap_adj =
-			ofnode_read_s32_default(dev->node,
+			ofnode_read_s32_default(dev_ofnode(dev),
 						"marvell,hs400-tap-adjust", 0);
 		debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs400_tap_adj);
 	}
 
-	err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
+	err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
+				    voltages, 2);
 	if (err) {
 		slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 	} else {
@@ -3756,14 +3758,15 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
 		pr_err("%s: No device tree information found\n", __func__);
 		return -1;
 	}
-	host->node = dev->node;
+	host->node = dev_ofnode(dev);
 	host->last_slotid = -1;
 	if (otx_is_platform(PLATFORM_ASIM))
 		host->is_asim = true;
 	if (otx_is_platform(PLATFORM_EMULATOR))
 		host->is_emul = true;
 	host->dma_wait_delay =
-		ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
+		ofnode_read_u32_default(dev_ofnode(dev),
+					"marvell,dma-wait-delay", 1);
 	/* Force reset of eMMC */
 	writeq(0, host->base_addr + MIO_EMM_CFG());
 	debug("%s: Clearing MIO_EMM_CFG\n", __func__);
@@ -3824,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
 	struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
 	struct octeontx_mmc_slot *slot;
 	struct mmc_uclass_priv *upriv;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	u32 bus_id;
 	char name[16];
 	int err;
diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
index 96a5fe6592a..64433cf6ccc 100644
--- a/drivers/mtd/nand/raw/octeontx_nand.c
+++ b/drivers/mtd/nand/raw/octeontx_nand.c
@@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
 static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
 {
 	struct udevice *dev = tn->dev;
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 	ofnode nand_node;
 	int nr_chips = of_get_child_count(node);
 	int ret;
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index ab9a24ed5b5..cd12376ab82 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
 		return -ENOMEM;
 	sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
 	spinand->slave = slave;
-	spinand_set_ofnode(spinand, dev->node);
+	spinand_set_ofnode(spinand, dev_ofnode(dev));
 #endif
 
 	ret = spinand_init(spinand);
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index a10f87eefc5..0e89e663f71 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -957,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
 {
 	const char *if_str;
 
-	if_str = ofnode_read_string(dev->node, "phy-connection-type");
+	if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
 	debug("MAC system interface mode %s\n", if_str);
 
 	return phy_get_interface_by_name(if_str);
@@ -969,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
 	char mac_name[11];
 	u32 fm, num;
 
-	if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
+	if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
 		printf("FMan node property cell-index missing\n");
 		return -EINVAL;
 	}
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 2e684e58393..f6fc7801b95 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
 	 * and some are not, use different naming scheme - enetc-N based on
 	 * PCI function # and enetc#N based on interface count
 	 */
-	if (ofnode_valid(dev->node))
+	if (ofnode_valid(dev_ofnode(dev)))
 		sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
 	else
 		sprintf(name, "enetc#%u", eth_num_devices++);
@@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
 			mdio_register(&priv->imdio);
 	}
 
-	if (!ofnode_valid(dev->node)) {
+	if (!ofnode_valid(dev_ofnode(dev))) {
 		enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
 		return;
 	}
 
-	if_str = ofnode_read_string(dev->node, "phy-mode");
+	if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
 	if (if_str)
 		priv->if_type = phy_get_interface_by_name(if_str);
 	else
@@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
 {
 	struct enetc_priv *priv = dev_get_priv(dev);
 
-	if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
+	if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
 		enetc_dbg(dev, "interface disabled\n");
 		return -ENODEV;
 	}
diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
index 4da97b61d17..3eb6ac9fc8f 100644
--- a/drivers/net/fsl_enetc_mdio.c
+++ b/drivers/net/fsl_enetc_mdio.c
@@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
 	 * and some are not, use different naming scheme - enetc-N based on
 	 * PCI function # and enetc#N based on interface count
 	 */
-	if (ofnode_valid(dev->node))
+	if (ofnode_valid(dev_ofnode(dev)))
 		sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
 	else
 		sprintf(name, "emdio#%u", eth_num_devices++);
diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c
index 13a8856286a..50134b4d9b6 100644
--- a/drivers/net/mdio-ipq4019.c
+++ b/drivers/net/mdio-ipq4019.c
@@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
 
 static int ipq4019_mdio_bind(struct udevice *dev)
 {
-	if (ofnode_valid(dev->node))
-		device_set_name(dev, ofnode_get_name(dev->node));
+	if (ofnode_valid(dev_ofnode(dev)))
+		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
 	return 0;
 }
diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c
index f8557dd2c49..3654230118f 100644
--- a/drivers/net/mdio_mux_i2creg.c
+++ b/drivers/net/mdio_mux_i2creg.c
@@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
 	}
 
 	/* parent should be an I2C chip, grandparent should be an I2C bus */
-	chip_node = ofnode_get_parent(dev->node);
+	chip_node = ofnode_get_parent(dev_ofnode(dev));
 	bus_node = ofnode_get_parent(chip_node);
 
 	err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c
index 005f28f1b25..96f8dc62b56 100644
--- a/drivers/net/mvmdio.c
+++ b/drivers/net/mvmdio.c
@@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
  */
 static int mvmdio_bind(struct udevice *dev)
 {
-	if (ofnode_valid(dev->node))
-		device_set_name(dev, ofnode_get_name(dev->node));
+	if (ofnode_valid(dev_ofnode(dev)))
+		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
 	return 0;
 }
diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
index d1582b968bf..58436419f1b 100644
--- a/drivers/net/octeontx/smi.c
+++ b/drivers/net/octeontx/smi.c
@@ -313,7 +313,7 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-	int ret, subnode, cnt = 0, node = dev->node.of_offset;
+	int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
 	struct mii_dev *bus;
 	struct octeontx_smi_priv *priv;
 	pci_dev_t bdf = dm_pci_get_bdf(dev);
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 2d124732cf0..ec486893725 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -707,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
 		tsec_configure_serdes(priv);
 
 #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
-	if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
+	if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
+					     "fixed-link")))
 		phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
 	else
 		phydev = dm_eth_phy_connect(priv->dev);
diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
index 8e35ea14750..82010e7c96e 100644
--- a/drivers/phy/phy-ti-am654.c
+++ b/drivers/phy/phy-ti-am654.c
@@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
 
 	ret = device_bind_driver_to_node(dev->parent,
 					 "ti-serdes-am654-mux-clk",
-					 dev_read_name(dev), dev->node,
+					 dev_read_name(dev), dev_ofnode(dev),
 					 NULL);
 	if (ret) {
 		dev_err(dev, "%s: not able to bind clock driver\n", __func__);
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index 2e7ab671286..ef8274ce96d 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
 	if (!priv->data)
 		return -EINVAL;
 
-	priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->regmap_hhi))
 		return PTR_ERR(priv->regmap_hhi);
 
-	ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
+	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
 			      &ao_phandle);
 	if (ret)
 		return ret;
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index 40947c66f31..eb94af2cf83 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
 	ofnode hhi_node;
 	int ret;
 
-	priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
+	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->regmap_ao))
 		return PTR_ERR(priv->regmap_ao);
 
-	ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
+	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
 			      &hhi_phandle);
 	if (ret)
 		return ret;
diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
index 6f0d0a59ff4..5bf186e4d4c 100644
--- a/drivers/power/regulator/pbias_regulator.c
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -103,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
 {
 	int children;
 
-	children = pmic_bind_children(dev, dev->node, pmic_children_info);
+	children = pmic_bind_children(dev, dev_ofnode(dev),
+				      pmic_children_info);
 	if (!children)
 		debug("%s: %s - no child found\n", __func__, dev->name);
 
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 58b7469f977..03eeacc286d 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
 					if (strcmp(cdev->driver->name, "fixed_rate_clock"))
 						continue;
 
-					str = ofnode_read_string(cdev->node, "clock-output-names");
+					str = ofnode_read_string(dev_ofnode(cdev),
+								 "clock-output-names");
 					if (!str)
 						continue;
 
 					if (!strcmp(str, "xtal")) {
 						err = uclass_get_device_by_ofnode(UCLASS_CLK,
-										  cdev->node,
+										  dev_ofnode(cdev),
 										  &cdev);
 						if (err) {
 							printf("%s%d: Failed to get xtal clk\n", __func__, i);
@@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
 					return -EINVAL;
 				}
 
-				err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
+				err = uclass_get_device_by_ofnode(UCLASS_CLK,
+								  dev_ofnode(cdev),
+								  &cdev);
 				if (err) {
 					printf("%s%d: Failed to get clk controller\n", __func__, i);
 					return err;
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index c64c9b5917c..98450db94b2 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
 	 * Bind it to the node, too, so that it can get its base address.
 	 */
 	ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
-					 dev->node, &sys_child);
+					 dev_ofnode(dev), &sys_child);
 	if (ret)
 		debug("Warning: No sysreset driver: ret=%d\n", ret);
 
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index b8c0216b39d..c17a5522bcc 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
-	ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
+	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
+			&cs_sck_delay);
+	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
+			&sck_cs_delay);
 
 	/* Set PCS to SCK delay scale values */
 	ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 7c38d6e0527..b898c32edc0 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
 	const char *method;
 
 	debug("optee: looking for conduit method in DT.\n");
-	method = ofnode_get_property(dev->node, "method", NULL);
+	method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
 	if (!method) {
 		debug("optee: missing \"method\" property\n");
 		return ERR_PTR(-ENXIO);
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index e861c82f7e1..798a21793f7 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 	enum usb_dr_mode dr_mode;
 	int ret = 0;
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 	cdns->role = USB_ROLE_NONE;
 
 	/*
@@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	node = ofnode_by_compatible(parent->node, "cdns,usb3");
+	node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
 	if (!ofnode_valid(node)) {
 		ret = -ENODEV;
 		goto fail;
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 2e003530a15..dfd7cf683f7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
 	 */
 	hird_threshold = 12;
 
-	dwc->hsphy_mode = usb_get_phy_mode(dev->node);
+	dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
 
 	dwc->has_lpm_erratum = dev_read_bool(dev,
 				"snps,has-lpm-erratum");
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 459add80c58..39e931f634d 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_of_to_plat(struct udevice *dev)
 {
 	struct dwc3_generic_plat *plat = dev_get_plat(dev);
-	ofnode node = dev->node;
+	ofnode node = dev_ofnode(dev);
 
 	plat->base = dev_read_addr(dev);
 
@@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	ofnode_for_each_subnode(node, parent->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
 		const char *name = ofnode_get_name(node);
 		enum usb_dr_mode dr_mode;
 		struct udevice *dev;
@@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
 	while (child) {
 		enum usb_dr_mode dr_mode;
 
-		dr_mode = usb_get_dr_mode(child->node);
+		dr_mode = usb_get_dr_mode(dev_ofnode(child));
 		device_find_next_child(&child);
 		if (ops && ops->select_dr_mode)
 			ops->select_dr_mode(dev, index, dr_mode);
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index acc7866b64a..6f99fb27f3f 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -395,7 +395,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
 	}
 #endif
 
-	priv->otg_mode = usb_get_dr_mode(dev->node);
+	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	ret = dwc3_meson_g12a_usb_init(priv);
 	if (ret)
diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c
index b63cc235f7e..08467d6210b 100644
--- a/drivers/usb/dwc3/dwc3-meson-gxl.c
+++ b/drivers/usb/dwc3/dwc3-meson-gxl.c
@@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	priv->otg_mode = usb_get_dr_mode(dev->node);
+	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
 		priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 4771b1e9312..e3871e381e1 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
-	if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
-	    usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
+	if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}
diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c
index c3cac9c5abd..742e156cbb9 100644
--- a/drivers/usb/host/dwc3-octeon-glue.c
+++ b/drivers/usb/host/dwc3-octeon-glue.c
@@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
 
 	/* Find snps,dwc3 node from subnode */
 	dwc3_node = ofnode_null();
-	ofnode_for_each_subnode(node, dev->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
 		if (ofnode_device_is_compatible(node, "snps,dwc3"))
 			dwc3_node = node;
 	}
diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index deb820a0f84..e5c6a1a67d6 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
 	int ret;
 	u32 reg[4];
 
-	ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
+	ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
+				    ARRAY_SIZE(reg));
 	if (ret) {
 		pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
 		return ret;
@@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
 	ofnode node, dwc3_node;
 
 	/* Find snps,dwc3 node from subnode */
-	ofnode_for_each_subnode(node, dev->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
 		if (ofnode_device_is_compatible(node, "snps,dwc3"))
 			dwc3_node = node;
 	}
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index d2f49cf4690..ef3a63afa44 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
 	struct usb_plat *plat = dev_get_plat(dev);
 	enum usb_dr_mode dr_mode;
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 
 	switch (dr_mode) {
 	case USB_DR_MODE_HOST:
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index 59408e4e50e..3e0ae80cece 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-	dr_mode = usb_get_dr_mode(dev->node);
+	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
 		dr_mode = USB_DR_MODE_HOST;
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 28136f88f45..2f5cc9b1480 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
 	mtu->ippc_base = ssusb->ippc_base;
 	mtu->mac_base = ssusb->mac_base;
 	mtu->ssusb = ssusb;
-	mtu->max_speed = usb_get_maximum_speed(dev->node);
+	mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
 	mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
 
 	ret = mtu3_hw_init(mtu);
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index c951107b201..b097471f3d4 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
 		return -ENODEV;
 	}
 
-	ssusb->dr_mode = usb_get_dr_mode(child->node);
+	ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
 
 	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
 		ssusb->dr_mode == USB_DR_MODE_OTG)
@@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
+	node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
 	if (!ofnode_valid(node))
 		return -ENODEV;
 
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 81b12fadfc1..75cf1811f7a 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
 	ofnode node;
 	int ret;
 
-	ofnode_for_each_subnode(node, parent->node) {
+	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
 		struct udevice *dev;
 		const char *name = ofnode_get_name(node);
 		enum usb_dr_mode dr_mode;
diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c
index 00e2c36f376..b47bef3578f 100644
--- a/drivers/video/nexell_display.c
+++ b/drivers/video/nexell_display.c
@@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
 		      __func__);
 		return NULL;
 	}
-	node = dev->node.of_offset;
+	node = dev_ofnode(dev).of_offset;
 
 	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
 		ret = nx_display_parse_dt(dev, dp, plat);
diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c
index d125a5ba737..159201a5916 100644
--- a/drivers/video/rockchip/rk_mipi.c
+++ b/drivers/video/rockchip/rk_mipi.c
@@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
 	rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
 	/* Set dpi color coding depth 24 bit */
-	timing_node = ofnode_find_subnode(dev->node, "display-timings");
+	timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");
 	node = ofnode_first_subnode(timing_node);
 
 	val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
diff --git a/include/dm/device.h b/include/dm/device.h
index 4a1224bcc26..1b274206ea3 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
  */
 static inline ofnode dev_ofnode(const struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	return dev->node;
+#else
+	return ofnode_null();
+#endif
 }
 
 /* Returns non-zero if the device is active (probed and not removed) */
@@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
 
 static inline int dev_of_offset(const struct udevice *dev)
 {
-	return ofnode_to_offset(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	return ofnode_to_offset(dev_ofnode(dev));
+#else
+	return -1;
+#endif
 }
 
 static inline bool dev_has_ofnode(const struct udevice *dev)
 {
-	return ofnode_valid(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	return ofnode_valid(dev_ofnode(dev));
+#else
+	return false;
+#endif
+}
+
+static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	dev->node = node;
+#endif
 }
 
 static inline int dev_seq(const struct udevice *dev)
diff --git a/include/dm/read.h b/include/dm/read.h
index d5cdd87911d..fc987f77598 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -21,7 +21,7 @@ struct resource;
 #if CONFIG_IS_ENABLED(OF_LIVE)
 static inline const struct device_node *dev_np(const struct udevice *dev)
 {
-	return ofnode_to_np(dev->node);
+	return ofnode_to_np(dev_ofnode(dev));
 }
 #else
 static inline const struct device_node *dev_np(const struct udevice *dev)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 54d03d02402..927854950a0 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -334,12 +334,12 @@ struct mtd_info {
 #if IS_ENABLED(CONFIG_DM)
 static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
 {
-	mtd->dev->node = node;
+	dev_set_ofnode(mtd->dev, node);
 }
 
 static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
 {
-	return mtd->dev->node;
+	return dev_ofnode(mtd->dev);
 }
 #else
 struct device_node;
diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
index 5f38f9fde41..780526c19e3 100644
--- a/net/mdio-mux-uclass.c
+++ b/net/mdio-mux-uclass.c
@@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
 	ofnode ch_node;
 	int err, first_err = 0;
 
-	if (!ofnode_valid(mux->node)) {
+	if (!dev_has_ofnode(mux)) {
 		debug("%s: no mux node found, no child MDIO busses set up\n",
 		      __func__);
 		return 0;
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index d062382c2a9..697e5f838d9 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
 	const char *dt_name;
 
 	/* set a custom name for the MDIO device, if present in DT */
-	if (ofnode_valid(dev->node)) {
-		dt_name = ofnode_read_string(dev->node, "device-name");
+	if (dev_has_ofnode(dev)) {
+		dt_name = dev_read_string(dev, "device-name");
 		if (dt_name) {
 			debug("renaming dev %s to %s\n", dev->name, dt_name);
 			device_set_name(dev, dt_name);
@@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 	struct phy_device *phy;
 	int i;
 
-	if (!ofnode_valid(ethdev->node)) {
+	if (!dev_has_ofnode(ethdev)) {
 		debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
 		return NULL;
 	}
 
 	interface = PHY_INTERFACE_MODE_NONE;
 	for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-		if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
+		if_str = dev_read_string(ethdev, phy_mode_str[i]);
 		if (if_str) {
 			interface = phy_get_interface_by_name(if_str);
 			break;
-- 
2.29.2.684.gfbc64c5ab5-goog


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 23/26] dm: core: Rename device node to indicate it is private
  2020-12-19 17:39 ` Simon Glass
                   ` (22 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

To avoid having people accidentally access this member, add a trailing
underscore. Also remove it when of-platdata is enabled, since it is not
used.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/dm/device.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/dm/device.h b/include/dm/device.h
index 1b274206ea3..4469804a00e 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -122,7 +122,6 @@ enum {
  *	access outside driver model)
  * @uclass_plat_: The uclass's configuration data for this device (do not access
  *	outside driver model)
- * @node: Reference to device tree node for this device
  * @driver_data: Driver data word for the entry that matched this device with
  *		its driver
  * @parent: Parent of this device, or NULL for the top level device
@@ -143,6 +142,8 @@ enum {
  * number. Otherwise, the next available number is used. Sequence numbers are
  * used by certain commands that need device to be numbered (e.g. 'mmc dev').
  * (do not access outside driver model)
+ * @node_: Reference to device tree node for this device (do not access outside
+ *	driver model)
  * @devres_head: List of memory allocations associated with this device.
  *		When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
  *		add to this list. Memory so-allocated will be freed
@@ -154,7 +155,6 @@ struct udevice {
 	void *plat_;
 	void *parent_plat_;
 	void *uclass_plat_;
-	ofnode node;
 	ulong driver_data;
 	struct udevice *parent;
 	void *priv_;
@@ -166,6 +166,9 @@ struct udevice {
 	struct list_head sibling_node;
 	u32 flags_;
 	int seq_;
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	ofnode node_;
+#endif
 #ifdef CONFIG_DEVRES
 	struct list_head devres_head;
 #endif
@@ -201,7 +204,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
 static inline ofnode dev_ofnode(const struct udevice *dev)
 {
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
-	return dev->node;
+	return dev->node_;
 #else
 	return ofnode_null();
 #endif
@@ -231,7 +234,7 @@ static inline bool dev_has_ofnode(const struct udevice *dev)
 static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
 {
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
-	dev->node = node;
+	dev->node_ = node;
 #endif
 }
 
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 24/26] dm: core: Split out scanning code to dm_scan()
  2020-12-19 17:39 ` Simon Glass
                   ` (23 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

Move the code related to scanning for devices to bind, into a new
function. This will make it easier to skip this step with the new
of-platdata improvements.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/root.c | 49 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index fe7359433f6..2a5ebec27d8 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -296,39 +296,60 @@ __weak int dm_scan_other(bool pre_reloc_only)
 	return 0;
 }
 
-int dm_init_and_scan(bool pre_reloc_only)
+/**
+ * dm_scan() - Scan tables to bind devices
+ *
+ * Runs through the driver_info tables and binds the devices it finds. Then runs
+ * through the devicetree nodes. Finally calls dm_scan_other() to add any
+ * special devices
+ *
+ * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
+ */
+static int dm_scan(bool pre_reloc_only)
 {
 	int ret;
 
-	if (CONFIG_IS_ENABLED(OF_PLATDATA))
-		dm_populate_phandle_data();
-
-	ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
-	if (ret) {
-		debug("dm_init() failed: %d\n", ret);
-		return ret;
-	}
 	ret = dm_scan_plat(pre_reloc_only);
 	if (ret) {
 		debug("dm_scan_plat() failed: %d\n", ret);
-		goto fail;
+		return ret;
 	}
 
 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
 		ret = dm_extended_scan(pre_reloc_only);
 		if (ret) {
 			debug("dm_extended_scan() failed: %d\n", ret);
-			goto fail;
+			return ret;
 		}
 	}
 
 	ret = dm_scan_other(pre_reloc_only);
 	if (ret)
-		goto fail;
+		return ret;
+
+	return 0;
+}
+
+int dm_init_and_scan(bool pre_reloc_only)
+{
+	int ret;
+
+	if (CONFIG_IS_ENABLED(OF_PLATDATA))
+		dm_populate_phandle_data();
+
+	ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
+	if (ret) {
+		debug("dm_init() failed: %d\n", ret);
+		return ret;
+	}
+	ret = dm_scan(pre_reloc_only);
+	if (ret) {
+		log_debug("dm_scan() failed: %d\n", ret);
+		return ret;
+	}
 
 	return 0;
-fail:
-	return ret;
 }
 
 #ifdef CONFIG_ACPIGEN
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 25/26] dm: core: Allow the uclass list to move
  2020-12-19 17:39 ` Simon Glass
                   ` (24 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

At present the uclass list head is in global_data. This is convenient
but with the new of-platdata we need the list head to be declared by
the generated code.

Change this over to be a pointer. Provide a 'static' version in
global_data to retain the current behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c             | 4 ++--
 drivers/core/root.c               | 7 ++++---
 drivers/core/uclass.c             | 4 ++--
 include/asm-generic/global_data.h | 8 +++++++-
 include/dm/device-internal.h      | 1 +
 test/dm/core.c                    | 6 +++---
 6 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6a9bee093d0..aeab3836ed7 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -613,7 +613,7 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp)
 	struct udevice *dev;
 	int ret;
 
-	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+	list_for_each_entry(uc, gd->uclass_root, sibling_node) {
 		ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node,
 						   &dev);
 		if (!ret || dev) {
@@ -1032,7 +1032,7 @@ int dev_disable_by_path(const char *path)
 	if (!of_live_active())
 		return -ENOSYS;
 
-	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+	list_for_each_entry(uc, gd->uclass_root, sibling_node) {
 		ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node, &dev);
 		if (!ret)
 			break;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 2a5ebec27d8..3adbc94eb94 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -45,8 +45,8 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
 {
 	/* The sentinel node has moved, so update things that point to it */
 	if (gd->dm_root) {
-		new_gd->uclass_root.next->prev = &new_gd->uclass_root;
-		new_gd->uclass_root.prev->next = &new_gd->uclass_root;
+		new_gd->uclass_root->next->prev = new_gd->uclass_root;
+		new_gd->uclass_root->prev->next = new_gd->uclass_root;
 	}
 }
 
@@ -136,7 +136,8 @@ int dm_init(bool of_live)
 		dm_warn("Virtual root driver already exists!\n");
 		return -EINVAL;
 	}
-	INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
+	gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
+	INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
 
 	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
 		fix_drivers();
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index e773e34833e..cdb975d5b31 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -33,7 +33,7 @@ struct uclass *uclass_find(enum uclass_id key)
 	 * node to the start of the list, or creating a linear array mapping
 	 * id to node.
 	 */
-	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+	list_for_each_entry(uc, gd->uclass_root, sibling_node) {
 		if (uc->uc_drv->id == key)
 			return uc;
 	}
@@ -84,7 +84,7 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
 	uc->uc_drv = uc_drv;
 	INIT_LIST_HEAD(&uc->sibling_node);
 	INIT_LIST_HEAD(&uc->dev_head);
-	list_add(&uc->sibling_node, &DM_UCLASS_ROOT_NON_CONST);
+	list_add(&uc->sibling_node, DM_UCLASS_ROOT_NON_CONST);
 
 	if (uc_drv->init) {
 		ret = uc_drv->init(uc);
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 87d827d0f43..b63575919f0 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -194,7 +194,13 @@ struct global_data {
 	/**
 	 * @uclass_root: head of core tree
 	 */
-	struct list_head uclass_root;
+	struct list_head uclass_root_s;
+	/**
+	 * @uclass_root: pointer to head of core tree, if uclasses are in
+	 * read-only memory and cannot be adjusted to use @uclass_root as a
+	 * list head.
+	 */
+	struct list_head *uclass_root;
 # if CONFIG_IS_ENABLED(OF_PLATDATA)
         /** Dynamic info about the driver */
 	struct driver_rt *dm_driver_rt;
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 03b092bdf7d..639bbd293d9 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -288,6 +288,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr);
 /* Cast away any volatile pointer */
 #define DM_ROOT_NON_CONST		(((gd_t *)gd)->dm_root)
 #define DM_UCLASS_ROOT_NON_CONST	(((gd_t *)gd)->uclass_root)
+#define DM_UCLASS_ROOT_S_NON_CONST	(((gd_t *)gd)->uclass_root_s)
 
 /* device resource management */
 #ifdef CONFIG_DEVRES
diff --git a/test/dm/core.c b/test/dm/core.c
index 565896ed504..580d171e30e 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -116,14 +116,14 @@ static int dm_test_autobind(struct unit_test_state *uts)
 	 * device with no children.
 	 */
 	ut_assert(dms->root);
-	ut_asserteq(1, list_count_items(&gd->uclass_root));
+	ut_asserteq(1, list_count_items(gd->uclass_root));
 	ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
 	ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
 
 	ut_assertok(dm_scan_plat(false));
 
 	/* We should have our test class now at least, plus more children */
-	ut_assert(1 < list_count_items(&gd->uclass_root));
+	ut_assert(1 < list_count_items(gd->uclass_root));
 	ut_assert(0 < list_count_items(&gd->dm_root->child_head));
 
 	/* Our 3 dm_test_infox children should be bound to the test uclass */
@@ -1073,7 +1073,7 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
 	struct udevice *dev;
 	struct uclass *uc;
 
-	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+	list_for_each_entry(uc, gd->uclass_root, sibling_node) {
 		list_for_each_entry(dev, &uc->dev_head, uclass_node) {
 			if (dev->seq_ == -1)
 				printf("Device '%s' has no seq (%d)\n",
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails
  2020-12-19 17:39 ` Simon Glass
                   ` (25 preceding siblings ...)
  (?)
@ 2020-12-19 17:40 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-19 17:40 UTC (permalink / raw)
  To: u-boot

It is useful to see the error code when this fails. Add logging for this
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/lists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 426444db3a9..e214306b904 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -251,7 +251,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		if (ret) {
 			dm_warn("Error binding driver '%s': %d\n", entry->name,
 				ret);
-			return ret;
+			return log_msg_ret("bind", ret);
 		} else {
 			found = true;
 			if (devp)
-- 
2.29.2.684.gfbc64c5ab5-goog

^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 01/26] sandbox: serial: Move priv into a header file
  2020-12-19 17:39 ` [PATCH 01/26] sandbox: serial: Move priv into a header file Simon Glass
@ 2020-12-21 11:38   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Andy Shevchenko @ 2020-12-21 11:38 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:39:53AM -0700, Simon Glass wrote:
> Move this struct into a header file so that dtoc can include it in its
> dt-platdata.c file.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  arch/sandbox/include/asm/serial.h | 30 ++++++++++++++++++++++++++++++
>  drivers/serial/sandbox.c          | 16 +---------------
>  2 files changed, 31 insertions(+), 15 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/serial.h
> 
> diff --git a/arch/sandbox/include/asm/serial.h b/arch/sandbox/include/asm/serial.h
> new file mode 100644
> index 00000000000..bc82aebd0ea
> --- /dev/null
> +++ b/arch/sandbox/include/asm/serial.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright 2020 Google LLC
> + * Written by Simon Glass <sjg@chromium.org>
> + */
> +
> +#ifndef __asm_serial_h
> +#define __asm_serial_h
> +
> +#include <dt-structs.h>
> +
> +struct sandbox_serial_plat {
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +	struct dtd_sandbox_serial dtplat;
> +#endif
> +	int colour;	/* Text colour to use for output, -1 for none */
> +};
> +
> +/**
> + * struct sandbox_serial_priv - Private data for this driver
> + *
> + * @buf: holds input characters available to be read by this driver
> + */
> +struct sandbox_serial_priv {
> +	struct membuff buf;
> +	char serial_buf[16];
> +	bool start_of_line;
> +};
> +
> +#endif /* __asm_serial_h */
> diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
> index a05c56458b0..19368ba2560 100644
> --- a/drivers/serial/sandbox.c
> +++ b/drivers/serial/sandbox.c
> @@ -17,25 +17,11 @@
>  #include <serial.h>
>  #include <video.h>
>  #include <linux/compiler.h>
> +#include <asm/serial.h>
>  #include <asm/state.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -struct sandbox_serial_plat {
> -	int colour;	/* Text colour to use for output, -1 for none */
> -};
> -
> -/**
> - * struct sandbox_serial_priv - Private data for this driver
> - *
> - * @buf: holds input characters available to be read by this driver
> - */
> -struct sandbox_serial_priv {
> -	struct membuff buf;
> -	char serial_buf[16];
> -	bool start_of_line;
> -};
> -
>  /**
>   * output_ansi_colour() - Output an ANSI colour code
>   *
> -- 
> 2.29.2.684.gfbc64c5ab5-goog
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 12/26] x86: sysreset: Move priv/plat structs to headers
  2020-12-19 17:40 ` [PATCH 12/26] x86: sysreset: Move priv/plat structs " Simon Glass
@ 2020-12-21 11:38   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Andy Shevchenko @ 2020-12-21 11:38 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:04AM -0700, Simon Glass wrote:
> With the new of-platdata, these need to be available to dt_platdata.c
> so must be in header files. Move them and add the dtd struct too.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  arch/x86/include/asm/sysreset.h | 18 ++++++++++++++++++
>  drivers/sysreset/sysreset_x86.c |  5 +----
>  2 files changed, 19 insertions(+), 4 deletions(-)
>  create mode 100644 arch/x86/include/asm/sysreset.h
> 
> diff --git a/arch/x86/include/asm/sysreset.h b/arch/x86/include/asm/sysreset.h
> new file mode 100644
> index 00000000000..5e586f51c00
> --- /dev/null
> +++ b/arch/x86/include/asm/sysreset.h
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright 2020 Google LLC
> + */
> +#ifndef _X86_ASM_SYSRESET_H_
> +#define _X86_ASM_SYSRESET_H_
> +
> +#include <dt-structs.h>
> +
> +struct x86_sysreset_plat {
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +	struct dtd_x86_reset dtplat;
> +#endif
> +
> +	struct udevice *pch;
> +};
> +
> +#endif	/* _X86_ASM_SYSRESET_H_ */
> diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c
> index 8f9970301e5..8042f3994fe 100644
> --- a/drivers/sysreset/sysreset_x86.c
> +++ b/drivers/sysreset/sysreset_x86.c
> @@ -13,10 +13,7 @@
>  #include <acpi/acpi_s3.h>
>  #include <asm/io.h>
>  #include <asm/processor.h>
> -
> -struct x86_sysreset_plat {
> -	struct udevice *pch;
> -};
> +#include <asm/sysreset.h>
>  
>  /*
>   * Power down the machine by using the power management sleep control
> -- 
> 2.29.2.684.gfbc64c5ab5-goog
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 17/26] dm: core: Rename sqq to seq_
  2020-12-19 17:40 ` [PATCH 17/26] dm: core: Rename sqq to seq_ Simon Glass
@ 2020-12-21 11:41   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Andy Shevchenko @ 2020-12-21 11:41 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:09AM -0700, Simon Glass wrote:
> Now that the sequence-numbering migration is complete, rename this member
> back to seq_, adding an underscore to indicate it is internal to driver
> model.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/core/device.c    | 8 ++++----
>  drivers/core/dump.c      | 2 +-
>  drivers/core/uclass.c    | 8 ++++----
>  drivers/pci/pci-uclass.c | 2 +-
>  include/dm/device.h      | 9 +++++----
>  test/dm/core.c           | 6 +++---
>  6 files changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 72169632c88..f4ae7786ee9 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -73,7 +73,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
>  	dev->driver = drv;
>  	dev->uclass = uc;
>  
> -	dev->sqq = -1;
> +	dev->seq_ = -1;
>  	if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
>  	    (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
>  		/*
> @@ -83,13 +83,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
>  		if (CONFIG_IS_ENABLED(OF_CONTROL) &&
>  		    !CONFIG_IS_ENABLED(OF_PLATDATA)) {
>  			if (uc->uc_drv->name && ofnode_valid(node)) {
> -				if (!dev_read_alias_seq(dev, &dev->sqq))
> +				if (!dev_read_alias_seq(dev, &dev->seq_))
>  					auto_seq = false;
>  			}
>  		}
>  	}
>  	if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
> -		dev->sqq = uclass_find_next_free_seq(uc);
> +		dev->seq_ = uclass_find_next_free_seq(uc);
>  
>  	if (drv->plat_auto) {
>  		bool alloc = !plat;
> @@ -658,7 +658,7 @@ int device_find_child_by_seq(const struct udevice *parent, int seq,
>  	*devp = NULL;
>  
>  	list_for_each_entry(dev, &parent->child_head, sibling_node) {
> -		if (dev->sqq == seq) {
> +		if (dev->seq_ == seq) {
>  			*devp = dev;
>  			return 0;
>  		}
> diff --git a/drivers/core/dump.c b/drivers/core/dump.c
> index 7784ec02dea..1d4628abc74 100644
> --- a/drivers/core/dump.c
> +++ b/drivers/core/dump.c
> @@ -69,7 +69,7 @@ static void dm_display_line(struct udevice *dev, int index)
>  	printf("%-3i %c %s @ %08lx", index,
>  	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
>  	       dev->name, (ulong)map_to_sysmem(dev));
> -	if (dev->sqq != -1)
> +	if (dev->seq_ != -1)
>  		printf(", seq %d", dev_seq(dev));
>  	puts("\n");
>  }
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index f60bc9a8504..e773e34833e 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -297,8 +297,8 @@ int uclass_find_next_free_seq(struct uclass *uc)
>  
>  	/* Avoid conflict with existing devices */
>  	list_for_each_entry(dev, &uc->dev_head, uclass_node) {
> -		if (dev->sqq > max)
> -			max = dev->sqq;
> +		if (dev->seq_ > max)
> +			max = dev->seq_;
>  	}
>  	/*
>  	 * At this point, max will be -1 if there are no existing aliases or
> @@ -323,8 +323,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq, struct udevice **devp)
>  		return ret;
>  
>  	uclass_foreach_dev(dev, uc) {
> -		log_debug("   - %d '%s'\n", dev->sqq, dev->name);
> -		if (dev->sqq == seq) {
> +		log_debug("   - %d '%s'\n", dev->seq_, dev->name);
> +		if (dev->seq_ == seq) {
>  			*devp = dev;
>  			log_debug("   - found\n");
>  			return 0;
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 37a233878d0..1f6c51f1e8d 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
>  		ret = uclass_get(UCLASS_PCI, &uc);
>  		if (ret)
>  			return ret;
> -		bus->sqq = uclass_find_next_free_seq(uc);
> +		bus->seq_ = uclass_find_next_free_seq(uc);
>  	}
>  
>  	/* For bridges, use the top-level PCI controller */
> diff --git a/include/dm/device.h b/include/dm/device.h
> index daebd6eb68d..a063bbaa176 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -136,11 +136,12 @@ enum {
>   * @child_head: List of children of this device
>   * @sibling_node: Next device in list of all devices
>   * @flags: Flags for this device DM_FLAG_...
> - * @seq: Allocated sequence number for this device (-1 = none). This is set up
> + * @seq_: Allocated sequence number for this device (-1 = none). This is set up
>   * when the device is bound and is unique within the device's uclass. If the
>   * device has an alias in the devicetree then that is used to set the sequence
>   * number. Otherwise, the next available number is used. Sequence numbers are
> - * used by certain commands that need device to be numbered (e.g. 'mmc dev')
> + * used by certain commands that need device to be numbered (e.g. 'mmc dev').
> + * (do not access outside driver model)
>   * @devres_head: List of memory allocations associated with this device.
>   *		When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
>   *		add to this list. Memory so-allocated will be freed
> @@ -163,7 +164,7 @@ struct udevice {
>  	struct list_head child_head;
>  	struct list_head sibling_node;
>  	uint32_t flags;
> -	int sqq;
> +	int seq_;
>  #ifdef CONFIG_DEVRES
>  	struct list_head devres_head;
>  #endif
> @@ -190,7 +191,7 @@ static inline bool dev_has_of_node(struct udevice *dev)
>  
>  static inline int dev_seq(const struct udevice *dev)
>  {
> -	return dev->sqq;
> +	return dev->seq_;
>  }
>  
>  /**
> diff --git a/test/dm/core.c b/test/dm/core.c
> index cf66e27db4e..b274b043882 100644
> --- a/test/dm/core.c
> +++ b/test/dm/core.c
> @@ -1075,10 +1075,10 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
>  
>  	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
>  		list_for_each_entry(dev, &uc->dev_head, uclass_node) {
> -			if (dev->sqq == -1)
> +			if (dev->seq_ == -1)
>  				printf("Device '%s' has no seq (%d)\n",
> -				       dev->name, dev->sqq);
> -			ut_assert(dev->sqq != -1);
> +				       dev->name, dev->seq_);
> +			ut_assert(dev->seq_ != -1);
>  		}
>  	}
>  
> -- 
> 2.29.2.684.gfbc64c5ab5-goog
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  2020-12-19 17:40 ` [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid() Simon Glass
@ 2020-12-21 11:41   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
  2021-01-04 11:01   ` Patrick DELAUNAY
  2 siblings, 0 replies; 65+ messages in thread
From: Andy Shevchenko @ 2020-12-21 11:41 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:13AM -0700, Simon Glass wrote:
> We have two functions which do the same thing. Standardise on
> dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in
> normal operation: it is either null or missing.
> 
> Also move the functions into one place.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/clk/clk-uclass.c            |  2 +-
>  drivers/core/device.c               |  2 +-
>  drivers/gpio/sandbox.c              |  2 +-
>  drivers/i2c/designware_i2c_pci.c    |  4 ++--
>  drivers/i2c/i2c-uclass.c            |  2 +-
>  drivers/mmc/pci_mmc.c               |  2 +-
>  drivers/pci/pci-uclass.c            |  6 +++---
>  drivers/pinctrl/pinctrl-uclass.c    |  2 +-
>  drivers/spi/spi-uclass.c            |  2 +-
>  drivers/sysreset/sysreset_sandbox.c |  2 +-
>  drivers/timer/timer-uclass.c        |  2 +-
>  drivers/usb/host/usb-uclass.c       |  2 +-
>  include/dm/device.h                 | 13 ++++++++++++-
>  include/dm/read.h                   | 16 ----------------
>  test/dm/pci.c                       |  6 +++---
>  15 files changed, 30 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index ac954a34d27..5cfd00ce771 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -345,7 +345,7 @@ int clk_set_defaults(struct udevice *dev, int stage)
>  {
>  	int ret;
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	/* If this not in SPL and pre-reloc state, don't take any action. */
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 8c7ce220f84..bd4ecc9e24d 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -485,7 +485,7 @@ int device_probe(struct udevice *dev)
>  	}
>  
>  	/* Only handle devices that have a valid ofnode */
> -	if (dev_of_valid(dev)) {
> +	if (dev_has_ofnode(dev)) {
>  		/*
>  		 * Process 'assigned-{clocks/clock-parents/clock-rates}'
>  		 * properties
> diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
> index 489271b560e..f8fa4baa2c3 100644
> --- a/drivers/gpio/sandbox.c
> +++ b/drivers/gpio/sandbox.c
> @@ -294,7 +294,7 @@ static int gpio_sandbox_probe(struct udevice *dev)
>  {
>  	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		/* Tell the uclass how many GPIOs we have */
>  		uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
>  
> diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
> index 18eef625f0f..ec0cdf62207 100644
> --- a/drivers/i2c/designware_i2c_pci.c
> +++ b/drivers/i2c/designware_i2c_pci.c
> @@ -92,7 +92,7 @@ static int designware_i2c_pci_bind(struct udevice *dev)
>  {
>  	char name[20];
>  
> -	if (dev_of_valid(dev))
> +	if (dev_has_ofnode(dev))
>  		return 0;
>  
>  	sprintf(name, "i2c_designware#%u", dev_seq(dev));
> @@ -152,7 +152,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
>  	int ret;
>  
>  	/* If no device-tree node, ignore this since we assume it isn't used */
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	ret = acpi_device_path(dev, path, sizeof(path));
> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
> index 456cf3b85fb..be56785217c 100644
> --- a/drivers/i2c/i2c-uclass.c
> +++ b/drivers/i2c/i2c-uclass.c
> @@ -678,7 +678,7 @@ static int i2c_child_post_bind(struct udevice *dev)
>  #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
>  	struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  	return i2c_chip_of_to_plat(dev, plat);
>  #else
> diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
> index fc09ad99e5e..c71c495d581 100644
> --- a/drivers/mmc/pci_mmc.c
> +++ b/drivers/mmc/pci_mmc.c
> @@ -75,7 +75,7 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
>  	struct acpi_dp *dp;
>  	int ret;
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	ret = gpio_get_acpi(&priv->cd_gpio, &gpio);
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 1f6c51f1e8d..4cdd06b1257 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -540,7 +540,7 @@ int pci_auto_config_devices(struct udevice *bus)
>  		int ret;
>  
>  		debug("%s: device %s\n", __func__, dev->name);
> -		if (dev_of_valid(dev) &&
> +		if (dev_has_ofnode(dev) &&
>  		    dev_read_bool(dev, "pci,no-autoconfig"))
>  			continue;
>  		ret = dm_pciauto_config_device(dev);
> @@ -1036,7 +1036,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
>  	hose->bus = bus;
>  	hose->first_busno = dev_seq(bus);
>  	hose->last_busno = dev_seq(bus);
> -	if (dev_of_valid(bus)) {
> +	if (dev_has_ofnode(bus)) {
>  		hose->skip_auto_config_until_reloc =
>  			dev_read_bool(bus,
>  				      "u-boot,skip-auto-config-until-reloc");
> @@ -1091,7 +1091,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
>  {
>  	struct pci_child_plat *pplat;
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	pplat = dev_get_parent_plat(dev);
> diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
> index 4653e86ba46..7919e54e8de 100644
> --- a/drivers/pinctrl/pinctrl-uclass.c
> +++ b/drivers/pinctrl/pinctrl-uclass.c
> @@ -112,7 +112,7 @@ static int pinconfig_post_bind(struct udevice *dev)
>  	ofnode node;
>  	int ret;
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	dev_for_each_subnode(node, dev) {
> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
> index f3b8ffad425..8bd35a551b8 100644
> --- a/drivers/spi/spi-uclass.c
> +++ b/drivers/spi/spi-uclass.c
> @@ -155,7 +155,7 @@ static int spi_child_post_bind(struct udevice *dev)
>  {
>  	struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev);
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	return spi_slave_of_to_plat(dev, plat);
> diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
> index 7026a48c4b2..8eca7d8bfda 100644
> --- a/drivers/sysreset/sysreset_sandbox.c
> +++ b/drivers/sysreset/sysreset_sandbox.c
> @@ -50,7 +50,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
>  	 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
>  	 * If we are that device, return an error.
>  	 */
> -	if (state->fdt_fname && !dev_of_valid(dev))
> +	if (state->fdt_fname && !dev_has_ofnode(dev))
>  		return -ENODEV;
>  
>  	switch (type) {
> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
> index 8e63c17e9f3..da1a72f0252 100644
> --- a/drivers/timer/timer-uclass.c
> +++ b/drivers/timer/timer-uclass.c
> @@ -54,7 +54,7 @@ static int timer_pre_probe(struct udevice *dev)
>  	ulong ret;
>  
>  	/* It is possible that a timer device has a null ofnode */
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	err = clk_get_by_index(dev, 0, &timer_clk);
> diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
> index ae6b1450d3a..e3b616c3266 100644
> --- a/drivers/usb/host/usb-uclass.c
> +++ b/drivers/usb/host/usb-uclass.c
> @@ -773,7 +773,7 @@ static int usb_child_post_bind(struct udevice *dev)
>  	struct usb_dev_plat *plat = dev_get_parent_plat(dev);
>  	int val;
>  
> -	if (!dev_of_valid(dev))
> +	if (!dev_has_ofnode(dev))
>  		return 0;
>  
>  	/* We only support matching a few things */
> diff --git a/include/dm/device.h b/include/dm/device.h
> index b15a14ec330..4a1224bcc26 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -192,6 +192,17 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
>  	dev->flags_ &= ~bic;
>  }
>  
> +/**
> + * dev_ofnode() - get the DT node reference associated with a udevice
> + *
> + * @dev:	device to check
> + * @return reference of the the device's DT node
> + */
> +static inline ofnode dev_ofnode(const struct udevice *dev)
> +{
> +	return dev->node;
> +}
> +
>  /* Returns non-zero if the device is active (probed and not removed) */
>  #define device_active(dev)	(dev_get_flags(dev) & DM_FLAG_ACTIVATED)
>  
> @@ -200,7 +211,7 @@ static inline int dev_of_offset(const struct udevice *dev)
>  	return ofnode_to_offset(dev->node);
>  }
>  
> -static inline bool dev_has_ofnode(struct udevice *dev)
> +static inline bool dev_has_ofnode(const struct udevice *dev)
>  {
>  	return ofnode_valid(dev->node);
>  }
> diff --git a/include/dm/read.h b/include/dm/read.h
> index 0585eb12281..d5cdd87911d 100644
> --- a/include/dm/read.h
> +++ b/include/dm/read.h
> @@ -30,22 +30,6 @@ static inline const struct device_node *dev_np(const struct udevice *dev)
>  }
>  #endif
>  
> -/**
> - * dev_ofnode() - get the DT node reference associated with a udevice
> - *
> - * @dev:	device to check
> - * @return reference of the the device's DT node
> - */
> -static inline ofnode dev_ofnode(const struct udevice *dev)
> -{
> -	return dev->node;
> -}
> -
> -static inline bool dev_of_valid(const struct udevice *dev)
> -{
> -	return ofnode_valid(dev_ofnode(dev));
> -}
> -
>  #ifndef CONFIG_DM_DEV_READ_INLINE
>  
>  /**
> diff --git a/test/dm/pci.c b/test/dm/pci.c
> index 76490befdf5..fa2e4a85596 100644
> --- a/test/dm/pci.c
> +++ b/test/dm/pci.c
> @@ -120,13 +120,13 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts)
>  
>  	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
>  	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
> -	ut_assertok(dev_of_valid(swap));
> +	ut_assertok(dev_has_ofnode(swap));
>  	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap));
>  	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
> -	ut_assertok(dev_of_valid(swap));
> +	ut_assertok(dev_has_ofnode(swap));
>  	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x10, 0), &swap));
>  	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
> -	ut_assertok(!dev_of_valid(swap));
> +	ut_assertok(!dev_has_ofnode(swap));
>  
>  	return 0;
>  }
> -- 
> 2.29.2.684.gfbc64c5ab5-goog
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 25/26] dm: core: Allow the uclass list to move
  2020-12-19 17:39 ` Simon Glass
                   ` (26 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present the uclass list head is in global_data. This is convenient
but with the new of-platdata we need the list head to be declared by
the generated code.

Change this over to be a pointer. Provide a 'static' version in
global_data to retain the current behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c             | 4 ++--
 drivers/core/root.c               | 7 ++++---
 drivers/core/uclass.c             | 4 ++--
 include/asm-generic/global_data.h | 8 +++++++-
 include/dm/device-internal.h      | 1 +
 test/dm/core.c                    | 6 +++---
 6 files changed, 19 insertions(+), 11 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails
  2020-12-19 17:39 ` Simon Glass
                   ` (27 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

It is useful to see the error code when this fails. Add logging for this
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/lists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 24/26] dm: core: Split out scanning code to dm_scan()
  2020-12-19 17:39 ` Simon Glass
                   ` (28 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

Move the code related to scanning for devices to bind, into a new
function. This will make it easier to skip this step with the new
of-platdata improvements.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/root.c | 49 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 14 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 23/26] dm: core: Rename device node to indicate it is private
  2020-12-19 17:39 ` Simon Glass
                   ` (29 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

To avoid having people accidentally access this member, add a trailing
underscore. Also remove it when of-platdata is enabled, since it is not
used.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/dm/device.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 22/26] dm: core: Access device ofnode through functions
  2020-12-19 17:39 ` Simon Glass
@ 2020-12-28 16:26   ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
 board/synopsys/hsdk/clk-lib.c             |  2 +-
 drivers/ata/mtk_ahci.c                    |  3 ++-
 drivers/clk/meson/axg.c                   |  2 +-
 drivers/clk/meson/g12a.c                  |  2 +-
 drivers/clk/meson/gxbb.c                  |  2 +-
 drivers/core/device.c                     |  2 +-
 drivers/core/root.c                       |  2 +-
 drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
 drivers/gpio/octeon_gpio.c                |  2 +-
 drivers/misc/swap_case.c                  |  2 +-
 drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
 drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
 drivers/mtd/nand/spi/core.c               |  2 +-
 drivers/net/fm/eth.c                      |  4 ++--
 drivers/net/fsl_enetc.c                   |  8 ++++----
 drivers/net/fsl_enetc_mdio.c              |  2 +-
 drivers/net/mdio-ipq4019.c                |  4 ++--
 drivers/net/mdio_mux_i2creg.c             |  2 +-
 drivers/net/mvmdio.c                      |  4 ++--
 drivers/net/octeontx/smi.c                |  2 +-
 drivers/net/tsec.c                        |  3 ++-
 drivers/phy/phy-ti-am654.c                |  2 +-
 drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
 drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
 drivers/power/regulator/pbias_regulator.c |  3 ++-
 drivers/pwm/pwm-meson.c                   |  9 ++++++---
 drivers/reset/reset-socfpga.c             |  2 +-
 drivers/spi/fsl_dspi.c                    |  6 ++++--
 drivers/tee/optee/core.c                  |  2 +-
 drivers/usb/cdns3/core.c                  |  4 ++--
 drivers/usb/dwc3/core.c                   |  2 +-
 drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
 drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
 drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
 drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
 drivers/usb/host/ehci-mx6.c               |  2 +-
 drivers/usb/host/xhci-dwc3.c              |  2 +-
 drivers/usb/mtu3/mtu3_core.c              |  2 +-
 drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
 drivers/usb/musb-new/ti-musb.c            |  2 +-
 drivers/video/nexell_display.c            |  2 +-
 drivers/video/rockchip/rk_mipi.c          |  2 +-
 include/dm/device.h                       | 23 +++++++++++++++++++++--
 include/dm/read.h                         |  2 +-
 include/linux/mtd/mtd.h                   |  4 ++--
 net/mdio-mux-uclass.c                     |  2 +-
 net/mdio-uclass.c                         |  8 ++++----
 50 files changed, 113 insertions(+), 82 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 22/26] dm: core: Access device ofnode through functions
@ 2020-12-28 16:26   ` Simon Glass
  0 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: Simon Glass
  Cc: Aaron Williams, Alexey Brodkin, Anatolij Gustschin, Bin Meng,
	Chunfeng Yun, Daniel Schwierzeck, Eugeniy Paltsev, Frank Wang,
	Frank Wunderlich, GSS_MTK_Uboot_upstream, Jaehoon Chung,
	Jagan Teki, Jens Wiklander, Joe Hershberger, Kever Yang,
	Ley Foon Tan, Lokesh Vutla, Luka Kovacic, Luka Perkov,
	Lukasz Majewski, Madalin Bucur, Marek Vasut, Masahiro Yamada,
	Michal Simek, Neil Armstrong, Patrice Chotard, Patrick Delaunay,
	Pavel Herrmann, Peng Fan, Philipp Tomsich, Priyanka Jain,
	Rasmus Villemoes, Robert Marko, Ryder Lee, Sean Anderson,
	Siva Durga Prasad Paladugu, Stefan Bosch, Stefan Roese,
	Suneel Garapati, Weijie Gao, hui.song, u-boot-amlogic,
	uboot-snps-arc, uboot-stm32, U-Boot Mailing List

At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
 board/synopsys/hsdk/clk-lib.c             |  2 +-
 drivers/ata/mtk_ahci.c                    |  3 ++-
 drivers/clk/meson/axg.c                   |  2 +-
 drivers/clk/meson/g12a.c                  |  2 +-
 drivers/clk/meson/gxbb.c                  |  2 +-
 drivers/core/device.c                     |  2 +-
 drivers/core/root.c                       |  2 +-
 drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
 drivers/gpio/octeon_gpio.c                |  2 +-
 drivers/misc/swap_case.c                  |  2 +-
 drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
 drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
 drivers/mtd/nand/spi/core.c               |  2 +-
 drivers/net/fm/eth.c                      |  4 ++--
 drivers/net/fsl_enetc.c                   |  8 ++++----
 drivers/net/fsl_enetc_mdio.c              |  2 +-
 drivers/net/mdio-ipq4019.c                |  4 ++--
 drivers/net/mdio_mux_i2creg.c             |  2 +-
 drivers/net/mvmdio.c                      |  4 ++--
 drivers/net/octeontx/smi.c                |  2 +-
 drivers/net/tsec.c                        |  3 ++-
 drivers/phy/phy-ti-am654.c                |  2 +-
 drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
 drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
 drivers/power/regulator/pbias_regulator.c |  3 ++-
 drivers/pwm/pwm-meson.c                   |  9 ++++++---
 drivers/reset/reset-socfpga.c             |  2 +-
 drivers/spi/fsl_dspi.c                    |  6 ++++--
 drivers/tee/optee/core.c                  |  2 +-
 drivers/usb/cdns3/core.c                  |  4 ++--
 drivers/usb/dwc3/core.c                   |  2 +-
 drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
 drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
 drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
 drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
 drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
 drivers/usb/host/ehci-mx6.c               |  2 +-
 drivers/usb/host/xhci-dwc3.c              |  2 +-
 drivers/usb/mtu3/mtu3_core.c              |  2 +-
 drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
 drivers/usb/musb-new/ti-musb.c            |  2 +-
 drivers/video/nexell_display.c            |  2 +-
 drivers/video/rockchip/rk_mipi.c          |  2 +-
 include/dm/device.h                       | 23 +++++++++++++++++++++--
 include/dm/read.h                         |  2 +-
 include/linux/mtd/mtd.h                   |  4 ++--
 net/mdio-mux-uclass.c                     |  2 +-
 net/mdio-uclass.c                         |  8 ++++----
 50 files changed, 113 insertions(+), 82 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  2020-12-19 17:40 ` [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid() Simon Glass
  2020-12-21 11:41   ` Andy Shevchenko
@ 2020-12-28 16:26   ` Simon Glass
  2021-01-04 11:01   ` Patrick DELAUNAY
  2 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:13AM -0700, Simon Glass wrote:
> We have two functions which do the same thing. Standardise on
> dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in
> normal operation: it is either null or missing.
>
> Also move the functions into one place.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/clk/clk-uclass.c            |  2 +-
>  drivers/core/device.c               |  2 +-
>  drivers/gpio/sandbox.c              |  2 +-
>  drivers/i2c/designware_i2c_pci.c    |  4 ++--
>  drivers/i2c/i2c-uclass.c            |  2 +-
>  drivers/mmc/pci_mmc.c               |  2 +-
>  drivers/pci/pci-uclass.c            |  6 +++---
>  drivers/pinctrl/pinctrl-uclass.c    |  2 +-
>  drivers/spi/spi-uclass.c            |  2 +-
>  drivers/sysreset/sysreset_sandbox.c |  2 +-
>  drivers/timer/timer-uclass.c        |  2 +-
>  drivers/usb/host/usb-uclass.c       |  2 +-
>  include/dm/device.h                 | 13 ++++++++++++-
>  include/dm/read.h                   | 16 ----------------
>  test/dm/pci.c                       |  6 +++---
>  15 files changed, 30 insertions(+), 35 deletions(-)
>
Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode()
  2020-12-19 17:39 ` Simon Glass
                   ` (31 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

We use 'ofnode' rather than 'of_node' in U-Boot. Rename this function to
fit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c            | 2 +-
 drivers/mmc/octeontx_hsmmc.c     | 2 +-
 drivers/pinctrl/pinctrl-uclass.c | 2 +-
 drivers/usb/host/usb-uclass.c    | 2 +-
 include/dm/device.h              | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 19/26] dm: core: Rename device flags to indicate it is private
  2020-12-19 17:39 ` Simon Glass
                   ` (32 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

To avoid having people accidentally access this member, add a trailing
underscore.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/dm/device.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 18/26] dm: core: Access device flags through functions
  2020-12-19 17:39 ` Simon Glass
                   ` (33 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present flags are stored as part of the device. In preparation for
storing them separately, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/remoteproc.c                     |  2 +-
 drivers/clk/clk.c                    |  2 +-
 drivers/core/device-remove.c         | 18 ++++++++--------
 drivers/core/device.c                | 32 ++++++++++++++--------------
 drivers/core/devres.c                |  4 ++--
 drivers/core/dump.c                  |  4 ++--
 drivers/mtd/nand/raw/octeontx_nand.c |  2 +-
 drivers/remoteproc/rproc-uclass.c    |  2 +-
 drivers/serial/serial-uclass.c       |  2 +-
 include/dm/device.h                  | 15 +++++++++++++
 include/virtio.h                     |  2 +-
 test/dm/bus.c                        | 10 ++++-----
 test/dm/core.c                       | 14 ++++++------
 test/dm/cpu.c                        |  2 +-
 test/dm/test-fdt.c                   | 20 ++++++++---------
 test/dm/virtio.c                     |  2 +-
 16 files changed, 74 insertions(+), 59 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 17/26] dm: core: Rename sqq to seq_
  2020-12-19 17:40 ` [PATCH 17/26] dm: core: Rename sqq to seq_ Simon Glass
  2020-12-21 11:41   ` Andy Shevchenko
@ 2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:09AM -0700, Simon Glass wrote:
> Now that the sequence-numbering migration is complete, rename this member
> back to seq_, adding an underscore to indicate it is internal to driver
> model.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/core/device.c    | 8 ++++----
>  drivers/core/dump.c      | 2 +-
>  drivers/core/uclass.c    | 8 ++++----
>  drivers/pci/pci-uclass.c | 2 +-
>  include/dm/device.h      | 9 +++++----
>  test/dm/core.c           | 6 +++---
>  6 files changed, 18 insertions(+), 17 deletions(-)
>
Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 16/26] dm: core: Split out alloc code into a new function
  2020-12-19 17:39 ` Simon Glass
                   ` (34 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

Add a new function to handle the allocation of private/platform data for
a device. This will make it easier to skip this feature when using the new
of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 89 +++++++++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 37 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 15/26] x86: Drop rtc from SPL
  2020-12-19 17:39 ` Simon Glass
                   ` (35 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

The RTC is not currently used in SPL. Drop it so that it does not take up
space.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/rtc.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL
  2020-12-19 17:39 ` Simon Glass
                   ` (36 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

Some devices are not needed in SPL/TPL. For TPL this causes the
generation of unnecessary of-platadata structs. Make some adjustments to
fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/chromebook_coral.dts | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data
  2020-12-19 17:39 ` Simon Glass
                   ` (37 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present this driver calls malloc() to start a new platform data
structure, fills it in and tells driver model to use it.

We want to avoid malloc, particularly with the new version of of-platdata.
Create a new struct which encompasses both the dtd struct and the ns16550
one, to avoid this. Unfortunately we must copy the data into the right
place for the ns16550 driver. Add some comments about this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/uart.c              | 43 ++++++++++++---------
 arch/x86/include/asm/arch-apollolake/uart.h | 19 ++++++++-
 2 files changed, 42 insertions(+), 20 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 12/26] x86: sysreset: Move priv/plat structs to headers
  2020-12-19 17:40 ` [PATCH 12/26] x86: sysreset: Move priv/plat structs " Simon Glass
  2020-12-21 11:38   ` Andy Shevchenko
@ 2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:40:04AM -0700, Simon Glass wrote:
> With the new of-platdata, these need to be available to dt_platdata.c
> so must be in header files. Move them and add the dtd struct too.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/include/asm/sysreset.h | 18 ++++++++++++++++++
>  drivers/sysreset/sysreset_x86.c |  5 +----
>  2 files changed, 19 insertions(+), 4 deletions(-)
>  create mode 100644 arch/x86/include/asm/sysreset.h
>
Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (38 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/simple-bus.c |  7 +------
 include/dm/simple_bus.h   | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 include/dm/simple_bus.h

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash
  2020-12-19 17:39 ` Simon Glass
                   ` (40 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

This construct effectively uses struct spi_nor due to a #define in
spi-nor.h so we may as well use that struct here. This allows dtoc to
parse it correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata
  2020-12-19 17:39 ` Simon Glass
                   ` (39 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

The #define of one struct to another has been around for a while. It
confuses dtoc and makes it think that struct spi_flash does not exist.

Make a few changes to improve things while we wait for migration to be
completed:

- Move the 'struct spi_flash' to column 1 so dtoc scans it
- Remove the #define when compiling dt-platdata.c
- Update the strange mtd_get/set_of_node() functions
- Use struct spi_nor in the drivers, so dtoc sees the correct struct

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sf-uclass.c | 2 +-
 drivers/mtd/spi/sf_probe.c  | 2 +-
 include/linux/mtd/spi-nor.h | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 08/26] spi: Tidy up get/set of device node
  2020-12-19 17:39 ` Simon Glass
                   ` (41 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

This code is a bit odd in that it only reads and updates the livetree
version of the device ofnode. This means it won't work with flattree.
Update the code to work as it was presumably intended.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/nand/spi/core.c |  2 +-
 include/linux/mtd/mtd.h     |  9 ++++-----
 include/linux/mtd/nand.h    | 14 ++++++++++++++
 include/linux/mtd/spi-nor.h |  2 ++
 include/linux/mtd/spinand.h | 15 +++++++++++++++
 5 files changed, 36 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 07/26] x86: spl: Move priv/plat structs to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (42 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/spi/ich.c | 11 -----------
 drivers/spi/ich.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 06/26] x86: Move priv/plat structs for intel_common to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (43 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/intel_common/itss.c | 19 -------------------
 arch/x86/cpu/intel_common/p2sb.c |  9 +--------
 arch/x86/include/asm/itss.h      | 21 +++++++++++++++++++++
 arch/x86/include/asm/p2sb.h      | 18 ++++++++++++++++++
 4 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 arch/x86/include/asm/p2sb.h

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 05/26] x86: apl: Move priv/plat structs to headers
  2020-12-19 17:39 ` Simon Glass
                   ` (44 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

With the new of-platdata, these need to be available to dt_platdata.c
so must be in header files. Move them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/apollolake/hostbridge.c          | 20 +------------
 arch/x86/cpu/apollolake/pmc.c                 |  8 +-----
 arch/x86/include/asm/arch-apollolake/gpio.h   | 18 ++++++++++++
 .../include/asm/arch-apollolake/hostbridge.h  | 28 +++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/pmc.h    | 16 +++++++++++
 drivers/pinctrl/intel/pinctrl_apl.c           | 12 --------
 6 files changed, 64 insertions(+), 38 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-apollolake/hostbridge.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/pmc.h

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 04/26] sandbox: Update dts files to reduce SPL size
  2020-12-19 17:39 ` Simon Glass
                   ` (45 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present there are require a few devices in the devicetree which are
not actually used in SPL. This will cause problems with the new
of-platdata, since it will try to instantiate devices which are not
compiled into U-Boot.

Update the devicetree to remove these devices from SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox.dts  |  4 ++--
 arch/sandbox/dts/sandbox.dtsi | 11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 03/26] sandbox: Add a compatible string for spltest
  2020-12-19 17:39 ` Simon Glass
                   ` (46 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

At present this driver does not have a compatible string. For it to be
used with the coming of-platadata, it must have one. Update it
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/spltest_sandbox.c | 6 ++++++
 1 file changed, 6 insertions(+)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 02/26] sandbox: i2c: Move priv into a header file
  2020-12-19 17:39 ` Simon Glass
                   ` (47 preceding siblings ...)
  (?)
@ 2020-12-28 16:26 ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

Move this struct into a header file so that dtoc can include it in its
dt-platdata.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/include/asm/i2c.h | 14 ++++++++++++++
 drivers/i2c/sandbox_i2c.c      |  5 +----
 2 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 arch/sandbox/include/asm/i2c.h

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 01/26] sandbox: serial: Move priv into a header file
  2020-12-19 17:39 ` [PATCH 01/26] sandbox: serial: Move priv into a header file Simon Glass
  2020-12-21 11:38   ` Andy Shevchenko
@ 2020-12-28 16:26   ` Simon Glass
  1 sibling, 0 replies; 65+ messages in thread
From: Simon Glass @ 2020-12-28 16:26 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 19, 2020 at 10:39:53AM -0700, Simon Glass wrote:
> Move this struct into a header file so that dtoc can include it in its
> dt-platdata.c file.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/sandbox/include/asm/serial.h | 30 ++++++++++++++++++++++++++++++
>  drivers/serial/sandbox.c          | 16 +---------------
>  2 files changed, 31 insertions(+), 15 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/serial.h
>
Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid()
  2020-12-19 17:40 ` [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid() Simon Glass
  2020-12-21 11:41   ` Andy Shevchenko
  2020-12-28 16:26   ` Simon Glass
@ 2021-01-04 11:01   ` Patrick DELAUNAY
  2 siblings, 0 replies; 65+ messages in thread
From: Patrick DELAUNAY @ 2021-01-04 11:01 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 12/19/20 6:40 PM, Simon Glass wrote:
> We have two functions which do the same thing. Standardise on
> dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in
> normal operation: it is either null or missing.
>
> Also move the functions into one place.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   drivers/clk/clk-uclass.c            |  2 +-
>   drivers/core/device.c               |  2 +-
>   drivers/gpio/sandbox.c              |  2 +-
>   drivers/i2c/designware_i2c_pci.c    |  4 ++--
>   drivers/i2c/i2c-uclass.c            |  2 +-
>   drivers/mmc/pci_mmc.c               |  2 +-
>   drivers/pci/pci-uclass.c            |  6 +++---
>   drivers/pinctrl/pinctrl-uclass.c    |  2 +-
>   drivers/spi/spi-uclass.c            |  2 +-
>   drivers/sysreset/sysreset_sandbox.c |  2 +-
>   drivers/timer/timer-uclass.c        |  2 +-
>   drivers/usb/host/usb-uclass.c       |  2 +-
>   include/dm/device.h                 | 13 ++++++++++++-
>   include/dm/read.h                   | 16 ----------------
>   test/dm/pci.c                       |  6 +++---
>   15 files changed, 30 insertions(+), 35 deletions(-)
>
Reviewed-by: Patrick Delaunay

Thanks

Patrick

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 22/26] dm: core: Access device ofnode through functions
  2020-12-19 17:40   ` Simon Glass
@ 2021-01-04 13:02     ` Patrick DELAUNAY
  -1 siblings, 0 replies; 65+ messages in thread
From: Patrick DELAUNAY @ 2021-01-04 13:02 UTC (permalink / raw)
  To: u-boot

Hi Simon,


On 12/19/20 6:40 PM, Simon Glass wrote:
> At present ofnode is present in the device even if it is never used. With
> of-platdata this field is not used, so can be removed. In preparation for
> this, change the access to go through inline functions.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
>   board/synopsys/hsdk/clk-lib.c             |  2 +-
>   drivers/ata/mtk_ahci.c                    |  3 ++-
>   drivers/clk/meson/axg.c                   |  2 +-
>   drivers/clk/meson/g12a.c                  |  2 +-
>   drivers/clk/meson/gxbb.c                  |  2 +-
>   drivers/core/device.c                     |  2 +-
>   drivers/core/root.c                       |  2 +-
>   drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
>   drivers/gpio/octeon_gpio.c                |  2 +-
>   drivers/misc/swap_case.c                  |  2 +-
>   drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
>   drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
>   drivers/mtd/nand/spi/core.c               |  2 +-
>   drivers/net/fm/eth.c                      |  4 ++--
>   drivers/net/fsl_enetc.c                   |  8 ++++----
>   drivers/net/fsl_enetc_mdio.c              |  2 +-
>   drivers/net/mdio-ipq4019.c                |  4 ++--
>   drivers/net/mdio_mux_i2creg.c             |  2 +-
>   drivers/net/mvmdio.c                      |  4 ++--
>   drivers/net/octeontx/smi.c                |  2 +-
>   drivers/net/tsec.c                        |  3 ++-
>   drivers/phy/phy-ti-am654.c                |  2 +-
>   drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
>   drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
>   drivers/power/regulator/pbias_regulator.c |  3 ++-
>   drivers/pwm/pwm-meson.c                   |  9 ++++++---
>   drivers/reset/reset-socfpga.c             |  2 +-
>   drivers/spi/fsl_dspi.c                    |  6 ++++--
>   drivers/tee/optee/core.c                  |  2 +-
>   drivers/usb/cdns3/core.c                  |  4 ++--
>   drivers/usb/dwc3/core.c                   |  2 +-
>   drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
>   drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
>   drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
>   drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
>   drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
>   drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
>   drivers/usb/host/ehci-mx6.c               |  2 +-
>   drivers/usb/host/xhci-dwc3.c              |  2 +-
>   drivers/usb/mtu3/mtu3_core.c              |  2 +-
>   drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
>   drivers/usb/musb-new/ti-musb.c            |  2 +-
>   drivers/video/nexell_display.c            |  2 +-
>   drivers/video/rockchip/rk_mipi.c          |  2 +-
>   include/dm/device.h                       | 23 +++++++++++++++++++++--
>   include/dm/read.h                         |  2 +-
>   include/linux/mtd/mtd.h                   |  4 ++--
>   net/mdio-mux-uclass.c                     |  2 +-
>   net/mdio-uclass.c                         |  8 ++++----
>   50 files changed, 113 insertions(+), 82 deletions(-)

in all the modified drivers,
for the functions ofnode_XXXX(dev->node,...) modified to ofnode_XXXX(dev_ofnode(dev),
they can also modified to dev_XXX function :

ofnode_read_u32(dev_ofnode(dev), ...) => dev_read_u32(dev,....)
ofnode_read_string(dev_ofnode(dev), ...) => dev_read_string(dev,....)
ofnode_valid(dev_ofnode(dev)) => dev_has_ofnode(dev)

but you prefer perhaps minizes the modifications in this patchset and if 
it is the case :

Reviewed-by: Patrick Delaunay


You can found some other examples below.

>
> diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
> index af6ea439646..766ed95f1a6 100644
> --- a/arch/arm/mach-stm32mp/pwr_regulator.c
> +++ b/arch/arm/mach-stm32mp/pwr_regulator.c
> @@ -81,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
>   {
>   	int children;
>   
> -	children = pmic_bind_children(dev, dev->node, pwr_children_info);
> +	children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
>   	if (!children)
>   		dev_dbg(dev, "no child found\n");
>   
> diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
> index 1c74bfb93a3..bd43179fc79 100644
> --- a/board/synopsys/hsdk/clk-lib.c
> +++ b/board/synopsys/hsdk/clk-lib.c
> @@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
>   	/* Dummy fmeas device, just to be able to use standard clk_* api */
>   	struct udevice fmeas = {
>   		.name = "clk-fmeas",
> -		.node = ofnode_path("/clk-fmeas"),
>   	};
> +	dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
>   
>   	ret = clk_get_by_name(&fmeas, name, &clk);
>   	if (ret) {
> diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
> index cd28e0cae37..46b7677783f 100644
> --- a/drivers/ata/mtk_ahci.c
> +++ b/drivers/ata/mtk_ahci.c
> @@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
>   				   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
>   	}
>   
> -	ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
> +	ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
> +			&hpriv->port_map);

dev_read_u32(dev, "ports-implemented", &hpriv->port_map);

>   	return 0;
>   }
>   
> diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
> index 82068578ffb..d6da59d269b 100644
> --- a/drivers/clk/meson/axg.c
> +++ b/drivers/clk/meson/axg.c
> @@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
> index 01b22abc34d..5058db1a47b 100644
> --- a/drivers/clk/meson/g12a.c
> +++ b/drivers/clk/meson/g12a.c
> @@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
> index 2a20541dcb4..e379540deee 100644
> --- a/drivers/clk/meson/gxbb.c
> +++ b/drivers/clk/meson/gxbb.c
> @@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index bd4ecc9e24d..6a9bee093d0 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
>   	dev_set_plat(dev, plat);
>   	dev->driver_data = driver_data;
>   	dev->name = name;
> -	dev->node = node;
> +	dev_set_ofnode(dev, node);
>   	dev->parent = parent;
>   	dev->driver = drv;
>   	dev->uclass = uc;
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 9ef242979ba..fe7359433f6 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -148,7 +148,7 @@ int dm_init(bool of_live)
>   	if (ret)
>   		return ret;
>   	if (CONFIG_IS_ENABLED(OF_CONTROL))
> -		DM_ROOT_NON_CONST->node = ofnode_root();
> +		dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
>   	ret = device_probe(DM_ROOT_NON_CONST);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
> index 2bc1a0d5716..a964347fa32 100644
> --- a/drivers/gpio/mpc8xxx_gpio.c
> +++ b/drivers/gpio/mpc8xxx_gpio.c
> @@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
>   	u32 i;
>   	u32 reg[4];
>   
> -	if (ofnode_read_bool(dev->node, "little-endian"))
> +	if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))

if (dev_read_bool(dev, "little-endian"))

>   		data->little_endian = true;
>   
>   	if (data->little_endian)
> @@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
>   	if (!str)
>   		return -ENOMEM;
>   
> -	if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
> +	if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
>   		unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
>   			- sizeof(u32);
>   
> diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c
> index 958516d8f8e..42eae79d8c4 100644
> --- a/drivers/gpio/octeon_gpio.c
> +++ b/drivers/gpio/octeon_gpio.c
> @@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
>   			GPIO_CONST_GPIOS_MASK;
>   	} else {
>   		priv->base = dev_remap_addr(dev);
> -		uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
> +		uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
>   							      "nr-gpios", 32);

uc_priv->gpio_count = dev_read_u32_default(dev, "nr-gpios", 32);

>   	}
>   
> diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
> index abea0e76139..3cbc8f37ec5 100644
> --- a/drivers/misc/swap_case.c
> +++ b/drivers/misc/swap_case.c
> @@ -54,7 +54,7 @@ struct swap_case_priv {
>   
>   static int sandbox_swap_case_use_ea(const struct udevice *dev)
>   {
> -	return !!ofnode_get_property(dev->node, "use-ea", NULL);
> +	return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);

return !!dev_read_prop(dev, "use-ea", NULL);

>   }
>   
>   /* Please keep these macros in sync with ea_regs below */
> diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
> index f3da6af9090..442ca493d76 100644
> --- a/drivers/mmc/octeontx_hsmmc.c
> +++ b/drivers/mmc/octeontx_hsmmc.c
> @@ -3439,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
>    */
>   static bool octeontx_mmc_get_valid(struct udevice *dev)
>   {
> -	const char *stat = ofnode_read_string(dev->node, "status");
> +	const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
>   

const char *stat = dev_read_string(dev, "status");

>   	if (!stat || !strncmp(stat, "ok", 2))
>   		return true;
> @@ -3461,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
>   	uint low, high;
>   	char env_name[32];
>   	int err;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	int bus_width = 1;
>   	ulong new_max_freq;
>   
>   	debug("%s(%s)", __func__, dev->name);
>   	slot->cfg.name = dev->name;
>   
> -	slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
> +	slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
> +						  "max-frequency",
>   						  26000000);

slot->cfg.f_max = dev_read_s32_default(dev, "max-frequency", 26000000);

>   	snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
>   		 slot->bus_id);
> @@ -3486,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
>   
>   	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
>   		slot->hs400_tuning_block =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs400-tuning-block",
>   						-1);
idem
>   		debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
>   		      dev->name, slot->hs400_tuning_block);
>   
>   		slot->hs200_tap_adj =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs200-tap-adjust", 0);
idem
>   		debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
>   		      slot->hs200_tap_adj);
>   		slot->hs400_tap_adj =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs400-tap-adjust", 0);
idem
>   		debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
>   		      slot->hs400_tap_adj);
>   	}
>   
> -	err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
> +	err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
> +				    voltages, 2);
idem
>   	if (err) {
>   		slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
>   	} else {
> @@ -3756,14 +3758,15 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
>   		pr_err("%s: No device tree information found\n", __func__);
>   		return -1;
>   	}
> -	host->node = dev->node;
> +	host->node = dev_ofnode(dev);
>   	host->last_slotid = -1;
>   	if (otx_is_platform(PLATFORM_ASIM))
>   		host->is_asim = true;
>   	if (otx_is_platform(PLATFORM_EMULATOR))
>   		host->is_emul = true;
>   	host->dma_wait_delay =
> -		ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
> +		ofnode_read_u32_default(dev_ofnode(dev),
> +					"marvell,dma-wait-delay", 1);
idem
>   	/* Force reset of eMMC */
>   	writeq(0, host->base_addr + MIO_EMM_CFG());
>   	debug("%s: Clearing MIO_EMM_CFG\n", __func__);
> @@ -3824,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
>   	struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
>   	struct octeontx_mmc_slot *slot;
>   	struct mmc_uclass_priv *upriv;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	u32 bus_id;
>   	char name[16];
>   	int err;
> diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
> index 96a5fe6592a..64433cf6ccc 100644
> --- a/drivers/mtd/nand/raw/octeontx_nand.c
> +++ b/drivers/mtd/nand/raw/octeontx_nand.c
> @@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
>   static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
>   {
>   	struct udevice *dev = tn->dev;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	ofnode nand_node;
>   	int nr_chips = of_get_child_count(node);
>   	int ret;
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index ab9a24ed5b5..cd12376ab82 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
>   		return -ENOMEM;
>   	sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
>   	spinand->slave = slave;
> -	spinand_set_ofnode(spinand, dev->node);
> +	spinand_set_ofnode(spinand, dev_ofnode(dev));
>   #endif
>   
>   	ret = spinand_init(spinand);
> diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
> index a10f87eefc5..0e89e663f71 100644
> --- a/drivers/net/fm/eth.c
> +++ b/drivers/net/fm/eth.c
> @@ -957,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
>   {
>   	const char *if_str;
>   
> -	if_str = ofnode_read_string(dev->node, "phy-connection-type");
> +	if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
dev_read_string
>   	debug("MAC system interface mode %s\n", if_str);
>   
>   	return phy_get_interface_by_name(if_str);
> @@ -969,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
>   	char mac_name[11];
>   	u32 fm, num;
>   
> -	if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
> +	if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
dev_read_u32
>   		printf("FMan node property cell-index missing\n");
>   		return -EINVAL;
>   	}
> diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
> index 2e684e58393..f6fc7801b95 100644
> --- a/drivers/net/fsl_enetc.c
> +++ b/drivers/net/fsl_enetc.c
> @@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
>   	 * and some are not, use different naming scheme - enetc-N based on
>   	 * PCI function # and enetc#N based on interface count
>   	 */
> -	if (ofnode_valid(dev->node))
> +	if (ofnode_valid(dev_ofnode(dev)))

if (dev_has_ofnode(dev))

>   		sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
>   	else
>   		sprintf(name, "enetc#%u", eth_num_devices++);
> @@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
>   			mdio_register(&priv->imdio);
>   	}
>   
> -	if (!ofnode_valid(dev->node)) {
> +	if (!ofnode_valid(dev_ofnode(dev))) {


if (!dev_has_ofnode(dev))

>   		enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
>   		return;
>   	}
>   
> -	if_str = ofnode_read_string(dev->node, "phy-mode");
> +	if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
dev_read_string
>   	if (if_str)
>   		priv->if_type = phy_get_interface_by_name(if_str);
>   	else
> @@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
>   {
>   	struct enetc_priv *priv = dev_get_priv(dev);
>   
> -	if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
> +	if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {

if (dev_has_ofnode(dev) && !dev_read_enabled(dev)) {

>   		enetc_dbg(dev, "interface disabled\n");
>   		return -ENODEV;
>   	}
> diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
> index 4da97b61d17..3eb6ac9fc8f 100644
> --- a/drivers/net/fsl_enetc_mdio.c
> +++ b/drivers/net/fsl_enetc_mdio.c
> @@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
>   	 * and some are not, use different naming scheme - enetc-N based on
>   	 * PCI function # and enetc#N based on interface count
>   	 */
> -	if (ofnode_valid(dev->node))
> +	if (ofnode_valid(dev_ofnode(dev)))
if (dev_has_ofnode(dev))
>   		sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
>   	else
>   		sprintf(name, "emdio#%u", eth_num_devices++);
> diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c
> index 13a8856286a..50134b4d9b6 100644
> --- a/drivers/net/mdio-ipq4019.c
> +++ b/drivers/net/mdio-ipq4019.c
> @@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
>   
>   static int ipq4019_mdio_bind(struct udevice *dev)
>   {
> -	if (ofnode_valid(dev->node))
> -		device_set_name(dev, ofnode_get_name(dev->node));
> +	if (ofnode_valid(dev_ofnode(dev)))
> +		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));

if (dev_has_ofnode(dev)

 ??? device_set_name(dev, dev_read_name(dev));


>   
>   	return 0;
>   }
> diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c
> index f8557dd2c49..3654230118f 100644
> --- a/drivers/net/mdio_mux_i2creg.c
> +++ b/drivers/net/mdio_mux_i2creg.c
> @@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
>   	}
>   
>   	/* parent should be an I2C chip, grandparent should be an I2C bus */
> -	chip_node = ofnode_get_parent(dev->node);
> +	chip_node = ofnode_get_parent(dev_ofnode(dev));
>   	bus_node = ofnode_get_parent(chip_node);
>   
>   	err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
> diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c
> index 005f28f1b25..96f8dc62b56 100644
> --- a/drivers/net/mvmdio.c
> +++ b/drivers/net/mvmdio.c
> @@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
>    */
>   static int mvmdio_bind(struct udevice *dev)
>   {
> -	if (ofnode_valid(dev->node))
> -		device_set_name(dev, ofnode_get_name(dev->node));
> +	if (ofnode_valid(dev_ofnode(dev)))
> +		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));

if (dev_has_ofnode(dev)

 ??? device_set_name(dev, dev_read_name(dev));

>   	return 0;
>   }
> diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
> index d1582b968bf..58436419f1b 100644
> --- a/drivers/net/octeontx/smi.c
> +++ b/drivers/net/octeontx/smi.c
> @@ -313,7 +313,7 @@ read_error:
>   
>   int octeontx_smi_probe(struct udevice *dev)
>   {
> -	int ret, subnode, cnt = 0, node = dev->node.of_offset;
> +	int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
>   	struct mii_dev *bus;
>   	struct octeontx_smi_priv *priv;
>   	pci_dev_t bdf = dm_pci_get_bdf(dev);
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index 2d124732cf0..ec486893725 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -707,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
>   		tsec_configure_serdes(priv);
>   
>   #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
> -	if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
> +	if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
> +					     "fixed-link")))

if (ofnode_valid(dev_read_subnode(priv->dev, "fixed-link")))

>   		phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
>   	else
>   		phydev = dm_eth_phy_connect(priv->dev);
> diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
> index 8e35ea14750..82010e7c96e 100644
> --- a/drivers/phy/phy-ti-am654.c
> +++ b/drivers/phy/phy-ti-am654.c
> @@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
>   
>   	ret = device_bind_driver_to_node(dev->parent,
>   					 "ti-serdes-am654-mux-clk",
> -					 dev_read_name(dev), dev->node,
> +					 dev_read_name(dev), dev_ofnode(dev),
>   					 NULL);
>   	if (ret) {
>   		dev_err(dev, "%s: not able to bind clock driver\n", __func__);
> diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
> index 2e7ab671286..ef8274ce96d 100644
> --- a/drivers/power/domain/meson-ee-pwrc.c
> +++ b/drivers/power/domain/meson-ee-pwrc.c
> @@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
>   	if (!priv->data)
>   		return -EINVAL;
>   
> -	priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->regmap_hhi))
>   		return PTR_ERR(priv->regmap_hhi);
>   
> -	ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
> +	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
>   			      &ao_phandle);
dev_read_u32
>   	if (ret)
>   		return ret;
> diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
> index 40947c66f31..eb94af2cf83 100644
> --- a/drivers/power/domain/meson-gx-pwrc-vpu.c
> +++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
> @@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
>   	ofnode hhi_node;
>   	int ret;
>   
> -	priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->regmap_ao))
>   		return PTR_ERR(priv->regmap_ao);
>   
> -	ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
> +	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
>   			      &hhi_phandle);
dev_read_u32
>   	if (ret)
>   		return ret;
> diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
> index 6f0d0a59ff4..5bf186e4d4c 100644
> --- a/drivers/power/regulator/pbias_regulator.c
> +++ b/drivers/power/regulator/pbias_regulator.c
> @@ -103,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
>   {
>   	int children;
>   
> -	children = pmic_bind_children(dev, dev->node, pmic_children_info);
> +	children = pmic_bind_children(dev, dev_ofnode(dev),
> +				      pmic_children_info);
>   	if (!children)
>   		debug("%s: %s - no child found\n", __func__, dev->name);
>   
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 58b7469f977..03eeacc286d 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
>   					if (strcmp(cdev->driver->name, "fixed_rate_clock"))
>   						continue;
>   
> -					str = ofnode_read_string(cdev->node, "clock-output-names");
> +					str = ofnode_read_string(dev_ofnode(cdev),
> +								 "clock-output-names");
dev_read_string
>   					if (!str)
>   						continue;
>   
>   					if (!strcmp(str, "xtal")) {
>   						err = uclass_get_device_by_ofnode(UCLASS_CLK,
> -										  cdev->node,
> +										  dev_ofnode(cdev),
>   										  &cdev);
>   						if (err) {
>   							printf("%s%d: Failed to get xtal clk\n", __func__, i);
> @@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
>   					return -EINVAL;
>   				}
>   
> -				err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
> +				err = uclass_get_device_by_ofnode(UCLASS_CLK,
> +								  dev_ofnode(cdev),
> +								  &cdev);
>   				if (err) {
>   					printf("%s%d: Failed to get clk controller\n", __func__, i);
>   					return err;
> diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
> index c64c9b5917c..98450db94b2 100644
> --- a/drivers/reset/reset-socfpga.c
> +++ b/drivers/reset/reset-socfpga.c
> @@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
>   	 * Bind it to the node, too, so that it can get its base address.
>   	 */
>   	ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
> -					 dev->node, &sys_child);
> +					 dev_ofnode(dev), &sys_child);
>   	if (ret)
>   		debug("Warning: No sysreset driver: ret=%d\n", ret);
>   
> diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
> index b8c0216b39d..c17a5522bcc 100644
> --- a/drivers/spi/fsl_dspi.c
> +++ b/drivers/spi/fsl_dspi.c
> @@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
>   		return -EINVAL;
>   	}
>   
> -	ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
> -	ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
> +	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
> +			&cs_sck_delay);
> +	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
> +			&sck_cs_delay);
>   

dev_read_u32


>   	/* Set PCS to SCK delay scale values */
>   	ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index 7c38d6e0527..b898c32edc0 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
>   	const char *method;
>   
>   	debug("optee: looking for conduit method in DT.\n");
> -	method = ofnode_get_property(dev->node, "method", NULL);
> +	method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
dev_read_prop
>   	if (!method) {
>   		debug("optee: missing \"method\" property\n");
>   		return ERR_PTR(-ENXIO);
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index e861c82f7e1..798a21793f7 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>   	enum usb_dr_mode dr_mode;
>   	int ret = 0;
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   	cdns->role = USB_ROLE_NONE;
>   
>   	/*
> @@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	node = ofnode_by_compatible(parent->node, "cdns,usb3");
> +	node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
>   	if (!ofnode_valid(node)) {
>   		ret = -ENODEV;
>   		goto fail;
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 2e003530a15..dfd7cf683f7 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
>   	 */
>   	hird_threshold = 12;
>   
> -	dwc->hsphy_mode = usb_get_phy_mode(dev->node);
> +	dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
>   
>   	dwc->has_lpm_erratum = dev_read_bool(dev,
>   				"snps,has-lpm-erratum");
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 459add80c58..39e931f634d 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
>   static int dwc3_generic_of_to_plat(struct udevice *dev)
>   {
>   	struct dwc3_generic_plat *plat = dev_get_plat(dev);
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   
>   	plat->base = dev_read_addr(dev);
>   
> @@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	ofnode_for_each_subnode(node, parent->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(parent)) {

 ??? dev_for_each_subnode(node, parent) {
>   		const char *name = ofnode_get_name(node);
>   		enum usb_dr_mode dr_mode;
>   		struct udevice *dev;
> @@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
>   	while (child) {
>   		enum usb_dr_mode dr_mode;
>   
> -		dr_mode = usb_get_dr_mode(child->node);
> +		dr_mode = usb_get_dr_mode(dev_ofnode(child));
>   		device_find_next_child(&child);
>   		if (ops && ops->select_dr_mode)
>   			ops->select_dr_mode(dev, index, dr_mode);
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index acc7866b64a..6f99fb27f3f 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -395,7 +395,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
>   	}
>   #endif
>   
> -	priv->otg_mode = usb_get_dr_mode(dev->node);
> +	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	ret = dwc3_meson_g12a_usb_init(priv);
>   	if (ret)
> diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c
> index b63cc235f7e..08467d6210b 100644
> --- a/drivers/usb/dwc3/dwc3-meson-gxl.c
> +++ b/drivers/usb/dwc3/dwc3-meson-gxl.c
> @@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
>   	if (ret)
>   		return ret;
>   
> -	priv->otg_mode = usb_get_dr_mode(dev->node);
> +	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
>   		priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 4771b1e9312..e3871e381e1 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
>   	void (*set_params)(struct dwc2_plat_otg_data *data);
>   	int ret;
>   
> -	if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
> -	    usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
> +	if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
> +	    usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
>   		dev_dbg(dev, "Invalid mode\n");
>   		return -ENODEV;
>   	}
> diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c
> index c3cac9c5abd..742e156cbb9 100644
> --- a/drivers/usb/host/dwc3-octeon-glue.c
> +++ b/drivers/usb/host/dwc3-octeon-glue.c
> @@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
>   
>   	/* Find snps,dwc3 node from subnode */
>   	dwc3_node = ofnode_null();
> -	ofnode_for_each_subnode(node, dev->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(dev)) {

dev_for_each_subnode(node, dev) {
>   		if (ofnode_device_is_compatible(node, "snps,dwc3"))
>   			dwc3_node = node;
>   	}
> diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
> index deb820a0f84..e5c6a1a67d6 100644
> --- a/drivers/usb/host/dwc3-sti-glue.c
> +++ b/drivers/usb/host/dwc3-sti-glue.c
> @@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
>   	int ret;
>   	u32 reg[4];
>   
> -	ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
> +	ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
> +				    ARRAY_SIZE(reg));
dev_read_u32
>   	if (ret) {
>   		pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
>   		return ret;
> @@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
>   	ofnode node, dwc3_node;
>   
>   	/* Find snps,dwc3 node from subnode */
> -	ofnode_for_each_subnode(node, dev->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(dev)) {

dev_for_each_subnode(node, dev) {
>   		if (ofnode_device_is_compatible(node, "snps,dwc3"))
>   			dwc3_node = node;
>   	}
> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index d2f49cf4690..ef3a63afa44 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
>   	struct usb_plat *plat = dev_get_plat(dev);
>   	enum usb_dr_mode dr_mode;
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	switch (dr_mode) {
>   	case USB_DR_MODE_HOST:
> diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
> index 59408e4e50e..3e0ae80cece 100644
> --- a/drivers/usb/host/xhci-dwc3.c
> +++ b/drivers/usb/host/xhci-dwc3.c
> @@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
>   
>   	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   	if (dr_mode == USB_DR_MODE_UNKNOWN)
>   		/* by default set dual role mode to HOST */
>   		dr_mode = USB_DR_MODE_HOST;
> diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
> index 28136f88f45..2f5cc9b1480 100644
> --- a/drivers/usb/mtu3/mtu3_core.c
> +++ b/drivers/usb/mtu3/mtu3_core.c
> @@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
>   	mtu->ippc_base = ssusb->ippc_base;
>   	mtu->mac_base = ssusb->mac_base;
>   	mtu->ssusb = ssusb;
> -	mtu->max_speed = usb_get_maximum_speed(dev->node);
> +	mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
>   	mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
>   
>   	ret = mtu3_hw_init(mtu);
> diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
> index c951107b201..b097471f3d4 100644
> --- a/drivers/usb/mtu3/mtu3_plat.c
> +++ b/drivers/usb/mtu3/mtu3_plat.c
> @@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
>   		return -ENODEV;
>   	}
>   
> -	ssusb->dr_mode = usb_get_dr_mode(child->node);
> +	ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
>   
>   	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
>   		ssusb->dr_mode == USB_DR_MODE_OTG)
> @@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
> +	node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
>   	if (!ofnode_valid(node))
>   		return -ENODEV;
>   
> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> index 81b12fadfc1..75cf1811f7a 100644
> --- a/drivers/usb/musb-new/ti-musb.c
> +++ b/drivers/usb/musb-new/ti-musb.c
> @@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	ofnode_for_each_subnode(node, parent->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
>   		struct udevice *dev;
>   		const char *name = ofnode_get_name(node);
>   		enum usb_dr_mode dr_mode;
> diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c
> index 00e2c36f376..b47bef3578f 100644
> --- a/drivers/video/nexell_display.c
> +++ b/drivers/video/nexell_display.c
> @@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
>   		      __func__);
>   		return NULL;
>   	}
> -	node = dev->node.of_offset;
> +	node = dev_ofnode(dev).of_offset;
>   
>   	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
>   		ret = nx_display_parse_dt(dev, dp, plat);
> diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c
> index d125a5ba737..159201a5916 100644
> --- a/drivers/video/rockchip/rk_mipi.c
> +++ b/drivers/video/rockchip/rk_mipi.c
> @@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
>   	rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
>   
>   	/* Set dpi color coding depth 24 bit */
> -	timing_node = ofnode_find_subnode(dev->node, "display-timings");
> +	timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");

timing_node = dev_read_subnode(dev, "display-timings");
  

>   	node = ofnode_first_subnode(timing_node);
>   
>   	val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 4a1224bcc26..1b274206ea3 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
>    */
>   static inline ofnode dev_ofnode(const struct udevice *dev)
>   {
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
>   	return dev->node;
> +#else
> +	return ofnode_null();
> +#endif
>   }
>   
>   /* Returns non-zero if the device is active (probed and not removed) */
> @@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
>   
>   static inline int dev_of_offset(const struct udevice *dev)
>   {
> -	return ofnode_to_offset(dev->node);
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	return ofnode_to_offset(dev_ofnode(dev));
> +#else
> +	return -1;
> +#endif
>   }
>   
>   static inline bool dev_has_ofnode(const struct udevice *dev)
>   {
> -	return ofnode_valid(dev->node);
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	return ofnode_valid(dev_ofnode(dev));
> +#else
> +	return false;
> +#endif
> +}
> +
> +static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
> +{
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	dev->node = node;
> +#endif
>   }
>   
>   static inline int dev_seq(const struct udevice *dev)
> diff --git a/include/dm/read.h b/include/dm/read.h
> index d5cdd87911d..fc987f77598 100644
> --- a/include/dm/read.h
> +++ b/include/dm/read.h
> @@ -21,7 +21,7 @@ struct resource;
>   #if CONFIG_IS_ENABLED(OF_LIVE)
>   static inline const struct device_node *dev_np(const struct udevice *dev)
>   {
> -	return ofnode_to_np(dev->node);
> +	return ofnode_to_np(dev_ofnode(dev));
>   }
>   #else
>   static inline const struct device_node *dev_np(const struct udevice *dev)
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 54d03d02402..927854950a0 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -334,12 +334,12 @@ struct mtd_info {
>   #if IS_ENABLED(CONFIG_DM)
>   static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
>   {
> -	mtd->dev->node = node;
> +	dev_set_ofnode(mtd->dev, node);
>   }
>   
>   static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
>   {
> -	return mtd->dev->node;
> +	return dev_ofnode(mtd->dev);
>   }
>   #else
>   struct device_node;
> diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
> index 5f38f9fde41..780526c19e3 100644
> --- a/net/mdio-mux-uclass.c
> +++ b/net/mdio-mux-uclass.c
> @@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
>   	ofnode ch_node;
>   	int err, first_err = 0;
>   
> -	if (!ofnode_valid(mux->node)) {
> +	if (!dev_has_ofnode(mux)) {
>   		debug("%s: no mux node found, no child MDIO busses set up\n",
>   		      __func__);
>   		return 0;
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index d062382c2a9..697e5f838d9 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
>   	const char *dt_name;
>   
>   	/* set a custom name for the MDIO device, if present in DT */
> -	if (ofnode_valid(dev->node)) {
> -		dt_name = ofnode_read_string(dev->node, "device-name");
> +	if (dev_has_ofnode(dev)) {
> +		dt_name = dev_read_string(dev, "device-name");
>   		if (dt_name) {
>   			debug("renaming dev %s to %s\n", dev->name, dt_name);
>   			device_set_name(dev, dt_name);
> @@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
>   	struct phy_device *phy;
>   	int i;
>   
> -	if (!ofnode_valid(ethdev->node)) {
> +	if (!dev_has_ofnode(ethdev)) {
>   		debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
>   		return NULL;
>   	}
>   
>   	interface = PHY_INTERFACE_MODE_NONE;
>   	for (i = 0; i < PHY_MODE_STR_CNT; i++) {
> -		if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
> +		if_str = dev_read_string(ethdev, phy_mode_str[i]);
>   		if (if_str) {
>   			interface = phy_get_interface_by_name(if_str);
>   			break;


Patrick

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 22/26] dm: core: Access device ofnode through functions
@ 2021-01-04 13:02     ` Patrick DELAUNAY
  0 siblings, 0 replies; 65+ messages in thread
From: Patrick DELAUNAY @ 2021-01-04 13:02 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List
  Cc: uboot-snps-arc, Peng Fan, Neil Armstrong, Lokesh Vutla,
	u-boot-amlogic, Pavel Herrmann, Alexey Brodkin, Kever Yang,
	Michal Simek, Stefan Bosch, Joe Hershberger, Patrick Delaunay,
	uboot-stm32, Philipp Tomsich, Marek Vasut, Ryder Lee,
	Luka Perkov, Daniel Schwierzeck, Rasmus Villemoes,
	Masahiro Yamada, Weijie Gao, Lukasz Majewski, Ley Foon Tan,
	Suneel Garapati, Jaehoon Chung, Madalin Bucur, Jagan Teki,
	Chunfeng Yun, Anatolij Gustschin, Siva Durga Prasad Paladugu,
	Stefan Roese, Frank Wunderlich, Frank Wang, Eugeniy Paltsev,
	Robert Marko, hui.song, Priyanka Jain, Sean Anderson,
	Patrice Chotard, Aaron Williams, Luka Kovacic, Bin Meng,
	GSS_MTK_Uboot_upstream, Jens Wiklander

Hi Simon,


On 12/19/20 6:40 PM, Simon Glass wrote:
> At present ofnode is present in the device even if it is never used. With
> of-platdata this field is not used, so can be removed. In preparation for
> this, change the access to go through inline functions.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
>   board/synopsys/hsdk/clk-lib.c             |  2 +-
>   drivers/ata/mtk_ahci.c                    |  3 ++-
>   drivers/clk/meson/axg.c                   |  2 +-
>   drivers/clk/meson/g12a.c                  |  2 +-
>   drivers/clk/meson/gxbb.c                  |  2 +-
>   drivers/core/device.c                     |  2 +-
>   drivers/core/root.c                       |  2 +-
>   drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
>   drivers/gpio/octeon_gpio.c                |  2 +-
>   drivers/misc/swap_case.c                  |  2 +-
>   drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
>   drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
>   drivers/mtd/nand/spi/core.c               |  2 +-
>   drivers/net/fm/eth.c                      |  4 ++--
>   drivers/net/fsl_enetc.c                   |  8 ++++----
>   drivers/net/fsl_enetc_mdio.c              |  2 +-
>   drivers/net/mdio-ipq4019.c                |  4 ++--
>   drivers/net/mdio_mux_i2creg.c             |  2 +-
>   drivers/net/mvmdio.c                      |  4 ++--
>   drivers/net/octeontx/smi.c                |  2 +-
>   drivers/net/tsec.c                        |  3 ++-
>   drivers/phy/phy-ti-am654.c                |  2 +-
>   drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
>   drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
>   drivers/power/regulator/pbias_regulator.c |  3 ++-
>   drivers/pwm/pwm-meson.c                   |  9 ++++++---
>   drivers/reset/reset-socfpga.c             |  2 +-
>   drivers/spi/fsl_dspi.c                    |  6 ++++--
>   drivers/tee/optee/core.c                  |  2 +-
>   drivers/usb/cdns3/core.c                  |  4 ++--
>   drivers/usb/dwc3/core.c                   |  2 +-
>   drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
>   drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
>   drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
>   drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
>   drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
>   drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
>   drivers/usb/host/ehci-mx6.c               |  2 +-
>   drivers/usb/host/xhci-dwc3.c              |  2 +-
>   drivers/usb/mtu3/mtu3_core.c              |  2 +-
>   drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
>   drivers/usb/musb-new/ti-musb.c            |  2 +-
>   drivers/video/nexell_display.c            |  2 +-
>   drivers/video/rockchip/rk_mipi.c          |  2 +-
>   include/dm/device.h                       | 23 +++++++++++++++++++++--
>   include/dm/read.h                         |  2 +-
>   include/linux/mtd/mtd.h                   |  4 ++--
>   net/mdio-mux-uclass.c                     |  2 +-
>   net/mdio-uclass.c                         |  8 ++++----
>   50 files changed, 113 insertions(+), 82 deletions(-)

in all the modified drivers,
for the functions ofnode_XXXX(dev->node,...) modified to ofnode_XXXX(dev_ofnode(dev),
they can also modified to dev_XXX function :

ofnode_read_u32(dev_ofnode(dev), ...) => dev_read_u32(dev,....)
ofnode_read_string(dev_ofnode(dev), ...) => dev_read_string(dev,....)
ofnode_valid(dev_ofnode(dev)) => dev_has_ofnode(dev)

but you prefer perhaps minizes the modifications in this patchset and if 
it is the case :

Reviewed-by: Patrick Delaunay


You can found some other examples below.

>
> diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
> index af6ea439646..766ed95f1a6 100644
> --- a/arch/arm/mach-stm32mp/pwr_regulator.c
> +++ b/arch/arm/mach-stm32mp/pwr_regulator.c
> @@ -81,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
>   {
>   	int children;
>   
> -	children = pmic_bind_children(dev, dev->node, pwr_children_info);
> +	children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
>   	if (!children)
>   		dev_dbg(dev, "no child found\n");
>   
> diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
> index 1c74bfb93a3..bd43179fc79 100644
> --- a/board/synopsys/hsdk/clk-lib.c
> +++ b/board/synopsys/hsdk/clk-lib.c
> @@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
>   	/* Dummy fmeas device, just to be able to use standard clk_* api */
>   	struct udevice fmeas = {
>   		.name = "clk-fmeas",
> -		.node = ofnode_path("/clk-fmeas"),
>   	};
> +	dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
>   
>   	ret = clk_get_by_name(&fmeas, name, &clk);
>   	if (ret) {
> diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
> index cd28e0cae37..46b7677783f 100644
> --- a/drivers/ata/mtk_ahci.c
> +++ b/drivers/ata/mtk_ahci.c
> @@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
>   				   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
>   	}
>   
> -	ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
> +	ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
> +			&hpriv->port_map);

dev_read_u32(dev, "ports-implemented", &hpriv->port_map);

>   	return 0;
>   }
>   
> diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
> index 82068578ffb..d6da59d269b 100644
> --- a/drivers/clk/meson/axg.c
> +++ b/drivers/clk/meson/axg.c
> @@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
> index 01b22abc34d..5058db1a47b 100644
> --- a/drivers/clk/meson/g12a.c
> +++ b/drivers/clk/meson/g12a.c
> @@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
> index 2a20541dcb4..e379540deee 100644
> --- a/drivers/clk/meson/gxbb.c
> +++ b/drivers/clk/meson/gxbb.c
> @@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
>   {
>   	struct meson_clk *priv = dev_get_priv(dev);
>   
> -	priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->map))
>   		return PTR_ERR(priv->map);
>   
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index bd4ecc9e24d..6a9bee093d0 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
>   	dev_set_plat(dev, plat);
>   	dev->driver_data = driver_data;
>   	dev->name = name;
> -	dev->node = node;
> +	dev_set_ofnode(dev, node);
>   	dev->parent = parent;
>   	dev->driver = drv;
>   	dev->uclass = uc;
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 9ef242979ba..fe7359433f6 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -148,7 +148,7 @@ int dm_init(bool of_live)
>   	if (ret)
>   		return ret;
>   	if (CONFIG_IS_ENABLED(OF_CONTROL))
> -		DM_ROOT_NON_CONST->node = ofnode_root();
> +		dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
>   	ret = device_probe(DM_ROOT_NON_CONST);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
> index 2bc1a0d5716..a964347fa32 100644
> --- a/drivers/gpio/mpc8xxx_gpio.c
> +++ b/drivers/gpio/mpc8xxx_gpio.c
> @@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
>   	u32 i;
>   	u32 reg[4];
>   
> -	if (ofnode_read_bool(dev->node, "little-endian"))
> +	if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))

if (dev_read_bool(dev, "little-endian"))

>   		data->little_endian = true;
>   
>   	if (data->little_endian)
> @@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
>   	if (!str)
>   		return -ENOMEM;
>   
> -	if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
> +	if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
>   		unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
>   			- sizeof(u32);
>   
> diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c
> index 958516d8f8e..42eae79d8c4 100644
> --- a/drivers/gpio/octeon_gpio.c
> +++ b/drivers/gpio/octeon_gpio.c
> @@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
>   			GPIO_CONST_GPIOS_MASK;
>   	} else {
>   		priv->base = dev_remap_addr(dev);
> -		uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
> +		uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
>   							      "nr-gpios", 32);

uc_priv->gpio_count = dev_read_u32_default(dev, "nr-gpios", 32);

>   	}
>   
> diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
> index abea0e76139..3cbc8f37ec5 100644
> --- a/drivers/misc/swap_case.c
> +++ b/drivers/misc/swap_case.c
> @@ -54,7 +54,7 @@ struct swap_case_priv {
>   
>   static int sandbox_swap_case_use_ea(const struct udevice *dev)
>   {
> -	return !!ofnode_get_property(dev->node, "use-ea", NULL);
> +	return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);

return !!dev_read_prop(dev, "use-ea", NULL);

>   }
>   
>   /* Please keep these macros in sync with ea_regs below */
> diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
> index f3da6af9090..442ca493d76 100644
> --- a/drivers/mmc/octeontx_hsmmc.c
> +++ b/drivers/mmc/octeontx_hsmmc.c
> @@ -3439,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
>    */
>   static bool octeontx_mmc_get_valid(struct udevice *dev)
>   {
> -	const char *stat = ofnode_read_string(dev->node, "status");
> +	const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
>   

const char *stat = dev_read_string(dev, "status");

>   	if (!stat || !strncmp(stat, "ok", 2))
>   		return true;
> @@ -3461,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
>   	uint low, high;
>   	char env_name[32];
>   	int err;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	int bus_width = 1;
>   	ulong new_max_freq;
>   
>   	debug("%s(%s)", __func__, dev->name);
>   	slot->cfg.name = dev->name;
>   
> -	slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
> +	slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
> +						  "max-frequency",
>   						  26000000);

slot->cfg.f_max = dev_read_s32_default(dev, "max-frequency", 26000000);

>   	snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
>   		 slot->bus_id);
> @@ -3486,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
>   
>   	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
>   		slot->hs400_tuning_block =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs400-tuning-block",
>   						-1);
idem
>   		debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
>   		      dev->name, slot->hs400_tuning_block);
>   
>   		slot->hs200_tap_adj =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs200-tap-adjust", 0);
idem
>   		debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
>   		      slot->hs200_tap_adj);
>   		slot->hs400_tap_adj =
> -			ofnode_read_s32_default(dev->node,
> +			ofnode_read_s32_default(dev_ofnode(dev),
>   						"marvell,hs400-tap-adjust", 0);
idem
>   		debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
>   		      slot->hs400_tap_adj);
>   	}
>   
> -	err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
> +	err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
> +				    voltages, 2);
idem
>   	if (err) {
>   		slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
>   	} else {
> @@ -3756,14 +3758,15 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
>   		pr_err("%s: No device tree information found\n", __func__);
>   		return -1;
>   	}
> -	host->node = dev->node;
> +	host->node = dev_ofnode(dev);
>   	host->last_slotid = -1;
>   	if (otx_is_platform(PLATFORM_ASIM))
>   		host->is_asim = true;
>   	if (otx_is_platform(PLATFORM_EMULATOR))
>   		host->is_emul = true;
>   	host->dma_wait_delay =
> -		ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
> +		ofnode_read_u32_default(dev_ofnode(dev),
> +					"marvell,dma-wait-delay", 1);
idem
>   	/* Force reset of eMMC */
>   	writeq(0, host->base_addr + MIO_EMM_CFG());
>   	debug("%s: Clearing MIO_EMM_CFG\n", __func__);
> @@ -3824,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
>   	struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
>   	struct octeontx_mmc_slot *slot;
>   	struct mmc_uclass_priv *upriv;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	u32 bus_id;
>   	char name[16];
>   	int err;
> diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
> index 96a5fe6592a..64433cf6ccc 100644
> --- a/drivers/mtd/nand/raw/octeontx_nand.c
> +++ b/drivers/mtd/nand/raw/octeontx_nand.c
> @@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
>   static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
>   {
>   	struct udevice *dev = tn->dev;
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   	ofnode nand_node;
>   	int nr_chips = of_get_child_count(node);
>   	int ret;
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index ab9a24ed5b5..cd12376ab82 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
>   		return -ENOMEM;
>   	sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
>   	spinand->slave = slave;
> -	spinand_set_ofnode(spinand, dev->node);
> +	spinand_set_ofnode(spinand, dev_ofnode(dev));
>   #endif
>   
>   	ret = spinand_init(spinand);
> diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
> index a10f87eefc5..0e89e663f71 100644
> --- a/drivers/net/fm/eth.c
> +++ b/drivers/net/fm/eth.c
> @@ -957,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
>   {
>   	const char *if_str;
>   
> -	if_str = ofnode_read_string(dev->node, "phy-connection-type");
> +	if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
dev_read_string
>   	debug("MAC system interface mode %s\n", if_str);
>   
>   	return phy_get_interface_by_name(if_str);
> @@ -969,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
>   	char mac_name[11];
>   	u32 fm, num;
>   
> -	if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
> +	if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
dev_read_u32
>   		printf("FMan node property cell-index missing\n");
>   		return -EINVAL;
>   	}
> diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
> index 2e684e58393..f6fc7801b95 100644
> --- a/drivers/net/fsl_enetc.c
> +++ b/drivers/net/fsl_enetc.c
> @@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
>   	 * and some are not, use different naming scheme - enetc-N based on
>   	 * PCI function # and enetc#N based on interface count
>   	 */
> -	if (ofnode_valid(dev->node))
> +	if (ofnode_valid(dev_ofnode(dev)))

if (dev_has_ofnode(dev))

>   		sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
>   	else
>   		sprintf(name, "enetc#%u", eth_num_devices++);
> @@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
>   			mdio_register(&priv->imdio);
>   	}
>   
> -	if (!ofnode_valid(dev->node)) {
> +	if (!ofnode_valid(dev_ofnode(dev))) {


if (!dev_has_ofnode(dev))

>   		enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
>   		return;
>   	}
>   
> -	if_str = ofnode_read_string(dev->node, "phy-mode");
> +	if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
dev_read_string
>   	if (if_str)
>   		priv->if_type = phy_get_interface_by_name(if_str);
>   	else
> @@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
>   {
>   	struct enetc_priv *priv = dev_get_priv(dev);
>   
> -	if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
> +	if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {

if (dev_has_ofnode(dev) && !dev_read_enabled(dev)) {

>   		enetc_dbg(dev, "interface disabled\n");
>   		return -ENODEV;
>   	}
> diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
> index 4da97b61d17..3eb6ac9fc8f 100644
> --- a/drivers/net/fsl_enetc_mdio.c
> +++ b/drivers/net/fsl_enetc_mdio.c
> @@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
>   	 * and some are not, use different naming scheme - enetc-N based on
>   	 * PCI function # and enetc#N based on interface count
>   	 */
> -	if (ofnode_valid(dev->node))
> +	if (ofnode_valid(dev_ofnode(dev)))
if (dev_has_ofnode(dev))
>   		sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
>   	else
>   		sprintf(name, "emdio#%u", eth_num_devices++);
> diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c
> index 13a8856286a..50134b4d9b6 100644
> --- a/drivers/net/mdio-ipq4019.c
> +++ b/drivers/net/mdio-ipq4019.c
> @@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
>   
>   static int ipq4019_mdio_bind(struct udevice *dev)
>   {
> -	if (ofnode_valid(dev->node))
> -		device_set_name(dev, ofnode_get_name(dev->node));
> +	if (ofnode_valid(dev_ofnode(dev)))
> +		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));

if (dev_has_ofnode(dev)

     device_set_name(dev, dev_read_name(dev));


>   
>   	return 0;
>   }
> diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c
> index f8557dd2c49..3654230118f 100644
> --- a/drivers/net/mdio_mux_i2creg.c
> +++ b/drivers/net/mdio_mux_i2creg.c
> @@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
>   	}
>   
>   	/* parent should be an I2C chip, grandparent should be an I2C bus */
> -	chip_node = ofnode_get_parent(dev->node);
> +	chip_node = ofnode_get_parent(dev_ofnode(dev));
>   	bus_node = ofnode_get_parent(chip_node);
>   
>   	err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
> diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c
> index 005f28f1b25..96f8dc62b56 100644
> --- a/drivers/net/mvmdio.c
> +++ b/drivers/net/mvmdio.c
> @@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
>    */
>   static int mvmdio_bind(struct udevice *dev)
>   {
> -	if (ofnode_valid(dev->node))
> -		device_set_name(dev, ofnode_get_name(dev->node));
> +	if (ofnode_valid(dev_ofnode(dev)))
> +		device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));

if (dev_has_ofnode(dev)

     device_set_name(dev, dev_read_name(dev));

>   	return 0;
>   }
> diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
> index d1582b968bf..58436419f1b 100644
> --- a/drivers/net/octeontx/smi.c
> +++ b/drivers/net/octeontx/smi.c
> @@ -313,7 +313,7 @@ read_error:
>   
>   int octeontx_smi_probe(struct udevice *dev)
>   {
> -	int ret, subnode, cnt = 0, node = dev->node.of_offset;
> +	int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
>   	struct mii_dev *bus;
>   	struct octeontx_smi_priv *priv;
>   	pci_dev_t bdf = dm_pci_get_bdf(dev);
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index 2d124732cf0..ec486893725 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -707,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
>   		tsec_configure_serdes(priv);
>   
>   #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
> -	if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
> +	if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
> +					     "fixed-link")))

if (ofnode_valid(dev_read_subnode(priv->dev, "fixed-link")))

>   		phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
>   	else
>   		phydev = dm_eth_phy_connect(priv->dev);
> diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
> index 8e35ea14750..82010e7c96e 100644
> --- a/drivers/phy/phy-ti-am654.c
> +++ b/drivers/phy/phy-ti-am654.c
> @@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
>   
>   	ret = device_bind_driver_to_node(dev->parent,
>   					 "ti-serdes-am654-mux-clk",
> -					 dev_read_name(dev), dev->node,
> +					 dev_read_name(dev), dev_ofnode(dev),
>   					 NULL);
>   	if (ret) {
>   		dev_err(dev, "%s: not able to bind clock driver\n", __func__);
> diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
> index 2e7ab671286..ef8274ce96d 100644
> --- a/drivers/power/domain/meson-ee-pwrc.c
> +++ b/drivers/power/domain/meson-ee-pwrc.c
> @@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
>   	if (!priv->data)
>   		return -EINVAL;
>   
> -	priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->regmap_hhi))
>   		return PTR_ERR(priv->regmap_hhi);
>   
> -	ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
> +	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
>   			      &ao_phandle);
dev_read_u32
>   	if (ret)
>   		return ret;
> diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
> index 40947c66f31..eb94af2cf83 100644
> --- a/drivers/power/domain/meson-gx-pwrc-vpu.c
> +++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
> @@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
>   	ofnode hhi_node;
>   	int ret;
>   
> -	priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
> +	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
>   	if (IS_ERR(priv->regmap_ao))
>   		return PTR_ERR(priv->regmap_ao);
>   
> -	ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
> +	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
>   			      &hhi_phandle);
dev_read_u32
>   	if (ret)
>   		return ret;
> diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
> index 6f0d0a59ff4..5bf186e4d4c 100644
> --- a/drivers/power/regulator/pbias_regulator.c
> +++ b/drivers/power/regulator/pbias_regulator.c
> @@ -103,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
>   {
>   	int children;
>   
> -	children = pmic_bind_children(dev, dev->node, pmic_children_info);
> +	children = pmic_bind_children(dev, dev_ofnode(dev),
> +				      pmic_children_info);
>   	if (!children)
>   		debug("%s: %s - no child found\n", __func__, dev->name);
>   
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 58b7469f977..03eeacc286d 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
>   					if (strcmp(cdev->driver->name, "fixed_rate_clock"))
>   						continue;
>   
> -					str = ofnode_read_string(cdev->node, "clock-output-names");
> +					str = ofnode_read_string(dev_ofnode(cdev),
> +								 "clock-output-names");
dev_read_string
>   					if (!str)
>   						continue;
>   
>   					if (!strcmp(str, "xtal")) {
>   						err = uclass_get_device_by_ofnode(UCLASS_CLK,
> -										  cdev->node,
> +										  dev_ofnode(cdev),
>   										  &cdev);
>   						if (err) {
>   							printf("%s%d: Failed to get xtal clk\n", __func__, i);
> @@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
>   					return -EINVAL;
>   				}
>   
> -				err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
> +				err = uclass_get_device_by_ofnode(UCLASS_CLK,
> +								  dev_ofnode(cdev),
> +								  &cdev);
>   				if (err) {
>   					printf("%s%d: Failed to get clk controller\n", __func__, i);
>   					return err;
> diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
> index c64c9b5917c..98450db94b2 100644
> --- a/drivers/reset/reset-socfpga.c
> +++ b/drivers/reset/reset-socfpga.c
> @@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
>   	 * Bind it to the node, too, so that it can get its base address.
>   	 */
>   	ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
> -					 dev->node, &sys_child);
> +					 dev_ofnode(dev), &sys_child);
>   	if (ret)
>   		debug("Warning: No sysreset driver: ret=%d\n", ret);
>   
> diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
> index b8c0216b39d..c17a5522bcc 100644
> --- a/drivers/spi/fsl_dspi.c
> +++ b/drivers/spi/fsl_dspi.c
> @@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
>   		return -EINVAL;
>   	}
>   
> -	ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
> -	ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
> +	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
> +			&cs_sck_delay);
> +	ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
> +			&sck_cs_delay);
>   

dev_read_u32


>   	/* Set PCS to SCK delay scale values */
>   	ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index 7c38d6e0527..b898c32edc0 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
>   	const char *method;
>   
>   	debug("optee: looking for conduit method in DT.\n");
> -	method = ofnode_get_property(dev->node, "method", NULL);
> +	method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
dev_read_prop
>   	if (!method) {
>   		debug("optee: missing \"method\" property\n");
>   		return ERR_PTR(-ENXIO);
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index e861c82f7e1..798a21793f7 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>   	enum usb_dr_mode dr_mode;
>   	int ret = 0;
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   	cdns->role = USB_ROLE_NONE;
>   
>   	/*
> @@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	node = ofnode_by_compatible(parent->node, "cdns,usb3");
> +	node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
>   	if (!ofnode_valid(node)) {
>   		ret = -ENODEV;
>   		goto fail;
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 2e003530a15..dfd7cf683f7 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
>   	 */
>   	hird_threshold = 12;
>   
> -	dwc->hsphy_mode = usb_get_phy_mode(dev->node);
> +	dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
>   
>   	dwc->has_lpm_erratum = dev_read_bool(dev,
>   				"snps,has-lpm-erratum");
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 459add80c58..39e931f634d 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
>   static int dwc3_generic_of_to_plat(struct udevice *dev)
>   {
>   	struct dwc3_generic_plat *plat = dev_get_plat(dev);
> -	ofnode node = dev->node;
> +	ofnode node = dev_ofnode(dev);
>   
>   	plat->base = dev_read_addr(dev);
>   
> @@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	ofnode_for_each_subnode(node, parent->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(parent)) {

     dev_for_each_subnode(node, parent) {
>   		const char *name = ofnode_get_name(node);
>   		enum usb_dr_mode dr_mode;
>   		struct udevice *dev;
> @@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
>   	while (child) {
>   		enum usb_dr_mode dr_mode;
>   
> -		dr_mode = usb_get_dr_mode(child->node);
> +		dr_mode = usb_get_dr_mode(dev_ofnode(child));
>   		device_find_next_child(&child);
>   		if (ops && ops->select_dr_mode)
>   			ops->select_dr_mode(dev, index, dr_mode);
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index acc7866b64a..6f99fb27f3f 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -395,7 +395,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
>   	}
>   #endif
>   
> -	priv->otg_mode = usb_get_dr_mode(dev->node);
> +	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	ret = dwc3_meson_g12a_usb_init(priv);
>   	if (ret)
> diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c
> index b63cc235f7e..08467d6210b 100644
> --- a/drivers/usb/dwc3/dwc3-meson-gxl.c
> +++ b/drivers/usb/dwc3/dwc3-meson-gxl.c
> @@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
>   	if (ret)
>   		return ret;
>   
> -	priv->otg_mode = usb_get_dr_mode(dev->node);
> +	priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
>   		priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 4771b1e9312..e3871e381e1 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
>   	void (*set_params)(struct dwc2_plat_otg_data *data);
>   	int ret;
>   
> -	if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
> -	    usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
> +	if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
> +	    usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
>   		dev_dbg(dev, "Invalid mode\n");
>   		return -ENODEV;
>   	}
> diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c
> index c3cac9c5abd..742e156cbb9 100644
> --- a/drivers/usb/host/dwc3-octeon-glue.c
> +++ b/drivers/usb/host/dwc3-octeon-glue.c
> @@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
>   
>   	/* Find snps,dwc3 node from subnode */
>   	dwc3_node = ofnode_null();
> -	ofnode_for_each_subnode(node, dev->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(dev)) {

dev_for_each_subnode(node, dev) {
>   		if (ofnode_device_is_compatible(node, "snps,dwc3"))
>   			dwc3_node = node;
>   	}
> diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
> index deb820a0f84..e5c6a1a67d6 100644
> --- a/drivers/usb/host/dwc3-sti-glue.c
> +++ b/drivers/usb/host/dwc3-sti-glue.c
> @@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
>   	int ret;
>   	u32 reg[4];
>   
> -	ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
> +	ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
> +				    ARRAY_SIZE(reg));
dev_read_u32
>   	if (ret) {
>   		pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
>   		return ret;
> @@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
>   	ofnode node, dwc3_node;
>   
>   	/* Find snps,dwc3 node from subnode */
> -	ofnode_for_each_subnode(node, dev->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(dev)) {

dev_for_each_subnode(node, dev) {
>   		if (ofnode_device_is_compatible(node, "snps,dwc3"))
>   			dwc3_node = node;
>   	}
> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index d2f49cf4690..ef3a63afa44 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
>   	struct usb_plat *plat = dev_get_plat(dev);
>   	enum usb_dr_mode dr_mode;
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   
>   	switch (dr_mode) {
>   	case USB_DR_MODE_HOST:
> diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
> index 59408e4e50e..3e0ae80cece 100644
> --- a/drivers/usb/host/xhci-dwc3.c
> +++ b/drivers/usb/host/xhci-dwc3.c
> @@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
>   
>   	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
>   
> -	dr_mode = usb_get_dr_mode(dev->node);
> +	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>   	if (dr_mode == USB_DR_MODE_UNKNOWN)
>   		/* by default set dual role mode to HOST */
>   		dr_mode = USB_DR_MODE_HOST;
> diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
> index 28136f88f45..2f5cc9b1480 100644
> --- a/drivers/usb/mtu3/mtu3_core.c
> +++ b/drivers/usb/mtu3/mtu3_core.c
> @@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
>   	mtu->ippc_base = ssusb->ippc_base;
>   	mtu->mac_base = ssusb->mac_base;
>   	mtu->ssusb = ssusb;
> -	mtu->max_speed = usb_get_maximum_speed(dev->node);
> +	mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
>   	mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
>   
>   	ret = mtu3_hw_init(mtu);
> diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
> index c951107b201..b097471f3d4 100644
> --- a/drivers/usb/mtu3/mtu3_plat.c
> +++ b/drivers/usb/mtu3/mtu3_plat.c
> @@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
>   		return -ENODEV;
>   	}
>   
> -	ssusb->dr_mode = usb_get_dr_mode(child->node);
> +	ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
>   
>   	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
>   		ssusb->dr_mode == USB_DR_MODE_OTG)
> @@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
> +	node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
>   	if (!ofnode_valid(node))
>   		return -ENODEV;
>   
> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> index 81b12fadfc1..75cf1811f7a 100644
> --- a/drivers/usb/musb-new/ti-musb.c
> +++ b/drivers/usb/musb-new/ti-musb.c
> @@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
>   	ofnode node;
>   	int ret;
>   
> -	ofnode_for_each_subnode(node, parent->node) {
> +	ofnode_for_each_subnode(node, dev_ofnode(parent)) {
>   		struct udevice *dev;
>   		const char *name = ofnode_get_name(node);
>   		enum usb_dr_mode dr_mode;
> diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c
> index 00e2c36f376..b47bef3578f 100644
> --- a/drivers/video/nexell_display.c
> +++ b/drivers/video/nexell_display.c
> @@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
>   		      __func__);
>   		return NULL;
>   	}
> -	node = dev->node.of_offset;
> +	node = dev_ofnode(dev).of_offset;
>   
>   	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
>   		ret = nx_display_parse_dt(dev, dp, plat);
> diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c
> index d125a5ba737..159201a5916 100644
> --- a/drivers/video/rockchip/rk_mipi.c
> +++ b/drivers/video/rockchip/rk_mipi.c
> @@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
>   	rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
>   
>   	/* Set dpi color coding depth 24 bit */
> -	timing_node = ofnode_find_subnode(dev->node, "display-timings");
> +	timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");

timing_node = dev_read_subnode(dev, "display-timings");
  

>   	node = ofnode_first_subnode(timing_node);
>   
>   	val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 4a1224bcc26..1b274206ea3 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
>    */
>   static inline ofnode dev_ofnode(const struct udevice *dev)
>   {
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
>   	return dev->node;
> +#else
> +	return ofnode_null();
> +#endif
>   }
>   
>   /* Returns non-zero if the device is active (probed and not removed) */
> @@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
>   
>   static inline int dev_of_offset(const struct udevice *dev)
>   {
> -	return ofnode_to_offset(dev->node);
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	return ofnode_to_offset(dev_ofnode(dev));
> +#else
> +	return -1;
> +#endif
>   }
>   
>   static inline bool dev_has_ofnode(const struct udevice *dev)
>   {
> -	return ofnode_valid(dev->node);
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	return ofnode_valid(dev_ofnode(dev));
> +#else
> +	return false;
> +#endif
> +}
> +
> +static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
> +{
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +	dev->node = node;
> +#endif
>   }
>   
>   static inline int dev_seq(const struct udevice *dev)
> diff --git a/include/dm/read.h b/include/dm/read.h
> index d5cdd87911d..fc987f77598 100644
> --- a/include/dm/read.h
> +++ b/include/dm/read.h
> @@ -21,7 +21,7 @@ struct resource;
>   #if CONFIG_IS_ENABLED(OF_LIVE)
>   static inline const struct device_node *dev_np(const struct udevice *dev)
>   {
> -	return ofnode_to_np(dev->node);
> +	return ofnode_to_np(dev_ofnode(dev));
>   }
>   #else
>   static inline const struct device_node *dev_np(const struct udevice *dev)
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 54d03d02402..927854950a0 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -334,12 +334,12 @@ struct mtd_info {
>   #if IS_ENABLED(CONFIG_DM)
>   static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
>   {
> -	mtd->dev->node = node;
> +	dev_set_ofnode(mtd->dev, node);
>   }
>   
>   static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
>   {
> -	return mtd->dev->node;
> +	return dev_ofnode(mtd->dev);
>   }
>   #else
>   struct device_node;
> diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
> index 5f38f9fde41..780526c19e3 100644
> --- a/net/mdio-mux-uclass.c
> +++ b/net/mdio-mux-uclass.c
> @@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
>   	ofnode ch_node;
>   	int err, first_err = 0;
>   
> -	if (!ofnode_valid(mux->node)) {
> +	if (!dev_has_ofnode(mux)) {
>   		debug("%s: no mux node found, no child MDIO busses set up\n",
>   		      __func__);
>   		return 0;
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index d062382c2a9..697e5f838d9 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
>   	const char *dt_name;
>   
>   	/* set a custom name for the MDIO device, if present in DT */
> -	if (ofnode_valid(dev->node)) {
> -		dt_name = ofnode_read_string(dev->node, "device-name");
> +	if (dev_has_ofnode(dev)) {
> +		dt_name = dev_read_string(dev, "device-name");
>   		if (dt_name) {
>   			debug("renaming dev %s to %s\n", dev->name, dt_name);
>   			device_set_name(dev, dt_name);
> @@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
>   	struct phy_device *phy;
>   	int i;
>   
> -	if (!ofnode_valid(ethdev->node)) {
> +	if (!dev_has_ofnode(ethdev)) {
>   		debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
>   		return NULL;
>   	}
>   
>   	interface = PHY_INTERFACE_MODE_NONE;
>   	for (i = 0; i < PHY_MODE_STR_CNT; i++) {
> -		if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
> +		if_str = dev_read_string(ethdev, phy_mode_str[i]);
>   		if (if_str) {
>   			interface = phy_get_interface_by_name(if_str);
>   			break;


Patrick


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 22/26] dm: core: Access device ofnode through functions
  2021-01-04 13:02     ` Patrick DELAUNAY
@ 2021-01-07 12:36       ` Simon Glass
  -1 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2021-01-07 12:36 UTC (permalink / raw)
  To: u-boot

Hi Patrick,

On Mon, 4 Jan 2021 at 06:02, Patrick DELAUNAY
<patrick.delaunay@foss.st.com> wrote:
>
> Hi Simon,
>
>
> On 12/19/20 6:40 PM, Simon Glass wrote:
> > At present ofnode is present in the device even if it is never used. With
> > of-platdata this field is not used, so can be removed. In preparation for
> > this, change the access to go through inline functions.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >   arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
> >   board/synopsys/hsdk/clk-lib.c             |  2 +-
> >   drivers/ata/mtk_ahci.c                    |  3 ++-
> >   drivers/clk/meson/axg.c                   |  2 +-
> >   drivers/clk/meson/g12a.c                  |  2 +-
> >   drivers/clk/meson/gxbb.c                  |  2 +-
> >   drivers/core/device.c                     |  2 +-
> >   drivers/core/root.c                       |  2 +-
> >   drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
> >   drivers/gpio/octeon_gpio.c                |  2 +-
> >   drivers/misc/swap_case.c                  |  2 +-
> >   drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
> >   drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
> >   drivers/mtd/nand/spi/core.c               |  2 +-
> >   drivers/net/fm/eth.c                      |  4 ++--
> >   drivers/net/fsl_enetc.c                   |  8 ++++----
> >   drivers/net/fsl_enetc_mdio.c              |  2 +-
> >   drivers/net/mdio-ipq4019.c                |  4 ++--
> >   drivers/net/mdio_mux_i2creg.c             |  2 +-
> >   drivers/net/mvmdio.c                      |  4 ++--
> >   drivers/net/octeontx/smi.c                |  2 +-
> >   drivers/net/tsec.c                        |  3 ++-
> >   drivers/phy/phy-ti-am654.c                |  2 +-
> >   drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
> >   drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
> >   drivers/power/regulator/pbias_regulator.c |  3 ++-
> >   drivers/pwm/pwm-meson.c                   |  9 ++++++---
> >   drivers/reset/reset-socfpga.c             |  2 +-
> >   drivers/spi/fsl_dspi.c                    |  6 ++++--
> >   drivers/tee/optee/core.c                  |  2 +-
> >   drivers/usb/cdns3/core.c                  |  4 ++--
> >   drivers/usb/dwc3/core.c                   |  2 +-
> >   drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
> >   drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
> >   drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
> >   drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
> >   drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
> >   drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
> >   drivers/usb/host/ehci-mx6.c               |  2 +-
> >   drivers/usb/host/xhci-dwc3.c              |  2 +-
> >   drivers/usb/mtu3/mtu3_core.c              |  2 +-
> >   drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
> >   drivers/usb/musb-new/ti-musb.c            |  2 +-
> >   drivers/video/nexell_display.c            |  2 +-
> >   drivers/video/rockchip/rk_mipi.c          |  2 +-
> >   include/dm/device.h                       | 23 +++++++++++++++++++++--
> >   include/dm/read.h                         |  2 +-
> >   include/linux/mtd/mtd.h                   |  4 ++--
> >   net/mdio-mux-uclass.c                     |  2 +-
> >   net/mdio-uclass.c                         |  8 ++++----
> >   50 files changed, 113 insertions(+), 82 deletions(-)
>
> in all the modified drivers,
> for the functions ofnode_XXXX(dev->node,...) modified to ofnode_XXXX(dev_ofnode(dev),
> they can also modified to dev_XXX function :
>
> ofnode_read_u32(dev_ofnode(dev), ...) => dev_read_u32(dev,....)
> ofnode_read_string(dev_ofnode(dev), ...) => dev_read_string(dev,....)
> ofnode_valid(dev_ofnode(dev)) => dev_has_ofnode(dev)
>
> but you prefer perhaps minizes the modifications in this patchset and if
> it is the case :
>
> Reviewed-by: Patrick Delaunay
>
>
> You can found some other examples below.

Thanks for that.

I wonder if we can press coccinelle into service here. I think the
dev_read() API came later so people didn't know about it?

Regards,
Simon

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 22/26] dm: core: Access device ofnode through functions
@ 2021-01-07 12:36       ` Simon Glass
  0 siblings, 0 replies; 65+ messages in thread
From: Simon Glass @ 2021-01-07 12:36 UTC (permalink / raw)
  To: Patrick DELAUNAY
  Cc: U-Boot Mailing List, uboot-snps-arc, Peng Fan, Neil Armstrong,
	Lokesh Vutla, u-boot-amlogic, Pavel Herrmann, Alexey Brodkin,
	Kever Yang, Michal Simek, Stefan Bosch, Joe Hershberger,
	Patrick Delaunay, U-Boot STM32, Philipp Tomsich, Marek Vasut,
	Ryder Lee, Luka Perkov, Daniel Schwierzeck, Rasmus Villemoes,
	Masahiro Yamada, Weijie Gao, Lukasz Majewski, Ley Foon Tan,
	Suneel Garapati, Jaehoon Chung, Madalin Bucur, Jagan Teki,
	Chunfeng Yun, Anatolij Gustschin, Siva Durga Prasad Paladugu,
	Stefan Roese, Frank Wunderlich, Frank Wang, Eugeniy Paltsev,
	Robert Marko, hui.song, Priyanka Jain, Sean Anderson,
	Patrice Chotard, Aaron Williams, Luka Kovacic, Bin Meng,
	GSS_MTK_Uboot_upstream, Jens Wiklander

Hi Patrick,

On Mon, 4 Jan 2021 at 06:02, Patrick DELAUNAY
<patrick.delaunay@foss.st.com> wrote:
>
> Hi Simon,
>
>
> On 12/19/20 6:40 PM, Simon Glass wrote:
> > At present ofnode is present in the device even if it is never used. With
> > of-platdata this field is not used, so can be removed. In preparation for
> > this, change the access to go through inline functions.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >   arch/arm/mach-stm32mp/pwr_regulator.c     |  2 +-
> >   board/synopsys/hsdk/clk-lib.c             |  2 +-
> >   drivers/ata/mtk_ahci.c                    |  3 ++-
> >   drivers/clk/meson/axg.c                   |  2 +-
> >   drivers/clk/meson/g12a.c                  |  2 +-
> >   drivers/clk/meson/gxbb.c                  |  2 +-
> >   drivers/core/device.c                     |  2 +-
> >   drivers/core/root.c                       |  2 +-
> >   drivers/gpio/mpc8xxx_gpio.c               |  4 ++--
> >   drivers/gpio/octeon_gpio.c                |  2 +-
> >   drivers/misc/swap_case.c                  |  2 +-
> >   drivers/mmc/octeontx_hsmmc.c              | 23 +++++++++++++----------
> >   drivers/mtd/nand/raw/octeontx_nand.c      |  2 +-
> >   drivers/mtd/nand/spi/core.c               |  2 +-
> >   drivers/net/fm/eth.c                      |  4 ++--
> >   drivers/net/fsl_enetc.c                   |  8 ++++----
> >   drivers/net/fsl_enetc_mdio.c              |  2 +-
> >   drivers/net/mdio-ipq4019.c                |  4 ++--
> >   drivers/net/mdio_mux_i2creg.c             |  2 +-
> >   drivers/net/mvmdio.c                      |  4 ++--
> >   drivers/net/octeontx/smi.c                |  2 +-
> >   drivers/net/tsec.c                        |  3 ++-
> >   drivers/phy/phy-ti-am654.c                |  2 +-
> >   drivers/power/domain/meson-ee-pwrc.c      |  4 ++--
> >   drivers/power/domain/meson-gx-pwrc-vpu.c  |  4 ++--
> >   drivers/power/regulator/pbias_regulator.c |  3 ++-
> >   drivers/pwm/pwm-meson.c                   |  9 ++++++---
> >   drivers/reset/reset-socfpga.c             |  2 +-
> >   drivers/spi/fsl_dspi.c                    |  6 ++++--
> >   drivers/tee/optee/core.c                  |  2 +-
> >   drivers/usb/cdns3/core.c                  |  4 ++--
> >   drivers/usb/dwc3/core.c                   |  2 +-
> >   drivers/usb/dwc3/dwc3-generic.c           |  6 +++---
> >   drivers/usb/dwc3/dwc3-meson-g12a.c        |  2 +-
> >   drivers/usb/dwc3/dwc3-meson-gxl.c         |  2 +-
> >   drivers/usb/gadget/dwc2_udc_otg.c         |  4 ++--
> >   drivers/usb/host/dwc3-octeon-glue.c       |  2 +-
> >   drivers/usb/host/dwc3-sti-glue.c          |  5 +++--
> >   drivers/usb/host/ehci-mx6.c               |  2 +-
> >   drivers/usb/host/xhci-dwc3.c              |  2 +-
> >   drivers/usb/mtu3/mtu3_core.c              |  2 +-
> >   drivers/usb/mtu3/mtu3_plat.c              |  4 ++--
> >   drivers/usb/musb-new/ti-musb.c            |  2 +-
> >   drivers/video/nexell_display.c            |  2 +-
> >   drivers/video/rockchip/rk_mipi.c          |  2 +-
> >   include/dm/device.h                       | 23 +++++++++++++++++++++--
> >   include/dm/read.h                         |  2 +-
> >   include/linux/mtd/mtd.h                   |  4 ++--
> >   net/mdio-mux-uclass.c                     |  2 +-
> >   net/mdio-uclass.c                         |  8 ++++----
> >   50 files changed, 113 insertions(+), 82 deletions(-)
>
> in all the modified drivers,
> for the functions ofnode_XXXX(dev->node,...) modified to ofnode_XXXX(dev_ofnode(dev),
> they can also modified to dev_XXX function :
>
> ofnode_read_u32(dev_ofnode(dev), ...) => dev_read_u32(dev,....)
> ofnode_read_string(dev_ofnode(dev), ...) => dev_read_string(dev,....)
> ofnode_valid(dev_ofnode(dev)) => dev_has_ofnode(dev)
>
> but you prefer perhaps minizes the modifications in this patchset and if
> it is the case :
>
> Reviewed-by: Patrick Delaunay
>
>
> You can found some other examples below.

Thanks for that.

I wonder if we can press coccinelle into service here. I think the
dev_read() API came later so people didn't know about it?

Regards,
Simon

^ permalink raw reply	[flat|nested] 65+ messages in thread

end of thread, other threads:[~2021-01-07 12:36 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 17:39 [PATCH 00/26] dm: Preparation for enhanced of-platdata (part C) Simon Glass
2020-12-19 17:39 ` Simon Glass
2020-12-19 17:39 ` [PATCH 01/26] sandbox: serial: Move priv into a header file Simon Glass
2020-12-21 11:38   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:39 ` [PATCH 02/26] sandbox: i2c: " Simon Glass
2020-12-19 17:39 ` [PATCH 03/26] sandbox: Add a compatible string for spltest Simon Glass
2020-12-19 17:39 ` [PATCH 04/26] sandbox: Update dts files to reduce SPL size Simon Glass
2020-12-19 17:39 ` [PATCH 05/26] x86: apl: Move priv/plat structs to headers Simon Glass
2020-12-19 17:39 ` [PATCH 06/26] x86: Move priv/plat structs for intel_common " Simon Glass
2020-12-19 17:39 ` [PATCH 07/26] x86: spl: Move priv/plat structs " Simon Glass
2020-12-19 17:40 ` [PATCH 08/26] spi: Tidy up get/set of device node Simon Glass
2020-12-19 17:40 ` [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata Simon Glass
2020-12-19 17:40 ` [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash Simon Glass
2020-12-19 17:40 ` [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers Simon Glass
2020-12-19 17:40 ` [PATCH 12/26] x86: sysreset: Move priv/plat structs " Simon Glass
2020-12-21 11:38   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:40 ` [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data Simon Glass
2020-12-19 17:40 ` [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL Simon Glass
2020-12-19 17:40 ` [PATCH 15/26] x86: Drop rtc from SPL Simon Glass
2020-12-19 17:40 ` [PATCH 16/26] dm: core: Split out alloc code into a new function Simon Glass
2020-12-19 17:40 ` [PATCH 17/26] dm: core: Rename sqq to seq_ Simon Glass
2020-12-21 11:41   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:40 ` [PATCH 18/26] dm: core: Access device flags through functions Simon Glass
2020-12-19 17:40 ` [PATCH 19/26] dm: core: Rename device flags to indicate it is private Simon Glass
2020-12-19 17:40 ` [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode() Simon Glass
2020-12-19 17:40 ` [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid() Simon Glass
2020-12-21 11:41   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2021-01-04 11:01   ` Patrick DELAUNAY
2020-12-19 17:40 ` [PATCH 22/26] dm: core: Access device ofnode through functions Simon Glass
2020-12-19 17:40   ` Simon Glass
2021-01-04 13:02   ` Patrick DELAUNAY
2021-01-04 13:02     ` Patrick DELAUNAY
2021-01-07 12:36     ` Simon Glass
2021-01-07 12:36       ` Simon Glass
2020-12-19 17:40 ` [PATCH 23/26] dm: core: Rename device node to indicate it is private Simon Glass
2020-12-19 17:40 ` [PATCH 24/26] dm: core: Split out scanning code to dm_scan() Simon Glass
2020-12-19 17:40 ` [PATCH 25/26] dm: core: Allow the uclass list to move Simon Glass
2020-12-19 17:40 ` [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails Simon Glass
2020-12-28 16:26 ` [PATCH 25/26] dm: core: Allow the uclass list to move Simon Glass
2020-12-28 16:26 ` [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails Simon Glass
2020-12-28 16:26 ` [PATCH 24/26] dm: core: Split out scanning code to dm_scan() Simon Glass
2020-12-28 16:26 ` [PATCH 23/26] dm: core: Rename device node to indicate it is private Simon Glass
2020-12-28 16:26 ` [PATCH 22/26] dm: core: Access device ofnode through functions Simon Glass
2020-12-28 16:26   ` Simon Glass
2020-12-28 16:26 ` [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode() Simon Glass
2020-12-28 16:26 ` [PATCH 19/26] dm: core: Rename device flags to indicate it is private Simon Glass
2020-12-28 16:26 ` [PATCH 18/26] dm: core: Access device flags through functions Simon Glass
2020-12-28 16:26 ` [PATCH 16/26] dm: core: Split out alloc code into a new function Simon Glass
2020-12-28 16:26 ` [PATCH 15/26] x86: Drop rtc from SPL Simon Glass
2020-12-28 16:26 ` [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL Simon Glass
2020-12-28 16:26 ` [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data Simon Glass
2020-12-28 16:26 ` [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers Simon Glass
2020-12-28 16:26 ` [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata Simon Glass
2020-12-28 16:26 ` [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash Simon Glass
2020-12-28 16:26 ` [PATCH 08/26] spi: Tidy up get/set of device node Simon Glass
2020-12-28 16:26 ` [PATCH 07/26] x86: spl: Move priv/plat structs to headers Simon Glass
2020-12-28 16:26 ` [PATCH 06/26] x86: Move priv/plat structs for intel_common " Simon Glass
2020-12-28 16:26 ` [PATCH 05/26] x86: apl: Move priv/plat structs " Simon Glass
2020-12-28 16:26 ` [PATCH 04/26] sandbox: Update dts files to reduce SPL size Simon Glass
2020-12-28 16:26 ` [PATCH 03/26] sandbox: Add a compatible string for spltest Simon Glass
2020-12-28 16:26 ` [PATCH 02/26] sandbox: i2c: Move priv into a header file Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.