All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/32] sandbox: Move to SDL2
@ 2020-02-03 14:35 Simon Glass
  2020-02-03 14:35 ` [PATCH v2 01/32] sandbox: Sort the help options Simon Glass
                   ` (39 more replies)
  0 siblings, 40 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This series handles moving sandbox to the latest version of SDL, SDL2. It
provides a few more features, better performance and has been around for
long enough that it is present in distributions in the last several years.

Unfortunately it requires considerable rework of how memory allocation is
handled in sandbox.

At present sandbox is built such that it uses U-Boot's malloc() instead
of the C library's malloc. This mostly works but it is fragile, since any
use of libraries can cause strange behaviour. For example SDL ends up
calling U-Boot's malloc/free and this can confuse valgrind and even cause
a crash in some cases.

The simplest solution seems to be to set a prefix for the allocation
functions so that U-Boot's functions can co-exist with the C library's.
This requires a little bit of fiddling but it guarantees that things work
correctly in all circumstances.

We have got away with this for a long time partly due to the way that
SDL1.2 operates on init. But with SDL2 this does not seem to be possible.

As a result of this series, malloc() is #defined to dlmalloc() within
U-Boot (for sandbox only). The use of 'free' as a function in U-Boot is
thus best avoided, since it is #defined to dlfree. The series updates some
APIs to deal with this.

Changes in v2:
- Update the name of the implementing callback function too
- Drop the patch with the Roboto font
- Fix 'adress' typo

Simon Glass (32):
  sandbox: Sort the help options
  video: Support truetype fonts on a 32-bit display
  video: sandbox: Enable all colour depths
  mailbox: Rename free() to rfree()
  power-domain: Rename free() to rfree()
  reset: Rename free() to rfree()
  gpio: Rename free() to rfree()
  clk: Rename free() to rfree()
  dma: Rename free() to rfree()
  mtd: Rename free() to rfree()
  sandbox: Rename 'free' variable
  sandbox: Use a prefix for all allocation functions
  exports: Add the malloc.h header
  string: Allow arch override of strndup() also
  sandbox: Rename strdup() functions
  sandbox: Drop use of special os_malloc() where possible
  sandbox: Drop os_realloc()
  sandbox: Ensure that long-options array is terminated
  sandbox: Add a new header for the system malloc()
  sound: Add a new stop_play() method
  sandbox: sound: Handle errors better in sound_beep()
  sandbox: Add comments to the sdl struct
  sandbox: sdl: Improve error handling
  sandbox: sdl: Support waiting for audio to complete
  gitlab: Disable SDL when building sandbox
  sandbox: sdl: Move to use SDL2
  sandbox: sdl: Add an option to double the screen size
  sandbox: Support changing the LCD colour depth
  dm: core: Require users of devres to include the header
  dm: core: Create a new header file for 'compat' features
  dm: core: Drop the inclusion of linux/compat.h in dm.h
  sandbox: Complete migration away from os_malloc()

 .gitlab-ci.yml                                |   5 +-
 .travis.yml                                   |   2 +-
 arch/arm/mach-aspeed/ast2500/clk_ast2500.c    |   1 +
 arch/arm/mach-imx/cmd_nandbcb.c               |   2 +
 arch/arm/mach-imx/imx8/image.c                |   1 +
 arch/arm/mach-meson/board-info.c              |   1 +
 arch/arm/mach-meson/sm.c                      |   1 +
 arch/arm/mach-mvebu/mbus.c                    |   1 +
 arch/arm/mach-rockchip/px30/clk_px30.c        |   1 +
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c    |   1 +
 arch/arm/mach-rockchip/rk3128/clk_rk3128.c    |   1 +
 arch/arm/mach-rockchip/rk3188/clk_rk3188.c    |   1 +
 arch/arm/mach-rockchip/rk3188/rk3188.c        |   1 +
 arch/arm/mach-rockchip/rk322x/clk_rk322x.c    |   1 +
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c    |   1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c        |   2 +
 arch/arm/mach-rockchip/rk3308/clk_rk3308.c    |   1 +
 arch/arm/mach-rockchip/rk3308/rk3308.c        |   1 +
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c    |   1 +
 arch/arm/mach-rockchip/rk3368/clk_rk3368.c    |   1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c    |   1 +
 arch/arm/mach-rockchip/rv1108/clk_rv1108.c    |   1 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |   1 +
 arch/arm/mach-socfpga/clock_manager_arria10.c |   1 +
 arch/arm/mach-stm32mp/pwr_regulator.c         |   2 +
 arch/arm/mach-tegra/cboot.c                   |   1 +
 arch/arm/mach-zynq/clk.c                      |   1 +
 arch/arm/mach-zynq/timer.c                    |   1 +
 arch/mips/mach-mtmips/cpu.c                   |   1 +
 arch/mips/mach-pic32/cpu.c                    |   1 +
 arch/riscv/lib/andes_plic.c                   |   1 +
 arch/riscv/lib/andes_plmt.c                   |   1 +
 arch/riscv/lib/sifive_clint.c                 |   1 +
 arch/sandbox/config.mk                        |   2 +-
 arch/sandbox/cpu/cpu.c                        |   1 +
 arch/sandbox/cpu/eth-raw-os.c                 |   6 +-
 arch/sandbox/cpu/os.c                         |  48 +--
 arch/sandbox/cpu/sdl.c                        | 338 +++++++++++-------
 arch/sandbox/cpu/start.c                      |  62 +++-
 arch/sandbox/cpu/state.c                      |  23 +-
 arch/sandbox/dts/sandbox.dtsi                 |   1 +
 arch/sandbox/include/asm/malloc.h             |  26 ++
 arch/sandbox/include/asm/sdl.h                |   9 +-
 arch/sandbox/include/asm/state.h              |   1 +
 arch/sandbox/include/asm/test.h               |   7 +
 arch/x86/cpu/apollolake/fsp_s.c               |   1 +
 arch/x86/cpu/apollolake/itss.c                |   1 +
 arch/x86/cpu/apollolake/spl.c                 |   1 +
 arch/x86/cpu/apollolake/uart.c                |   1 +
 arch/x86/cpu/qemu/e820.c                      |   1 +
 arch/x86/cpu/qfw_cpu.c                        |   1 +
 arch/x86/lib/coreboot_table.c                 |   1 +
 arch/x86/lib/fsp1/fsp_common.c                |   1 +
 arch/x86/lib/mrccache.c                       |   1 +
 arch/x86/lib/tables.c                         |   1 +
 board/compulab/common/common.c                |   1 +
 board/corscience/tricorder/tricorder.c        |   1 +
 board/gardena/smart-gateway-mt7688/board.c    |   1 +
 board/ge/common/vpd_reader.c                  |   1 +
 board/google/veyron/veyron.c                  |   1 +
 board/hisilicon/poplar/poplar.c               |   2 +-
 board/isee/igep003x/board.c                   |   1 +
 board/isee/igep00x0/igep00x0.c                |   1 +
 board/menlo/m53menlo/m53menlo.c               |   1 +
 board/microchip/pic32mzda/pic32mzda.c         |   1 +
 board/overo/overo.c                           |   1 +
 board/siemens/common/board.c                  |   1 +
 board/siemens/pxm2/board.c                    |   1 +
 board/siemens/rut/board.c                     |   1 +
 board/st/stm32mp1/stm32mp1.c                  |   2 +
 board/synopsys/hsdk/clk-lib.c                 |   1 +
 board/technexion/tao3530/tao3530.c            |   1 +
 board/ti/am335x/board.c                       |   1 +
 board/ti/am57xx/board.c                       |   1 +
 board/timll/devkit8000/devkit8000.c           |   1 +
 cmd/bootefi.c                                 |   1 +
 cmd/gpio.c                                    |   2 +
 cmd/gpt.c                                     |   1 +
 cmd/host.c                                    |   1 +
 cmd/mtd.c                                     |   2 +
 cmd/rng.c                                     |   1 +
 cmd/tpm-common.c                              |   1 +
 cmd/ubi.c                                     |   2 +
 cmd/usb_mass_storage.c                        |   1 +
 cmd/ximg.c                                    |   1 +
 common/android_ab.c                           |   1 +
 common/autoboot.c                             |   1 +
 common/exports.c                              |   1 +
 common/image-fdt.c                            |   1 +
 common/image.c                                |   1 +
 common/usb.c                                  |   1 +
 common/usb_hub.c                              |   1 +
 configs/sandbox64_defconfig                   |   1 -
 configs/sandbox_defconfig                     |   1 -
 configs/sandbox_flattree_defconfig            |   1 -
 configs/sandbox_spl_defconfig                 |   1 -
 doc/arch/sandbox.rst                          |   2 +-
 doc/device-tree-bindings/video/sandbox-fb.txt |   6 +-
 drivers/adc/rockchip-saradc.c                 |   1 +
 drivers/adc/stm32-adc-core.c                  |   1 +
 drivers/adc/stm32-adc.c                       |   1 +
 drivers/axi/sandbox_store.c                   |   1 +
 drivers/block/blk-uclass.c                    |   2 +
 drivers/block/sandbox.c                       |   1 +
 drivers/clk/altera/clk-arria10.c              |   3 +
 drivers/clk/aspeed/clk_ast2500.c              |   1 +
 drivers/clk/at91/clk-generated.c              |   2 +
 drivers/clk/at91/clk-h32mx.c                  |   1 +
 drivers/clk/at91/clk-peripheral.c             |   1 +
 drivers/clk/at91/clk-usb.c                    |   1 +
 drivers/clk/clk-cdce9xx.c                     |   1 +
 drivers/clk/clk-composite.c                   |   2 +
 drivers/clk/clk-divider.c                     |   2 +
 drivers/clk/clk-fixed-factor.c                |   2 +
 drivers/clk/clk-gate.c                        |   2 +
 drivers/clk/clk-mux.c                         |   2 +
 drivers/clk/clk-ti-sci.c                      |   5 +-
 drivers/clk/clk-uclass.c                      |   9 +-
 drivers/clk/clk_fixed_factor.c                |   1 +
 drivers/clk/clk_sandbox.c                     |   3 +-
 drivers/clk/clk_sandbox_ccf.c                 |   3 +
 drivers/clk/clk_sandbox_test.c                |   3 +
 drivers/clk/clk_versal.c                      |   2 +
 drivers/clk/clk_vexpress_osc.c                |   1 +
 drivers/clk/clk_zynq.c                        |   1 +
 drivers/clk/clk_zynqmp.c                      |   3 +
 drivers/clk/imx/clk-composite-8m.c            |   2 +
 drivers/clk/imx/clk-gate2.c                   |   2 +
 drivers/clk/imx/clk-imx8.c                    |   1 +
 drivers/clk/imx/clk-pfd.c                     |   2 +
 drivers/clk/imx/clk-pll14xx.c                 |   2 +
 drivers/clk/imx/clk-pllv3.c                   |   2 +
 drivers/clk/meson/axg.c                       |   1 +
 drivers/clk/meson/g12a.c                      |   1 +
 drivers/clk/meson/gxbb.c                      |   1 +
 drivers/clk/mvebu/armada-37xx-periph.c        |   1 +
 drivers/clk/mvebu/armada-37xx-tbg.c           |   1 +
 drivers/clk/rockchip/clk_px30.c               |   1 +
 drivers/clk/rockchip/clk_rk3036.c             |   1 +
 drivers/clk/rockchip/clk_rk3128.c             |   1 +
 drivers/clk/rockchip/clk_rk3188.c             |   2 +
 drivers/clk/rockchip/clk_rk322x.c             |   1 +
 drivers/clk/rockchip/clk_rk3288.c             |   2 +
 drivers/clk/rockchip/clk_rk3308.c             |   1 +
 drivers/clk/rockchip/clk_rk3328.c             |   1 +
 drivers/clk/rockchip/clk_rk3368.c             |   1 +
 drivers/clk/rockchip/clk_rk3399.c             |   1 +
 drivers/clk/rockchip/clk_rv1108.c             |   1 +
 drivers/clk/sifive/fu540-prci.c               |   1 +
 drivers/clk/tegra/tegra-car-clk.c             |   3 +-
 drivers/clk/uniphier/clk-uniphier-core.c      |   1 +
 drivers/core/devres.c                         |   2 +
 drivers/core/of_access.c                      |   1 +
 drivers/core/ofnode.c                         |   1 +
 drivers/core/syscon-uclass.c                  |   1 +
 drivers/ddr/altera/sdram_gen5.c               |   1 +
 drivers/ddr/altera/sdram_soc64.c              |   1 +
 drivers/dfu/dfu_mtd.c                         |   1 +
 drivers/dma/bcm6348-iudma.c                   |   1 +
 drivers/dma/dma-uclass.c                      |   5 +-
 drivers/dma/sandbox-dma-test.c                |   5 +-
 drivers/dma/ti/k3-udma.c                      |   8 +-
 drivers/firmware/ti_sci.c                     |   3 +
 drivers/fpga/fpga.c                           |   1 +
 drivers/gpio/74x164_gpio.c                    |   1 +
 drivers/gpio/adi_gpio2.c                      |   1 +
 drivers/gpio/at91_gpio.c                      |   1 +
 drivers/gpio/atmel_pio4.c                     |   1 +
 drivers/gpio/da8xx_gpio.c                     |   1 +
 drivers/gpio/dwapb_gpio.c                     |   2 +
 drivers/gpio/gpio-rcar.c                      |   4 +-
 drivers/gpio/gpio-uclass.c                    |   4 +-
 drivers/gpio/kona_gpio.c                      |   1 +
 drivers/gpio/mpc83xx_gpio.c                   |   1 +
 drivers/gpio/mscc_sgpio.c                     |   2 +
 drivers/gpio/mvgpio.c                         |   1 +
 drivers/gpio/mxs_gpio.c                       |   1 +
 drivers/gpio/pca953x_gpio.c                   |   1 +
 drivers/gpio/pca9698.c                        |   1 +
 drivers/gpio/sh_pfc.c                         |   1 +
 drivers/gpio/spear_gpio.c                     |   1 +
 drivers/gpio/stm32_gpio.c                     |   1 +
 drivers/hwspinlock/hwspinlock-uclass.c        |   2 +
 drivers/hwspinlock/stm32_hwspinlock.c         |   1 +
 drivers/i2c/ast_i2c.c                         |   1 +
 drivers/i2c/at91_i2c.c                        |   1 +
 drivers/i2c/designware_i2c.c                  |   3 +
 drivers/i2c/i2c-uniphier-f.c                  |   1 +
 drivers/i2c/i2c-uniphier.c                    |   1 +
 drivers/i2c/imx_lpi2c.c                       |   1 +
 drivers/i2c/meson_i2c.c                       |   1 +
 drivers/i2c/muxes/i2c-arb-gpio-challenge.c    |   1 +
 drivers/i2c/muxes/i2c-mux-gpio.c              |   2 +
 drivers/i2c/muxes/i2c-mux-uclass.c            |   1 +
 drivers/i2c/muxes/pca954x.c                   |   1 +
 drivers/i2c/mxc_i2c.c                         |   1 +
 drivers/i2c/rcar_i2c.c                        |   1 +
 drivers/i2c/stm32f7_i2c.c                     |   1 +
 drivers/i2c/tegra_i2c.c                       |   1 +
 drivers/i2c/xilinx_xiic.c                     |   1 +
 drivers/led/led_gpio.c                        |   1 +
 drivers/mailbox/k3-sec-proxy.c                |   4 +-
 drivers/mailbox/mailbox-uclass.c              |   5 +-
 drivers/mailbox/sandbox-mbox-test.c           |   1 +
 drivers/mailbox/sandbox-mbox.c                |   3 +-
 drivers/mailbox/stm32-ipcc.c                  |   4 +-
 drivers/mailbox/tegra-hsp.c                   |   3 +-
 drivers/mailbox/zynqmp-ipi.c                  |   1 +
 drivers/misc/cros_ec_sandbox.c                |   8 +-
 drivers/misc/imx8/scu_api.c                   |   1 +
 drivers/misc/k3_avs.c                         |   1 +
 drivers/misc/microchip_flexcom.c              |   1 +
 drivers/misc/p2sb-uclass.c                    |   1 +
 drivers/misc/stm32_rcc.c                      |   1 +
 drivers/misc/tegra186_bpmp.c                  |   2 +
 drivers/misc/vexpress_config.c                |   1 +
 drivers/mmc/am654_sdhci.c                     |   2 +
 drivers/mmc/arm_pl180_mmci.c                  |   1 +
 drivers/mmc/aspeed_sdhci.c                    |   1 +
 drivers/mmc/bcm2835_sdhost.c                  |   1 +
 drivers/mmc/fsl_esdhc.c                       |   1 +
 drivers/mmc/fsl_esdhc_imx.c                   |   2 +
 drivers/mmc/jz_mmc.c                          |   1 +
 drivers/mmc/mmc-uclass.c                      |   2 +
 drivers/mmc/msm_sdhci.c                       |   1 +
 drivers/mmc/mtk-sd.c                          |   1 +
 drivers/mmc/omap_hsmmc.c                      |   2 +
 drivers/mmc/renesas-sdhi.c                    |   2 +
 drivers/mmc/rockchip_sdhci.c                  |   1 +
 drivers/mmc/sdhci-cadence.c                   |   1 +
 drivers/mmc/sh_mmcif.c                        |   1 +
 drivers/mmc/sh_sdhi.c                         |   1 +
 drivers/mmc/snps_dw_mmc.c                     |   1 +
 drivers/mmc/socfpga_dw_mmc.c                  |   1 +
 drivers/mmc/stm32_sdmmc2.c                    |   1 +
 drivers/mmc/tegra_mmc.c                       |   1 +
 drivers/mmc/tmio-common.c                     |   1 +
 drivers/mmc/uniphier-sd.c                     |   2 +
 drivers/mmc/zynq_sdhci.c                      |   2 +
 drivers/mtd/hbmc-am654.c                      |   1 +
 drivers/mtd/mtd_uboot.c                       |   2 +
 drivers/mtd/mtdconcat.c                       |   1 +
 drivers/mtd/mtdcore.c                         |   5 +-
 drivers/mtd/mtdpart.c                         |   1 +
 drivers/mtd/nand/bbt.c                        |   1 +
 drivers/mtd/nand/core.c                       |   1 +
 drivers/mtd/nand/raw/atmel_nand.c             |   2 +
 drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c |   1 +
 drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c  |   1 +
 drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c  |   1 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      |   3 +
 .../mtd/nand/raw/brcmnand/brcmnand_compat.c   |   2 +
 drivers/mtd/nand/raw/denali.c                 |   6 +-
 drivers/mtd/nand/raw/denali_dt.c              |   1 +
 drivers/mtd/nand/raw/fsl_elbc_nand.c          |   1 +
 drivers/mtd/nand/raw/fsl_ifc_nand.c           |   1 +
 drivers/mtd/nand/raw/mxs_nand_spl.c           |   1 +
 drivers/mtd/nand/raw/nand_base.c              |   1 +
 drivers/mtd/nand/raw/nand_bbt.c               |   1 +
 drivers/mtd/nand/raw/nand_bch.c               |   1 +
 drivers/mtd/nand/raw/nand_timings.c           |   1 +
 drivers/mtd/nand/raw/nand_util.c              |   1 +
 drivers/mtd/nand/raw/pxa3xx_nand.c            |   3 +
 drivers/mtd/nand/raw/stm32_fmc2_nand.c        |   1 +
 drivers/mtd/nand/raw/sunxi_nand.c             |   4 +
 drivers/mtd/nand/raw/tegra_nand.c             |   1 +
 drivers/mtd/nand/raw/vf610_nfc.c              |   1 +
 drivers/mtd/nand/spi/core.c                   |   4 +-
 drivers/mtd/nand/spi/gigadevice.c             |   3 +-
 drivers/mtd/nand/spi/macronix.c               |   3 +-
 drivers/mtd/nand/spi/micron.c                 |   3 +-
 drivers/mtd/nand/spi/winbond.c                |   3 +-
 drivers/mtd/onenand/onenand_base.c            |   1 +
 drivers/mtd/renesas_rpc_hf.c                  |   2 +
 drivers/mtd/spi/sf-uclass.c                   |   1 +
 drivers/mtd/spi/spi-nor-core.c                |   2 +
 drivers/mtd/spi/spi-nor-tiny.c                |   1 +
 drivers/mtd/ubi/attach.c                      |   1 +
 drivers/mtd/ubi/build.c                       |   1 +
 drivers/mtd/ubi/debug.c                       |   2 +
 drivers/mtd/ubi/eba.c                         |   1 +
 drivers/mtd/ubi/fastmap.c                     |   2 +
 drivers/mtd/ubi/io.c                          |   1 +
 drivers/mtd/ubi/kapi.c                        |   1 +
 drivers/mtd/ubi/misc.c                        |   1 +
 drivers/mtd/ubi/upd.c                         |   1 +
 drivers/mtd/ubi/vmt.c                         |   1 +
 drivers/mtd/ubi/vtbl.c                        |   1 +
 drivers/mtd/ubi/wl.c                          |   1 +
 drivers/net/bcm6348-eth.c                     |   1 +
 drivers/net/bcm6368-eth.c                     |   2 +
 drivers/net/designware.c                      |   2 +
 drivers/net/dwc_eth_qos.c                     |   1 +
 drivers/net/dwmac_socfpga.c                   |   2 +
 drivers/net/e1000.c                           |   1 +
 drivers/net/e1000_spi.c                       |   1 +
 drivers/net/fsl-mc/dpio/qbman_portal.c        |   1 +
 drivers/net/fsl-mc/mc.c                       |   1 +
 drivers/net/fsl_enetc.c                       |   1 +
 drivers/net/ftgmac100.c                       |   2 +
 drivers/net/higmacv300.c                      |   1 +
 drivers/net/mscc_eswitch/jr2_switch.c         |   1 +
 drivers/net/mscc_eswitch/luton_switch.c       |   1 +
 drivers/net/mscc_eswitch/ocelot_switch.c      |   1 +
 drivers/net/mscc_eswitch/serval_switch.c      |   1 +
 drivers/net/mscc_eswitch/servalt_switch.c     |   1 +
 drivers/net/mtk_eth.c                         |   1 +
 drivers/net/mvneta.c                          |   2 +
 drivers/net/mvpp2.c                           |   3 +
 drivers/net/pch_gbe.c                         |   1 +
 drivers/net/pfe_eth/pfe_driver.c              |   1 +
 drivers/net/pfe_eth/pfe_eth.c                 |   1 +
 drivers/net/pfe_eth/pfe_firmware.c            |   1 +
 drivers/net/pfe_eth/pfe_mdio.c                |   1 +
 drivers/net/phy/dp83867.c                     |   1 +
 drivers/net/phy/fixed.c                       |   1 +
 drivers/net/pic32_eth.c                       |   1 +
 drivers/net/sandbox-raw-bus.c                 |   1 +
 drivers/net/sni_ave.c                         |   7 +-
 drivers/net/sun8i_emac.c                      |   1 +
 drivers/net/sunxi_emac.c                      |   1 +
 drivers/net/ti/am65-cpsw-nuss.c               |   2 +
 drivers/net/ti/cpsw-common.c                  |   1 +
 drivers/net/ti/cpsw.c                         |   1 +
 drivers/net/ti/cpsw_mdio.c                    |   1 +
 drivers/net/zynq_gem.c                        |   2 +
 drivers/nvme/nvme.c                           |   2 +
 drivers/pci/pci-aardvark.c                    |   1 +
 drivers/pci/pci-uclass.c                      |   1 +
 drivers/pci/pci_mvebu.c                       |   1 +
 drivers/pci/pcie_dw_ti.c                      |   2 +
 drivers/pci/pcie_fsl.c                        |   1 +
 drivers/pci/pcie_imx.c                        |   1 +
 drivers/pci/pcie_intel_fpga.c                 |   1 +
 drivers/pci/pcie_mediatek.c                   |   2 +
 drivers/phy/allwinner/phy-sun4i-usb.c         |   2 +
 drivers/phy/bcm6318-usbh-phy.c                |   1 +
 drivers/phy/bcm6348-usbh-phy.c                |   1 +
 drivers/phy/bcm6358-usbh-phy.c                |   1 +
 drivers/phy/bcm6368-usbh-phy.c                |   1 +
 drivers/phy/marvell/comphy_core.c             |   2 +
 drivers/phy/meson-g12a-usb2.c                 |   1 +
 drivers/phy/meson-g12a-usb3-pcie.c            |   1 +
 drivers/phy/meson-gxl-usb2.c                  |   1 +
 drivers/phy/meson-gxl-usb3.c                  |   1 +
 drivers/phy/omap-usb2-phy.c                   |   1 +
 drivers/phy/phy-mtk-tphy.c                    |   3 +
 drivers/phy/phy-rcar-gen2.c                   |   2 +
 drivers/phy/phy-rcar-gen3.c                   |   1 +
 drivers/phy/phy-stm32-usbphyc.c               |   1 +
 drivers/phy/phy-ti-am654.c                    |   2 +
 drivers/phy/ti-pipe3-phy.c                    |   1 +
 drivers/pinctrl/broadcom/pinctrl-bcm6838.c    |   1 +
 drivers/pinctrl/intel/pinctrl.c               |   2 +
 drivers/pinctrl/meson/pinctrl-meson.c         |   2 +
 drivers/pinctrl/mscc/mscc-common.c            |   2 +
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |   1 +
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c   |   3 +
 drivers/pinctrl/nxp/pinctrl-imx.c             |   3 +
 drivers/pinctrl/nxp/pinctrl-mxs.c             |   2 +
 drivers/pinctrl/pinctrl-generic.c             |   1 +
 drivers/pinctrl/pinctrl-single.c              |   1 +
 drivers/pinctrl/pinctrl-stmfx.c               |   1 +
 drivers/pinctrl/pinctrl-uclass.c              |   2 +
 drivers/pinctrl/pinctrl_stm32.c               |   3 +
 drivers/pinctrl/renesas/pfc.c                 |   2 +
 .../pinctrl/uniphier/pinctrl-uniphier-core.c  |   1 +
 drivers/power/domain/bcm6328-power-domain.c   |   3 +-
 .../power/domain/imx8-power-domain-legacy.c   |   3 +-
 drivers/power/domain/imx8-power-domain.c      |   3 +-
 drivers/power/domain/imx8m-power-domain.c     |   3 +-
 drivers/power/domain/meson-ee-pwrc.c          |   4 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c      |   4 +-
 drivers/power/domain/mtk-power-domain.c       |   4 +-
 drivers/power/domain/power-domain-uclass.c    |   3 +-
 .../power/domain/sandbox-power-domain-test.c  |   1 +
 drivers/power/domain/sandbox-power-domain.c   |   3 +-
 drivers/power/domain/tegra186-power-domain.c  |   3 +-
 drivers/power/domain/ti-sci-power-domain.c    |   5 +-
 drivers/power/pmic/fan53555.c                 |   1 +
 drivers/power/pmic/i2c_pmic_emul.c            |   1 +
 drivers/power/pmic/stpmic1.c                  |   1 +
 drivers/power/regulator/pbias_regulator.c     |   1 +
 drivers/power/regulator/pwm_regulator.c       |   1 +
 drivers/power/regulator/stm32-vrefbuf.c       |   1 +
 drivers/power/regulator/tps62360_regulator.c  |   1 +
 drivers/ram/imxrt_sdram.c                     |   1 +
 drivers/ram/k3-am654-ddrss.c                  |   1 +
 drivers/ram/k3-j721e/k3-j721e-ddrss.c         |   1 +
 drivers/ram/rockchip/dmc-rk3368.c             |   1 +
 drivers/ram/stm32_sdram.c                     |   1 +
 drivers/remoteproc/k3_system_controller.c     |   1 +
 drivers/remoteproc/rproc-elf-loader.c         |   2 +
 drivers/remoteproc/stm32_copro.c              |   2 +
 drivers/remoteproc/ti_k3_arm64_rproc.c        |   2 +
 drivers/remoteproc/ti_k3_dsp_rproc.c          |   3 +
 drivers/remoteproc/ti_k3_r5f_rproc.c          |   3 +
 drivers/reset/reset-bcm6345.c                 |   3 +-
 drivers/reset/reset-hisilicon.c               |   3 +-
 drivers/reset/reset-hsdk.c                    |   2 +-
 drivers/reset/reset-imx7.c                    |   3 +-
 drivers/reset/reset-mediatek.c                |   4 +-
 drivers/reset/reset-meson.c                   |   3 +-
 drivers/reset/reset-mtmips.c                  |   3 +-
 drivers/reset/reset-rockchip.c                |   3 +-
 drivers/reset/reset-socfpga.c                 |   3 +-
 drivers/reset/reset-sunxi.c                   |   3 +-
 drivers/reset/reset-ti-sci.c                  |   5 +-
 drivers/reset/reset-uclass.c                  |   4 +-
 drivers/reset/reset-uniphier.c                |   4 +-
 drivers/reset/sandbox-reset-test.c            |   1 +
 drivers/reset/sandbox-reset.c                 |   3 +-
 drivers/reset/sti-reset.c                     |   3 +-
 drivers/reset/stm32-reset.c                   |   3 +-
 drivers/reset/tegra-car-reset.c               |   3 +-
 drivers/reset/tegra186-reset.c                |   3 +-
 drivers/rtc/ds3232.c                          |   1 +
 drivers/rtc/rv3029.c                          |   1 +
 drivers/rtc/stm32_rtc.c                       |   2 +
 drivers/serial/atmel_usart.c                  |   1 +
 drivers/serial/ns16550.c                      |   1 +
 drivers/serial/serial-uclass.c                |   1 +
 drivers/serial/serial_bcm6345.c               |   1 +
 drivers/serial/serial_lpuart.c                |   1 +
 drivers/serial/serial_msm.c                   |   1 +
 drivers/serial/serial_mtk.c                   |   3 +-
 drivers/serial/serial_omap.c                  |   1 +
 drivers/serial/serial_pic32.c                 |   1 +
 drivers/serial/serial_sifive.c                |   1 +
 drivers/serial/serial_stm32.c                 |   1 +
 drivers/serial/serial_zynq.c                  |   2 +
 drivers/smem/msm_smem.c                       |   3 +
 drivers/soc/ti/k3-navss-ringacc.c             |   3 +
 drivers/sound/sandbox.c                       |  21 +-
 drivers/sound/sound-uclass.c                  |  17 +-
 drivers/spi/atmel-quadspi.c                   |   3 +
 drivers/spi/bcm63xx_hsspi.c                   |   1 +
 drivers/spi/bcm63xx_spi.c                     |   1 +
 drivers/spi/cadence_qspi.c                    |   2 +
 drivers/spi/designware_spi.c                  |   1 +
 drivers/spi/mvebu_a3700_spi.c                 |   1 +
 drivers/spi/mxc_spi.c                         |   1 +
 drivers/spi/spi-mem-nodm.c                    |   1 +
 drivers/spi/spi-mem.c                         |   2 +
 drivers/spi/spi-sunxi.c                       |   1 +
 drivers/spi/stm32_qspi.c                      |   1 +
 drivers/spi/stm32_spi.c                       |   2 +
 drivers/spi/ti_qspi.c                         |   1 +
 drivers/spi/uniphier_spi.c                    |   1 +
 drivers/spi/zynqmp_gqspi.c                    |   2 +
 drivers/spmi/spmi-msm.c                       |   1 +
 drivers/sysreset/sysreset-ti-sci.c            |   2 +
 drivers/sysreset/sysreset_syscon.c            |   1 +
 drivers/tee/optee/core.c                      |   2 +
 drivers/tee/optee/rpmb.c                      |   1 +
 drivers/tee/optee/supplicant.c                |   1 +
 drivers/tee/tee-uclass.c                      |   3 +-
 drivers/timer/ast_timer.c                     |   1 +
 drivers/timer/cadence-ttc.c                   |   1 +
 drivers/timer/dw-apb-timer.c                  |   2 +
 drivers/timer/ostm_timer.c                    |   1 +
 drivers/timer/stm32_timer.c                   |   1 +
 drivers/timer/timer-uclass.c                  |   1 +
 drivers/ufs/cdns-platform.c                   |   2 +
 drivers/ufs/ti-j721e-ufs.c                    |   2 +
 drivers/ufs/ufs.c                             |   2 +
 drivers/usb/cdns3/cdns3-ti.c                  |   1 +
 drivers/usb/cdns3/core.c                      |   2 +
 drivers/usb/cdns3/drd.c                       |   1 +
 drivers/usb/cdns3/ep0.c                       |   1 +
 drivers/usb/cdns3/gadget.c                    |   3 +
 drivers/usb/cdns3/host.c                      |   1 +
 drivers/usb/dwc3/core.c                       |   3 +
 drivers/usb/dwc3/dwc3-omap.c                  |   2 +
 drivers/usb/dwc3/dwc3-uniphier.c              |   1 +
 drivers/usb/dwc3/ep0.c                        |   1 +
 drivers/usb/dwc3/gadget.c                     |   2 +
 drivers/usb/dwc3/ti_usb_phy.c                 |   2 +
 drivers/usb/gadget/at91_udc.c                 |   2 +
 drivers/usb/gadget/composite.c                |   1 +
 drivers/usb/gadget/dwc2_udc_otg.c             |   2 +
 drivers/usb/gadget/f_mass_storage.c           |   1 +
 drivers/usb/gadget/pxa25x_udc.c               |   1 +
 drivers/usb/gadget/storage_common.c           |   1 +
 drivers/usb/gadget/udc/udc-core.c             |   2 +
 drivers/usb/host/dwc2.c                       |   1 +
 drivers/usb/host/ehci-atmel.c                 |   1 +
 drivers/usb/host/ehci-generic.c               |   2 +
 drivers/usb/host/ehci-hcd.c                   |   1 +
 drivers/usb/host/ohci-da8xx.c                 |   3 +
 drivers/usb/host/ohci-generic.c               |   2 +
 drivers/usb/host/r8a66597-hcd.c               |   1 +
 drivers/usb/host/xhci-rcar.c                  |   2 +
 drivers/usb/musb-new/am35x.c                  |   2 +
 drivers/usb/musb-new/da8xx.c                  |   1 +
 drivers/usb/musb-new/musb_core.c              |   2 +
 drivers/usb/musb-new/musb_dsps.c              |   2 +
 drivers/usb/musb-new/musb_gadget.c            |   2 +
 drivers/usb/musb-new/musb_gadget_ep0.c        |   1 +
 drivers/usb/musb-new/musb_host.c              |   2 +
 drivers/usb/musb-new/musb_uboot.c             |   2 +
 drivers/usb/musb-new/omap2430.c               |   2 +
 drivers/usb/musb-new/pic32.c                  |   1 +
 drivers/usb/musb-new/sunxi.c                  |   2 +
 drivers/usb/musb-new/ti-musb.c                |   1 +
 drivers/usb/phy/omap_usb_phy.c                |   1 +
 drivers/video/Kconfig                         |   4 +-
 drivers/video/atmel_hlcdfb.c                  |   1 +
 drivers/video/console_truetype.c              |  22 ++
 drivers/video/da8xx-fb.c                      |   1 +
 drivers/video/dw_mipi_dsi.c                   |   1 +
 drivers/video/exynos/exynos_mipi_dsi.c        |   1 +
 drivers/video/hitachi_tx18d42vm_lcd.c         |   1 +
 drivers/video/mali_dp.c                       |   2 +
 drivers/video/mipi_dsi.c                      |   1 +
 drivers/video/mvebu_lcd.c                     |   1 +
 drivers/video/mxsfb.c                         |   1 +
 drivers/video/orisetech_otm8009a.c            |   1 +
 drivers/video/pwm_backlight.c                 |   1 +
 drivers/video/raydium-rm68200.c               |   1 +
 drivers/video/rockchip/rk3288_hdmi.c          |   1 +
 drivers/video/rockchip/rk3288_mipi.c          |   1 +
 drivers/video/rockchip/rk3399_mipi.c          |   1 +
 drivers/video/rockchip/rk_edp.c               |   1 +
 drivers/video/rockchip/rk_vop.c               |   1 +
 drivers/video/sandbox_osd.c                   |   1 +
 drivers/video/sandbox_sdl.c                   |  13 +-
 drivers/video/scf0403_lcd.c                   |   1 +
 drivers/video/ssd2828.c                       |   1 +
 drivers/video/stm32/stm32_dsi.c               |   1 +
 drivers/video/stm32/stm32_ltdc.c              |   1 +
 drivers/video/tegra124/sor.c                  |   1 +
 drivers/video/video-uclass.c                  |   1 +
 drivers/virtio/virtio-uclass.c                |   1 +
 drivers/virtio/virtio_mmio.c                  |   1 +
 drivers/virtio/virtio_pci_legacy.c            |   1 +
 drivers/virtio/virtio_pci_modern.c            |   1 +
 drivers/virtio/virtio_ring.c                  |   1 +
 drivers/virtio/virtio_sandbox.c               |   1 +
 drivers/w1-eeprom/ds2502.c                    |   1 +
 drivers/w1/mxc_w1.c                           |   1 +
 drivers/watchdog/armada-37xx-wdt.c            |   1 +
 drivers/watchdog/ast_wdt.c                    |   1 +
 drivers/watchdog/cdns_wdt.c                   |   2 +
 drivers/watchdog/sp805_wdt.c                  |   1 +
 drivers/watchdog/xilinx_tb_wdt.c              |   1 +
 fs/ext4/ext4_write.c                          |   1 +
 fs/ext4/ext4fs.c                              |   1 +
 fs/fat/fat_write.c                            |   1 +
 fs/sandbox/sandboxfs.c                        |   1 +
 fs/ubifs/debug.c                              |   1 +
 fs/ubifs/gc.c                                 |   1 +
 fs/ubifs/io.c                                 |   1 +
 fs/ubifs/log.c                                |   1 +
 fs/ubifs/lprops.c                             |   1 +
 fs/ubifs/lpt.c                                |   1 +
 fs/ubifs/lpt_commit.c                         |   1 +
 fs/ubifs/master.c                             |   1 +
 fs/ubifs/orphan.c                             |   1 +
 fs/ubifs/recovery.c                           |   1 +
 fs/ubifs/replay.c                             |   1 +
 fs/ubifs/sb.c                                 |   1 +
 fs/ubifs/scan.c                               |   1 +
 fs/ubifs/super.c                              |   1 +
 fs/ubifs/tnc.c                                |   1 +
 fs/ubifs/tnc_misc.c                           |   1 +
 fs/ubifs/ubifs.c                              |   2 +
 fs/yaffs2/yaffs_allocator.c                   |   1 +
 fs/yaffs2/yaffs_checkptrw.c                   |   1 +
 fs/yaffs2/yaffs_guts.c                        |   1 +
 fs/yaffs2/yaffs_nandif.c                      |   1 +
 fs/yaffs2/yaffs_summary.c                     |   1 +
 fs/yaffs2/yaffs_uboot_glue.c                  |   1 +
 fs/yaffs2/yaffs_yaffs1.c                      |   1 +
 fs/yaffs2/yaffs_yaffs2.c                      |   1 +
 fs/yaffs2/yaffsfs.c                           |   1 +
 include/asm-generic/gpio.h                    |   2 +-
 include/clk-uclass.h                          |   4 +-
 include/dm/device.h                           |  74 ----
 include/dm/device_compat.h                    |  86 +++++
 include/dm/devres.h                           |   4 +
 include/dma-uclass.h                          |   4 +-
 include/linux/clk-provider.h                  |   1 +
 include/linux/compat.h                        |   3 +
 include/linux/mtd/mtd.h                       |   4 +-
 include/linux/string.h                        |   7 +-
 include/mailbox-uclass.h                      |   4 +-
 include/malloc.h                              |  24 +-
 include/os.h                                  |  22 +-
 include/phy.h                                 |   1 +
 include/power-domain-uclass.h                 |   4 +-
 include/reset-uclass.h                        |   4 +-
 include/sound.h                               |  12 +
 lib/bch.c                                     |   2 +
 lib/binman.c                                  |   1 +
 lib/bzip2/bzlib.c                             |   1 +
 lib/crypto/asymmetric_type.c                  |   2 +
 lib/crypto/pkcs7_parser.c                     |   1 +
 lib/crypto/public_key.c                       |   2 +
 lib/crypto/rsa_helper.c                       |   1 +
 lib/crypto/x509_cert_parser.c                 |   1 +
 lib/crypto/x509_public_key.c                  |   2 +
 lib/efi/efi.c                                 |   1 +
 lib/efi/efi_app.c                             |   1 +
 lib/efi/efi_stub.c                            |   1 +
 lib/efi_driver/efi_block_device.c             |   1 +
 lib/efi_driver/efi_uclass.c                   |   1 +
 lib/efi_loader/efi_console.c                  |   1 +
 lib/efi_loader/efi_runtime.c                  |   1 +
 lib/fdtdec.c                                  |   1 +
 lib/libavb/avb_cmdline.c                      |   1 +
 lib/libavb/avb_descriptor.c                   |   1 +
 lib/libavb/avb_rsa.c                          |   1 +
 lib/libavb/avb_slot_verify.c                  |   1 +
 lib/libavb/avb_sysdeps_posix.c                |   1 +
 lib/libavb/avb_util.c                         |   1 +
 lib/linux_compat.c                            |   1 +
 lib/list_sort.c                               |   1 +
 lib/lmb.c                                     |   1 +
 lib/rsa/rsa-sign.c                            |   1 +
 lib/rsa/rsa-verify.c                          |   1 +
 lib/string.c                                  |   2 +-
 lib/zstd/decompress.c                         |   1 +
 lib/zstd/zstd_common.c                        |   1 +
 net/mdio-uclass.c                             |   3 +
 post/post.c                                   |   1 +
 test/dm/clk.c                                 |   1 +
 test/dm/devres.c                              |   1 +
 test/dm/dma.c                                 |   1 +
 test/dm/gpio.c                                |   1 +
 test/dm/mailbox.c                             |   1 +
 test/dm/power-domain.c                        |   1 +
 test/dm/regmap.c                              |   1 +
 test/dm/reset.c                               |   1 +
 test/dm/sound.c                               |   1 +
 test/dm/spmi.c                                |   1 +
 test/dm/syscon.c                              |   1 +
 test/dm/tee.c                                 |   1 +
 test/dm/test-fdt.c                            |   1 +
 test/dm/video.c                               |   1 +
 test/lib/lmb.c                                |   1 +
 test/unicode_ut.c                             |   1 +
 642 files changed, 1399 insertions(+), 387 deletions(-)
 create mode 100644 arch/sandbox/include/asm/malloc.h
 create mode 100644 include/dm/device_compat.h

-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 01/32] sandbox: Sort the help options
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 02/32] video: Support truetype fonts on a 32-bit display Simon Glass
                   ` (38 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

At present options are presented in essentially random order. It is easier
to browse them if they are sorted into alphabetical order. Adjust the
help function to handle this.

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

Changes in v2: None

 arch/sandbox/cpu/start.c | 46 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index fff9cbdd79..d3ce61856e 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -9,13 +9,45 @@
 #include <os.h>
 #include <cli.h>
 #include <malloc.h>
+#include <sort.h>
 #include <asm/getopt.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 #include <asm/state.h>
+#include <linux/ctype.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/* Compare two options so that they can be sorted into alphabetical order */
+static int h_compare_opt(const void *p1, const void *p2)
+{
+	const struct sandbox_cmdline_option *opt1 = p1;
+	const struct sandbox_cmdline_option *opt2 = p2;
+	const char *str1, *str2;
+	char flag1[2], flag2[2];
+
+	opt1 = *(struct sandbox_cmdline_option **)p1;
+	opt2 = *(struct sandbox_cmdline_option **)p2;
+	flag1[1] = '\0';
+	flag2[1] = '\0';
+
+	*flag1 = opt1->flag_short < 0x100 ? opt1->flag_short : '\0';
+	*flag2 = opt2->flag_short < 0x100 ? opt2->flag_short : '\0';
+
+	str1 = *flag1 ? flag1 : opt1->flag;
+	str2 = *flag2 ? flag2 : opt2->flag;
+
+	/*
+	 * Force lower-case flags to come before upper-case ones. We only
+	 * support upper-case for short flags.
+	 */
+	if (isalpha(*str1) && isalpha(*str2) &&
+	    tolower(*str1) == tolower(*str2))
+		return isupper(*str1) - isupper(*str2);
+
+	return strcasecmp(str1, str2);
+}
+
 int sandbox_early_getopt_check(void)
 {
 	struct sandbox_state *state = state_get_current();
@@ -23,6 +55,8 @@ int sandbox_early_getopt_check(void)
 	size_t num_options = __u_boot_sandbox_option_count();
 	size_t i;
 	int max_arg_len, max_noarg_len;
+	struct sandbox_cmdline_option **sorted_opt;
+	int size;
 
 	/* parse_err will be a string of the faulting option */
 	if (!state->parse_err)
@@ -45,8 +79,18 @@ int sandbox_early_getopt_check(void)
 		max_arg_len = max((int)strlen(sb_opt[i]->flag), max_arg_len);
 	max_noarg_len = max_arg_len + 7;
 
+	/* Sort the options */
+	size = sizeof(*sorted_opt) * num_options;
+	sorted_opt = malloc(size);
+	if (!sorted_opt) {
+		printf("No memory to sort options\n");
+		os_exit(1);
+	}
+	memcpy(sorted_opt, sb_opt, size);
+	qsort(sorted_opt, num_options, sizeof(*sorted_opt), h_compare_opt);
+
 	for (i = 0; i < num_options; ++i) {
-		struct sandbox_cmdline_option *opt = sb_opt[i];
+		struct sandbox_cmdline_option *opt = sorted_opt[i];
 
 		/* first output the short flag if it has one */
 		if (opt->flag_short >= 0x100)
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 02/32] video: Support truetype fonts on a 32-bit display
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
  2020-02-03 14:35 ` [PATCH v2 01/32] sandbox: Sort the help options Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 03/32] video: sandbox: Enable all colour depths Simon Glass
                   ` (37 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

At present only a 16bpp display is supported for Truetype fonts. Add
support for 32bpp also since this is quite common.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 drivers/video/console_truetype.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 30086600fb..0a725c5c15 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -286,6 +286,27 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 			}
 			break;
 		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			u32 *dst = (u32 *)line + xoff;
+			int i;
+
+			for (i = 0; i < width; i++) {
+				int val = *bits;
+				int out;
+
+				if (vid_priv->colour_bg)
+					val = 255 - val;
+				out = val | val << 8 | val << 16;
+				if (vid_priv->colour_fg)
+					*dst++ |= out;
+				else
+					*dst++ &= out;
+				bits++;
+			}
+			break;
+		}
 #endif
 		default:
 			free(data);
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 03/32] video: sandbox: Enable all colour depths
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
  2020-02-03 14:35 ` [PATCH v2 01/32] sandbox: Sort the help options Simon Glass
  2020-02-03 14:35 ` [PATCH v2 02/32] video: Support truetype fonts on a 32-bit display Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 04/32] mailbox: Rename free() to rfree() Simon Glass
                   ` (36 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

For sandbox we want to have the maximum possible build coverage, so enable
all colour depths for video.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 configs/sandbox64_defconfig        | 1 -
 configs/sandbox_defconfig          | 1 -
 configs/sandbox_flattree_defconfig | 1 -
 configs/sandbox_spl_defconfig      | 1 -
 drivers/video/Kconfig              | 4 +++-
 5 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 7b80033c3b..941b1fd2c7 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -189,7 +189,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
-CONFIG_VIDEO_BPP16=y
 CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index fc018bdd2c..5d4f8eb5e1 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -209,7 +209,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
-CONFIG_VIDEO_BPP16=y
 CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 2c90639ecb..0049da3d48 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -168,7 +168,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
-CONFIG_VIDEO_BPP16=y
 CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index b78115af61..f55692c2b5 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -188,7 +188,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
-CONFIG_VIDEO_BPP16=y
 CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 50ab3650ee..d7e62bea9c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -38,6 +38,7 @@ config BACKLIGHT_GPIO
 config VIDEO_BPP8
 	bool "Support 8-bit-per-pixel displays"
 	depends on DM_VIDEO
+	default y if SANDBOX || X86
 	help
 	  Support drawing text and bitmaps onto a 8-bit-per-pixel display.
 	  Enabling this will include code to support this display. Without
@@ -47,6 +48,7 @@ config VIDEO_BPP8
 config VIDEO_BPP16
 	bool "Support 16-bit-per-pixel displays"
 	depends on DM_VIDEO
+	default y if SANDBOX || X86
 	help
 	  Support drawing text and bitmaps onto a 16-bit-per-pixel display.
 	  Enabling this will include code to support this display. Without
@@ -56,7 +58,7 @@ config VIDEO_BPP16
 config VIDEO_BPP32
 	bool "Support 32-bit-per-pixel displays"
 	depends on DM_VIDEO
-	default y if X86
+	default y if SANDBOX || X86
 	help
 	  Support drawing text and bitmaps onto a 32-bit-per-pixel display.
 	  Enabling this will include code to support this display. Without
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 04/32] mailbox: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (2 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 03/32] video: sandbox: Enable all colour depths Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 05/32] power-domain: " Simon Glass
                   ` (35 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2: None

 drivers/mailbox/k3-sec-proxy.c   | 2 +-
 drivers/mailbox/mailbox-uclass.c | 4 ++--
 drivers/mailbox/sandbox-mbox.c   | 2 +-
 drivers/mailbox/stm32-ipcc.c     | 2 +-
 drivers/mailbox/tegra-hsp.c      | 2 +-
 include/mailbox-uclass.h         | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c
index b07b56cf97..1194c6f029 100644
--- a/drivers/mailbox/k3-sec-proxy.c
+++ b/drivers/mailbox/k3-sec-proxy.c
@@ -291,7 +291,7 @@ static int k3_sec_proxy_recv(struct mbox_chan *chan, void *data)
 struct mbox_ops k3_sec_proxy_mbox_ops = {
 	.of_xlate = k3_sec_proxy_of_xlate,
 	.request = k3_sec_proxy_request,
-	.free = k3_sec_proxy_free,
+	.rfree = k3_sec_proxy_free,
 	.send = k3_sec_proxy_send,
 	.recv = k3_sec_proxy_recv,
 };
diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index 5968c9b7eb..a6d2d1f5b8 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -105,8 +105,8 @@ int mbox_free(struct mbox_chan *chan)
 
 	debug("%s(chan=%p)\n", __func__, chan);
 
-	if (ops->free)
-		return ops->free(chan);
+	if (ops->rfree)
+		return ops->rfree(chan);
 
 	return 0;
 }
diff --git a/drivers/mailbox/sandbox-mbox.c b/drivers/mailbox/sandbox-mbox.c
index bc917b3de4..442ca633a1 100644
--- a/drivers/mailbox/sandbox-mbox.c
+++ b/drivers/mailbox/sandbox-mbox.c
@@ -87,7 +87,7 @@ static const struct udevice_id sandbox_mbox_ids[] = {
 
 struct mbox_ops sandbox_mbox_mbox_ops = {
 	.request = sandbox_mbox_request,
-	.free = sandbox_mbox_free,
+	.rfree = sandbox_mbox_free,
 	.send = sandbox_mbox_send,
 	.recv = sandbox_mbox_recv,
 };
diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
index c3df9678a7..d4035a85f2 100644
--- a/drivers/mailbox/stm32-ipcc.c
+++ b/drivers/mailbox/stm32-ipcc.c
@@ -152,7 +152,7 @@ static const struct udevice_id stm32_ipcc_ids[] = {
 
 struct mbox_ops stm32_ipcc_mbox_ops = {
 	.request = stm32_ipcc_request,
-	.free = stm32_ipcc_free,
+	.rfree = stm32_ipcc_free,
 	.send = stm32_ipcc_send,
 	.recv = stm32_ipcc_recv,
 };
diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index 9bee886561..c463e6a2be 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -175,7 +175,7 @@ static const struct udevice_id tegra_hsp_ids[] = {
 struct mbox_ops tegra_hsp_mbox_ops = {
 	.of_xlate = tegra_hsp_of_xlate,
 	.request = tegra_hsp_request,
-	.free = tegra_hsp_free,
+	.rfree = tegra_hsp_free,
 	.send = tegra_hsp_send,
 	.recv = tegra_hsp_recv,
 };
diff --git a/include/mailbox-uclass.h b/include/mailbox-uclass.h
index e0618aad97..3c60c76506 100644
--- a/include/mailbox-uclass.h
+++ b/include/mailbox-uclass.h
@@ -49,14 +49,14 @@ struct mbox_ops {
 	 */
 	int (*request)(struct mbox_chan *chan);
 	/**
-	 * free - Free a previously requested channel.
+	 * rfree - Free a previously requested channel.
 	 *
 	 * This is the implementation of the client mbox_free() API.
 	 *
 	 * @chan:	The channel to free.
 	 * @return 0 if OK, or a negative error code.
 	 */
-	int (*free)(struct mbox_chan *chan);
+	int (*rfree)(struct mbox_chan *chan);
 	/**
 	* send - Send a message over a mailbox channel
 	*
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 05/32] power-domain: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (3 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 04/32] mailbox: Rename free() to rfree() Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 06/32] reset: " Simon Glass
                   ` (34 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 drivers/power/domain/bcm6328-power-domain.c     | 2 +-
 drivers/power/domain/imx8-power-domain-legacy.c | 2 +-
 drivers/power/domain/imx8-power-domain.c        | 2 +-
 drivers/power/domain/imx8m-power-domain.c       | 2 +-
 drivers/power/domain/meson-ee-pwrc.c            | 2 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c        | 2 +-
 drivers/power/domain/mtk-power-domain.c         | 2 +-
 drivers/power/domain/power-domain-uclass.c      | 2 +-
 drivers/power/domain/sandbox-power-domain.c     | 2 +-
 drivers/power/domain/tegra186-power-domain.c    | 2 +-
 drivers/power/domain/ti-sci-power-domain.c      | 2 +-
 include/power-domain-uclass.h                   | 4 ++--
 12 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/power/domain/bcm6328-power-domain.c b/drivers/power/domain/bcm6328-power-domain.c
index a90b2c83df..425451e4cd 100644
--- a/drivers/power/domain/bcm6328-power-domain.c
+++ b/drivers/power/domain/bcm6328-power-domain.c
@@ -62,7 +62,7 @@ static const struct udevice_id bcm6328_power_domain_ids[] = {
 };
 
 struct power_domain_ops bcm6328_power_domain_ops = {
-	.free = bcm6328_power_domain_free,
+	.rfree = bcm6328_power_domain_free,
 	.off = bcm6328_power_domain_off,
 	.on = bcm6328_power_domain_on,
 	.request = bcm6328_power_domain_request,
diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c
index d51dbaa6c0..74fcb05c15 100644
--- a/drivers/power/domain/imx8-power-domain-legacy.c
+++ b/drivers/power/domain/imx8-power-domain-legacy.c
@@ -296,7 +296,7 @@ static const struct udevice_id imx8_power_domain_ids[] = {
 
 struct power_domain_ops imx8_power_domain_ops = {
 	.request = imx8_power_domain_request,
-	.free = imx8_power_domain_free,
+	.rfree = imx8_power_domain_free,
 	.on = imx8_power_domain_on,
 	.off = imx8_power_domain_off,
 	.of_xlate = imx8_power_domain_of_xlate,
diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain.c
index aa768365b4..8e328f02c2 100644
--- a/drivers/power/domain/imx8-power-domain.c
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -73,7 +73,7 @@ static const struct udevice_id imx8_power_domain_ids[] = {
 
 struct power_domain_ops imx8_power_domain_ops_v2 = {
 	.request = imx8_power_domain_request,
-	.free = imx8_power_domain_free,
+	.rfree = imx8_power_domain_free,
 	.on = imx8_power_domain_on,
 	.off = imx8_power_domain_off,
 };
diff --git a/drivers/power/domain/imx8m-power-domain.c b/drivers/power/domain/imx8m-power-domain.c
index 40ece9ee3f..fbfd17718b 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -121,7 +121,7 @@ static const struct udevice_id imx8m_power_domain_ids[] = {
 
 struct power_domain_ops imx8m_power_domain_ops = {
 	.request = imx8m_power_domain_request,
-	.free = imx8m_power_domain_free,
+	.rfree = imx8m_power_domain_free,
 	.on = imx8m_power_domain_on,
 	.off = imx8m_power_domain_off,
 	.of_xlate = imx8m_power_domain_of_xlate,
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index 21d4c9d4dd..7f5d13e872 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -352,7 +352,7 @@ static int meson_ee_pwrc_of_xlate(struct power_domain *power_domain,
 }
 
 struct power_domain_ops meson_ee_pwrc_ops = {
-	.free = meson_ee_pwrc_free,
+	.rfree = meson_ee_pwrc_free,
 	.off = meson_ee_pwrc_off,
 	.on = meson_ee_pwrc_on,
 	.request = meson_ee_pwrc_request,
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index f44e33bacb..bd69aea8dd 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -269,7 +269,7 @@ static int meson_pwrc_vpu_of_xlate(struct power_domain *power_domain,
 }
 
 struct power_domain_ops meson_gx_pwrc_vpu_ops = {
-	.free = meson_pwrc_vpu_free,
+	.rfree = meson_pwrc_vpu_free,
 	.off = meson_pwrc_vpu_off,
 	.on = meson_pwrc_vpu_on,
 	.request = meson_pwrc_vpu_request,
diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index 0bf8a16447..6ea4fe9003 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -396,7 +396,7 @@ static const struct udevice_id mtk_power_domain_ids[] = {
 };
 
 struct power_domain_ops mtk_power_domain_ops = {
-	.free = scpsys_power_free,
+	.rfree = scpsys_power_free,
 	.off = scpsys_power_off,
 	.on = scpsys_power_on,
 	.request = scpsys_power_request,
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 80df5aff50..be0a8026f6 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -87,7 +87,7 @@ int power_domain_free(struct power_domain *power_domain)
 
 	debug("%s(power_domain=%p)\n", __func__, power_domain);
 
-	return ops->free(power_domain);
+	return ops->rfree(power_domain);
 }
 
 int power_domain_on(struct power_domain *power_domain)
diff --git a/drivers/power/domain/sandbox-power-domain.c b/drivers/power/domain/sandbox-power-domain.c
index 74db2eba7e..a5ae235d53 100644
--- a/drivers/power/domain/sandbox-power-domain.c
+++ b/drivers/power/domain/sandbox-power-domain.c
@@ -75,7 +75,7 @@ static const struct udevice_id sandbox_power_domain_ids[] = {
 
 struct power_domain_ops sandbox_power_domain_ops = {
 	.request = sandbox_power_domain_request,
-	.free = sandbox_power_domain_free,
+	.rfree = sandbox_power_domain_free,
 	.on = sandbox_power_domain_on,
 	.off = sandbox_power_domain_off,
 };
diff --git a/drivers/power/domain/tegra186-power-domain.c b/drivers/power/domain/tegra186-power-domain.c
index f344558227..d2a25ca333 100644
--- a/drivers/power/domain/tegra186-power-domain.c
+++ b/drivers/power/domain/tegra186-power-domain.c
@@ -71,7 +71,7 @@ static int tegra186_power_domain_off(struct power_domain *power_domain)
 
 struct power_domain_ops tegra186_power_domain_ops = {
 	.request = tegra186_power_domain_request,
-	.free = tegra186_power_domain_free,
+	.rfree = tegra186_power_domain_free,
 	.on = tegra186_power_domain_on,
 	.off = tegra186_power_domain_off,
 };
diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c
index 4c4351d2d9..b59af2b13b 100644
--- a/drivers/power/domain/ti-sci-power-domain.c
+++ b/drivers/power/domain/ti-sci-power-domain.c
@@ -120,7 +120,7 @@ static const struct udevice_id ti_sci_power_domain_of_match[] = {
 
 static struct power_domain_ops ti_sci_power_domain_ops = {
 	.request = ti_sci_power_domain_request,
-	.free = ti_sci_power_domain_free,
+	.rfree = ti_sci_power_domain_free,
 	.on = ti_sci_power_domain_on,
 	.off = ti_sci_power_domain_off,
 	.of_xlate = ti_sci_power_domain_of_xlate,
diff --git a/include/power-domain-uclass.h b/include/power-domain-uclass.h
index bd9906b2e7..acf749b38e 100644
--- a/include/power-domain-uclass.h
+++ b/include/power-domain-uclass.h
@@ -54,14 +54,14 @@ struct power_domain_ops {
 	 */
 	int (*request)(struct power_domain *power_domain);
 	/**
-	 * free - Free a previously requested power domain.
+	 * rfree - Free a previously requested power domain.
 	 *
 	 * This is the implementation of the client power_domain_free() API.
 	 *
 	 * @power_domain:	The power domain to free.
 	 * @return 0 if OK, or a negative error code.
 	 */
-	int (*free)(struct power_domain *power_domain);
+	int (*rfree)(struct power_domain *power_domain);
 	/**
 	 * on - Power on a power domain.
 	 *
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 06/32] reset: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (4 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 05/32] power-domain: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 07/32] gpio: " Simon Glass
                   ` (33 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2: None

 drivers/reset/reset-bcm6345.c   | 2 +-
 drivers/reset/reset-hisilicon.c | 2 +-
 drivers/reset/reset-hsdk.c      | 2 +-
 drivers/reset/reset-imx7.c      | 2 +-
 drivers/reset/reset-mediatek.c  | 2 +-
 drivers/reset/reset-meson.c     | 2 +-
 drivers/reset/reset-mtmips.c    | 2 +-
 drivers/reset/reset-rockchip.c  | 2 +-
 drivers/reset/reset-socfpga.c   | 2 +-
 drivers/reset/reset-sunxi.c     | 2 +-
 drivers/reset/reset-ti-sci.c    | 2 +-
 drivers/reset/reset-uclass.c    | 2 +-
 drivers/reset/reset-uniphier.c  | 2 +-
 drivers/reset/sandbox-reset.c   | 2 +-
 drivers/reset/sti-reset.c       | 2 +-
 drivers/reset/stm32-reset.c     | 2 +-
 drivers/reset/tegra-car-reset.c | 2 +-
 drivers/reset/tegra186-reset.c  | 2 +-
 include/reset-uclass.h          | 4 ++--
 19 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/reset/reset-bcm6345.c b/drivers/reset/reset-bcm6345.c
index 753c1108a9..bbaaea9bb3 100644
--- a/drivers/reset/reset-bcm6345.c
+++ b/drivers/reset/reset-bcm6345.c
@@ -52,7 +52,7 @@ static int bcm6345_reset_request(struct reset_ctl *rst)
 }
 
 struct reset_ops bcm6345_reset_reset_ops = {
-	.free = bcm6345_reset_free,
+	.rfree = bcm6345_reset_free,
 	.request = bcm6345_reset_request,
 	.rst_assert = bcm6345_reset_assert,
 	.rst_deassert = bcm6345_reset_deassert,
diff --git a/drivers/reset/reset-hisilicon.c b/drivers/reset/reset-hisilicon.c
index a9f052a0c5..d449e3d25e 100644
--- a/drivers/reset/reset-hisilicon.c
+++ b/drivers/reset/reset-hisilicon.c
@@ -72,7 +72,7 @@ static int hisi_reset_of_xlate(struct reset_ctl *rst,
 static const struct reset_ops hisi_reset_reset_ops = {
 	.of_xlate = hisi_reset_of_xlate,
 	.request = hisi_reset_request,
-	.free = hisi_reset_free,
+	.rfree = hisi_reset_free,
 	.rst_assert = hisi_reset_assert,
 	.rst_deassert = hisi_reset_deassert,
 };
diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
index 213d6c87be..f9a432a7a2 100644
--- a/drivers/reset/reset-hsdk.c
+++ b/drivers/reset/reset-hsdk.c
@@ -81,7 +81,7 @@ static int hsdk_reset_noop(struct reset_ctl *rst_ctl)
 
 static const struct reset_ops hsdk_reset_ops = {
 	.request	= hsdk_reset_noop,
-	.free		= hsdk_reset_noop,
+	.rfree		= hsdk_reset_noop,
 	.rst_assert	= hsdk_reset_noop,
 	.rst_deassert	= hsdk_reset_reset,
 };
diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c
index f2ca5cf801..a2bad65a3b 100644
--- a/drivers/reset/reset-imx7.c
+++ b/drivers/reset/reset-imx7.c
@@ -272,7 +272,7 @@ static int imx7_reset_request(struct reset_ctl *rst)
 
 static const struct reset_ops imx7_reset_reset_ops = {
 	.request = imx7_reset_request,
-	.free = imx7_reset_free,
+	.rfree = imx7_reset_free,
 	.rst_assert = imx7_reset_assert,
 	.rst_deassert = imx7_reset_deassert,
 };
diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c
index e3614e6e2a..cfbf2af863 100644
--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -55,7 +55,7 @@ static int mediatek_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops mediatek_reset_ops = {
 	.request = mediatek_reset_request,
-	.free = mediatek_reset_free,
+	.rfree = mediatek_reset_free,
 	.rst_assert = mediatek_reset_assert,
 	.rst_deassert = mediatek_reset_deassert,
 };
diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c
index 31aa4d41e8..9026e034c3 100644
--- a/drivers/reset/reset-meson.c
+++ b/drivers/reset/reset-meson.c
@@ -62,7 +62,7 @@ static int meson_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops meson_reset_ops = {
 	.request = meson_reset_request,
-	.free = meson_reset_free,
+	.rfree = meson_reset_free,
 	.rst_assert = meson_reset_assert,
 	.rst_deassert = meson_reset_deassert,
 };
diff --git a/drivers/reset/reset-mtmips.c b/drivers/reset/reset-mtmips.c
index 59734565d7..71254a93dd 100644
--- a/drivers/reset/reset-mtmips.c
+++ b/drivers/reset/reset-mtmips.c
@@ -45,7 +45,7 @@ static int mtmips_reset_deassert(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops mtmips_reset_ops = {
 	.request	= mtmips_reset_request,
-	.free		= mtmips_reset_free,
+	.rfree		= mtmips_reset_free,
 	.rst_assert	= mtmips_reset_assert,
 	.rst_deassert	= mtmips_reset_deassert,
 };
diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c
index 3871fc00d0..4fb9571b18 100644
--- a/drivers/reset/reset-rockchip.c
+++ b/drivers/reset/reset-rockchip.c
@@ -76,7 +76,7 @@ static int rockchip_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops rockchip_reset_ops = {
 	.request = rockchip_reset_request,
-	.free = rockchip_reset_free,
+	.rfree = rockchip_reset_free,
 	.rst_assert = rockchip_reset_assert,
 	.rst_deassert = rockchip_reset_deassert,
 };
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 93ec9cfdb6..98524eb2b7 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -101,7 +101,7 @@ static int socfpga_reset_free(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops socfpga_reset_ops = {
 	.request = socfpga_reset_request,
-	.free = socfpga_reset_free,
+	.rfree = socfpga_reset_free,
 	.rst_assert = socfpga_reset_assert,
 	.rst_deassert = socfpga_reset_deassert,
 };
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 364dc52fb7..1c717b20c3 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -81,7 +81,7 @@ static int sunxi_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops sunxi_reset_ops = {
 	.request = sunxi_reset_request,
-	.free = sunxi_reset_free,
+	.rfree = sunxi_reset_free,
 	.rst_assert = sunxi_reset_assert,
 	.rst_deassert = sunxi_reset_deassert,
 };
diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c
index c8a76dfb04..7b6f736f5e 100644
--- a/drivers/reset/reset-ti-sci.c
+++ b/drivers/reset/reset-ti-sci.c
@@ -190,7 +190,7 @@ static const struct udevice_id ti_sci_reset_of_match[] = {
 static struct reset_ops ti_sci_reset_ops = {
 	.of_xlate = ti_sci_reset_of_xlate,
 	.request = ti_sci_reset_request,
-	.free = ti_sci_reset_free,
+	.rfree = ti_sci_reset_free,
 	.rst_assert = ti_sci_reset_assert,
 	.rst_deassert = ti_sci_reset_deassert,
 	.rst_status = ti_sci_reset_status,
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index ee1a423ffb..bf1cba4124 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -164,7 +164,7 @@ int reset_free(struct reset_ctl *reset_ctl)
 
 	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-	return ops->free(reset_ctl);
+	return ops->rfree(reset_ctl);
 }
 
 int reset_assert(struct reset_ctl *reset_ctl)
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 39d684be4a..97f7b0ed5f 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -234,7 +234,7 @@ static int uniphier_reset_deassert(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops uniphier_reset_ops = {
 	.request = uniphier_reset_request,
-	.free = uniphier_reset_free,
+	.rfree = uniphier_reset_free,
 	.rst_assert = uniphier_reset_assert,
 	.rst_deassert = uniphier_reset_deassert,
 };
diff --git a/drivers/reset/sandbox-reset.c b/drivers/reset/sandbox-reset.c
index 40f2654d8e..c03fce3531 100644
--- a/drivers/reset/sandbox-reset.c
+++ b/drivers/reset/sandbox-reset.c
@@ -79,7 +79,7 @@ static const struct udevice_id sandbox_reset_ids[] = {
 
 struct reset_ops sandbox_reset_reset_ops = {
 	.request = sandbox_reset_request,
-	.free = sandbox_reset_free,
+	.rfree = sandbox_reset_free,
 	.rst_assert = sandbox_reset_assert,
 	.rst_deassert = sandbox_reset_deassert,
 };
diff --git a/drivers/reset/sti-reset.c b/drivers/reset/sti-reset.c
index d8cc485ce6..614da9da59 100644
--- a/drivers/reset/sti-reset.c
+++ b/drivers/reset/sti-reset.c
@@ -298,7 +298,7 @@ static int sti_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops sti_reset_ops = {
 	.request = sti_reset_request,
-	.free = sti_reset_free,
+	.rfree = sti_reset_free,
 	.rst_assert = sti_reset_assert,
 	.rst_deassert = sti_reset_deassert,
 };
diff --git a/drivers/reset/stm32-reset.c b/drivers/reset/stm32-reset.c
index 16d3dba749..4d7745abce 100644
--- a/drivers/reset/stm32-reset.c
+++ b/drivers/reset/stm32-reset.c
@@ -64,7 +64,7 @@ static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops stm32_reset_ops = {
 	.request	= stm32_reset_request,
-	.free		= stm32_reset_free,
+	.rfree		= stm32_reset_free,
 	.rst_assert	= stm32_reset_assert,
 	.rst_deassert	= stm32_reset_deassert,
 };
diff --git a/drivers/reset/tegra-car-reset.c b/drivers/reset/tegra-car-reset.c
index 25947822f1..886ea04e2e 100644
--- a/drivers/reset/tegra-car-reset.c
+++ b/drivers/reset/tegra-car-reset.c
@@ -51,7 +51,7 @@ static int tegra_car_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops tegra_car_reset_ops = {
 	.request = tegra_car_reset_request,
-	.free = tegra_car_reset_free,
+	.rfree = tegra_car_reset_free,
 	.rst_assert = tegra_car_reset_assert,
 	.rst_deassert = tegra_car_reset_deassert,
 };
diff --git a/drivers/reset/tegra186-reset.c b/drivers/reset/tegra186-reset.c
index 9927c063c3..84ed77b96f 100644
--- a/drivers/reset/tegra186-reset.c
+++ b/drivers/reset/tegra186-reset.c
@@ -60,7 +60,7 @@ static int tegra186_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops tegra186_reset_ops = {
 	.request = tegra186_reset_request,
-	.free = tegra186_reset_free,
+	.rfree = tegra186_reset_free,
 	.rst_assert = tegra186_reset_assert,
 	.rst_deassert = tegra186_reset_deassert,
 };
diff --git a/include/reset-uclass.h b/include/reset-uclass.h
index 7b5cc3cb3b..9a0696dd1e 100644
--- a/include/reset-uclass.h
+++ b/include/reset-uclass.h
@@ -51,14 +51,14 @@ struct reset_ops {
 	 */
 	int (*request)(struct reset_ctl *reset_ctl);
 	/**
-	 * free - Free a previously requested reset control.
+	 * rfree - Free a previously requested reset control.
 	 *
 	 * This is the implementation of the client reset_free() API.
 	 *
 	 * @reset_ctl:	The reset control to free.
 	 * @return 0 if OK, or a negative error code.
 	 */
-	int (*free)(struct reset_ctl *reset_ctl);
+	int (*rfree)(struct reset_ctl *reset_ctl);
 	/**
 	 * rst_assert - Assert a reset signal.
 	 *
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 07/32] gpio: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (5 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 06/32] reset: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 08/32] clk: " Simon Glass
                   ` (32 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2: None

 drivers/gpio/gpio-rcar.c   | 2 +-
 drivers/gpio/gpio-uclass.c | 4 ++--
 include/asm-generic/gpio.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 594e0a470a..a8c5b7f879 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -128,7 +128,7 @@ static int rcar_gpio_free(struct udevice *dev, unsigned offset)
 
 static const struct dm_gpio_ops rcar_gpio_ops = {
 	.request		= rcar_gpio_request,
-	.free			= rcar_gpio_free,
+	.rfree			= rcar_gpio_free,
 	.direction_input	= rcar_gpio_direction_input,
 	.direction_output	= rcar_gpio_direction_output,
 	.get_value		= rcar_gpio_get_value,
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 90fbed455b..4c155fceb5 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -364,8 +364,8 @@ int _dm_gpio_free(struct udevice *dev, uint offset)
 	uc_priv = dev_get_uclass_priv(dev);
 	if (!uc_priv->name[offset])
 		return -ENXIO;
-	if (gpio_get_ops(dev)->free) {
-		ret = gpio_get_ops(dev)->free(dev, offset);
+	if (gpio_get_ops(dev)->rfree) {
+		ret = gpio_get_ops(dev)->rfree(dev, offset);
 		if (ret)
 			return ret;
 	}
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d6cf18744f..05777e6afe 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -248,7 +248,7 @@ int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
  */
 struct dm_gpio_ops {
 	int (*request)(struct udevice *dev, unsigned offset, const char *label);
-	int (*free)(struct udevice *dev, unsigned offset);
+	int (*rfree)(struct udevice *dev, unsigned int offset);
 	int (*direction_input)(struct udevice *dev, unsigned offset);
 	int (*direction_output)(struct udevice *dev, unsigned offset,
 				int value);
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 08/32] clk: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (6 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 07/32] gpio: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 09/32] dma: " Simon Glass
                   ` (31 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2: None

 drivers/clk/clk-ti-sci.c          | 2 +-
 drivers/clk/clk-uclass.c          | 4 ++--
 drivers/clk/clk_sandbox.c         | 2 +-
 drivers/clk/tegra/tegra-car-clk.c | 2 +-
 include/clk-uclass.h              | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-ti-sci.c b/drivers/clk/clk-ti-sci.c
index ed1facbbcd..8212435ba8 100644
--- a/drivers/clk/clk-ti-sci.c
+++ b/drivers/clk/clk-ti-sci.c
@@ -203,7 +203,7 @@ static const struct udevice_id ti_sci_clk_of_match[] = {
 static struct clk_ops ti_sci_clk_ops = {
 	.of_xlate = ti_sci_clk_of_xlate,
 	.request = ti_sci_clk_request,
-	.free = ti_sci_clk_free,
+	.rfree = ti_sci_clk_free,
 	.get_rate = ti_sci_clk_get_rate,
 	.set_rate = ti_sci_clk_set_rate,
 	.set_parent = ti_sci_clk_set_parent,
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 0df38bd06a..49fa60eb7c 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -423,10 +423,10 @@ int clk_free(struct clk *clk)
 		return 0;
 	ops = clk_dev_ops(clk->dev);
 
-	if (!ops->free)
+	if (!ops->rfree)
 		return 0;
 
-	return ops->free(clk);
+	return ops->rfree(clk);
 }
 
 ulong clk_get_rate(struct clk *clk)
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index de6b2f7c82..cc084b0644 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -107,7 +107,7 @@ static struct clk_ops sandbox_clk_ops = {
 	.enable		= sandbox_clk_enable,
 	.disable	= sandbox_clk_disable,
 	.request	= sandbox_clk_request,
-	.free		= sandbox_clk_free,
+	.rfree		= sandbox_clk_free,
 };
 
 static int sandbox_clk_probe(struct udevice *dev)
diff --git a/drivers/clk/tegra/tegra-car-clk.c b/drivers/clk/tegra/tegra-car-clk.c
index 98be7602b3..07e8734b3a 100644
--- a/drivers/clk/tegra/tegra-car-clk.c
+++ b/drivers/clk/tegra/tegra-car-clk.c
@@ -80,7 +80,7 @@ static int tegra_car_clk_disable(struct clk *clk)
 
 static struct clk_ops tegra_car_clk_ops = {
 	.request = tegra_car_clk_request,
-	.free = tegra_car_clk_free,
+	.rfree = tegra_car_clk_free,
 	.get_rate = tegra_car_clk_get_rate,
 	.set_rate = tegra_car_clk_set_rate,
 	.enable = tegra_car_clk_enable,
diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index e76d98e2f6..dac42dab36 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -53,14 +53,14 @@ struct clk_ops {
 	 */
 	int (*request)(struct clk *clock);
 	/**
-	 * free - Free a previously requested clock.
+	 * rfree - Free a previously requested clock.
 	 *
 	 * This is the implementation of the client clk_free() API.
 	 *
 	 * @clock:	The clock to free.
 	 * @return 0 if OK, or a negative error code.
 	 */
-	int (*free)(struct clk *clock);
+	int (*rfree)(struct clk *clock);
 	/**
 	 * get_rate() - Get current clock rate.
 	 *
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 09/32] dma: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (7 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 08/32] clk: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 10/32] mtd: " Simon Glass
                   ` (30 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2:
- Update the name of the implementing callback function too

 drivers/dma/dma-uclass.c       | 4 ++--
 drivers/dma/sandbox-dma-test.c | 4 ++--
 drivers/dma/ti/k3-udma.c       | 4 ++--
 include/dma-uclass.h           | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index 5598bca21c..a0159d7888 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -122,10 +122,10 @@ int dma_free(struct dma *dma)
 
 	debug("%s(dma=%p)\n", __func__, dma);
 
-	if (!ops->free)
+	if (!ops->rfree)
 		return 0;
 
-	return ops->free(dma);
+	return ops->rfree(dma);
 }
 
 int dma_enable(struct dma *dma)
diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c
index 8fcef1863e..d009bb2168 100644
--- a/drivers/dma/sandbox-dma-test.c
+++ b/drivers/dma/sandbox-dma-test.c
@@ -88,7 +88,7 @@ static int sandbox_dma_request(struct dma *dma)
 	return 0;
 }
 
-static int sandbox_dma_free(struct dma *dma)
+static int sandbox_dma_rfree(struct dma *dma)
 {
 	struct sandbox_dma_dev *ud = dev_get_priv(dma->dev);
 	struct sandbox_dma_chan *uc;
@@ -229,7 +229,7 @@ static const struct dma_ops sandbox_dma_ops = {
 	.transfer	= sandbox_dma_transfer,
 	.of_xlate	= sandbox_dma_of_xlate,
 	.request	= sandbox_dma_request,
-	.free		= sandbox_dma_free,
+	.rfree		= sandbox_dma_rfree,
 	.enable		= sandbox_dma_enable,
 	.disable	= sandbox_dma_disable,
 	.send		= sandbox_dma_send,
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 95f6b5a93a..5820c8270b 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1551,7 +1551,7 @@ static int udma_request(struct dma *dma)
 	return 0;
 }
 
-static int udma_free(struct dma *dma)
+static int udma_rfree(struct dma *dma)
 {
 	struct udma_dev *ud = dev_get_priv(dma->dev);
 	struct udma_chan *uc;
@@ -1846,7 +1846,7 @@ static const struct dma_ops udma_ops = {
 	.transfer	= udma_transfer,
 	.of_xlate	= udma_of_xlate,
 	.request	= udma_request,
-	.free		= udma_free,
+	.rfree		= udma_rfree,
 	.enable		= udma_enable,
 	.disable	= udma_disable,
 	.send		= udma_send,
diff --git a/include/dma-uclass.h b/include/dma-uclass.h
index a1d9d26ac5..340437acc1 100644
--- a/include/dma-uclass.h
+++ b/include/dma-uclass.h
@@ -58,14 +58,14 @@ struct dma_ops {
 	 */
 	int (*request)(struct dma *dma);
 	/**
-	 * free - Free a previously requested dma.
+	 * rfree - Free a previously requested dma.
 	 *
 	 * This is the implementation of the client dma_free() API.
 	 *
 	 * @dma: The DMA to free.
 	 * @return 0 if OK, or a negative error code.
 	 */
-	int (*free)(struct dma *dma);
+	int (*rfree)(struct dma *dma);
 	/**
 	 * enable() - Enable a DMA Channel.
 	 *
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 10/32] mtd: Rename free() to rfree()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (8 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 09/32] dma: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 11/32] sandbox: Rename 'free' variable Simon Glass
                   ` (29 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This function name conflicts with our desire to #define free() to
something else on sandbox. Since it deals with resources, rename it to
rfree().

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

Changes in v2: None

 drivers/mtd/mtdcore.c             | 4 ++--
 drivers/mtd/nand/raw/denali.c     | 2 +-
 drivers/mtd/nand/spi/core.c       | 2 +-
 drivers/mtd/nand/spi/gigadevice.c | 2 +-
 drivers/mtd/nand/spi/macronix.c   | 2 +-
 drivers/mtd/nand/spi/micron.c     | 2 +-
 drivers/mtd/nand/spi/winbond.c    | 2 +-
 include/linux/mtd/mtd.h           | 4 ++--
 8 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index dd04d676d5..838c288318 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1179,10 +1179,10 @@ int mtd_ooblayout_free(struct mtd_info *mtd, int section,
 	if (!mtd || section < 0)
 		return -EINVAL;
 
-	if (!mtd->ooblayout || !mtd->ooblayout->free)
+	if (!mtd->ooblayout || !mtd->ooblayout->rfree)
 		return -ENOTSUPP;
 
-	return mtd->ooblayout->free(mtd, section, oobfree);
+	return mtd->ooblayout->rfree(mtd, section, oobfree);
 }
 EXPORT_SYMBOL_GPL(mtd_ooblayout_free);
 
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index be1b3627ad..b5a98f52f8 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -1156,7 +1156,7 @@ static int denali_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops denali_ooblayout_ops = {
 	.ecc = denali_ooblayout_ecc,
-	.free = denali_ooblayout_free,
+	.rfree = denali_ooblayout_free,
 };
 
 static int denali_multidev_fixup(struct denali_nand_info *denali)
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index cb8ffa3fa9..fba8cc056a 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1021,7 +1021,7 @@ static int spinand_noecc_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops spinand_noecc_ooblayout = {
 	.ecc = spinand_noecc_ooblayout_ecc,
-	.free = spinand_noecc_ooblayout_free,
+	.rfree = spinand_noecc_ooblayout_free,
 };
 
 static int spinand_init(struct spinand_device *spinand)
diff --git a/drivers/mtd/nand/spi/gigadevice.c b/drivers/mtd/nand/spi/gigadevice.c
index 3681c5eed9..e329c3cfc0 100644
--- a/drivers/mtd/nand/spi/gigadevice.c
+++ b/drivers/mtd/nand/spi/gigadevice.c
@@ -103,7 +103,7 @@ static int gd5fxgq4xexxg_ecc_get_status(struct spinand_device *spinand,
 
 static const struct mtd_ooblayout_ops gd5fxgq4xexxg_ooblayout = {
 	.ecc = gd5fxgq4xexxg_ooblayout_ecc,
-	.free = gd5fxgq4xexxg_ooblayout_free,
+	.rfree = gd5fxgq4xexxg_ooblayout_free,
 };
 
 static const struct spinand_info gigadevice_spinand_table[] = {
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 662c561e50..1119677f6f 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -47,7 +47,7 @@ static int mx35lfxge4ab_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = {
 	.ecc = mx35lfxge4ab_ooblayout_ecc,
-	.free = mx35lfxge4ab_ooblayout_free,
+	.rfree = mx35lfxge4ab_ooblayout_free,
 };
 
 static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 83951c5d0f..9c24542f96 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -63,7 +63,7 @@ static int mt29f2g01abagd_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops mt29f2g01abagd_ooblayout = {
 	.ecc = mt29f2g01abagd_ooblayout_ecc,
-	.free = mt29f2g01abagd_ooblayout_free,
+	.rfree = mt29f2g01abagd_ooblayout_free,
 };
 
 static int mt29f2g01abagd_ecc_get_status(struct spinand_device *spinand,
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 6ba8bc5c7b..de9352e48f 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -59,7 +59,7 @@ static int w25m02gv_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops w25m02gv_ooblayout = {
 	.ecc = w25m02gv_ooblayout_ecc,
-	.free = w25m02gv_ooblayout_free,
+	.rfree = w25m02gv_ooblayout_free,
 };
 
 static int w25m02gv_select_target(struct spinand_device *spinand,
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ceffd994de..1b9151714c 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -129,8 +129,8 @@ struct mtd_oob_region {
 struct mtd_ooblayout_ops {
 	int (*ecc)(struct mtd_info *mtd, int section,
 		   struct mtd_oob_region *oobecc);
-	int (*free)(struct mtd_info *mtd, int section,
-		    struct mtd_oob_region *oobfree);
+	int (*rfree)(struct mtd_info *mtd, int section,
+		     struct mtd_oob_region *oobfree);
 };
 
 /*
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 11/32] sandbox: Rename 'free' variable
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (9 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 10/32] mtd: " Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 12/32] sandbox: Use a prefix for all allocation functions Simon Glass
                   ` (28 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This name conflicts with our desire to #define free() to something else on
sandbox. Rename it.

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

Changes in v2: None

 arch/sandbox/cpu/state.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index cd46e000f5..ef2e63f37a 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -16,14 +16,14 @@ static struct sandbox_state *state;	/* Pointer to current state record */
 static int state_ensure_space(int extra_size)
 {
 	void *blob = state->state_fdt;
-	int used, size, free;
+	int used, size, free_bytes;
 	void *buf;
 	int ret;
 
 	used = fdt_off_dt_strings(blob) + fdt_size_dt_strings(blob);
 	size = fdt_totalsize(blob);
-	free = size - used;
-	if (free > extra_size)
+	free_bytes = size - used;
+	if (free_bytes > extra_size)
 		return 0;
 
 	size = used + extra_size;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 12/32] sandbox: Use a prefix for all allocation functions
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (10 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 11/32] sandbox: Rename 'free' variable Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:35 ` [PATCH v2 13/32] exports: Add the malloc.h header Simon Glass
                   ` (27 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

In order to allow use of both U-Boot's malloc() and the C library's
version, set a prefix for the allocation functions so that they can
co-exist.

This is only done for sandbox. For other archs everything remains the
same.

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

Changes in v2: None

 include/malloc.h | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/include/malloc.h b/include/malloc.h
index 5efa6920b2..f66c2e8617 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -788,8 +788,13 @@ struct mallinfo {
 
 */
 
-/* #define USE_DL_PREFIX */
-
+/*
+ * Rename the U-Boot alloc functions so that sandbox can still use the system
+ * ones
+ */
+#ifdef CONFIG_SANDBOX
+#define USE_DL_PREFIX
+#endif
 
 /*
 
@@ -892,6 +897,21 @@ void malloc_simple_info(void);
 # define pvALLOc		dlpvalloc
 # define mALLINFo	dlmallinfo
 # define mALLOPt		dlmallopt
+
+/* Ensure that U-Boot actually uses these too */
+#define calloc dlcalloc
+#define free(ptr) dlfree(ptr)
+#define malloc(x) dlmalloc(x)
+#define memalign dlmemalign
+#define realloc dlrealloc
+#define valloc dlvalloc
+#define pvalloc dlpvalloc
+#define mallinfo() dlmallinfo()
+#define mallopt dlmallopt
+#define malloc_trim dlmalloc_trim
+#define malloc_usable_size dlmalloc_usable_size
+#define malloc_stats dlmalloc_stats
+
 # else /* USE_DL_PREFIX */
 # define cALLOc		calloc
 # define fREe		free
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 13/32] exports: Add the malloc.h header
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (11 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 12/32] sandbox: Use a prefix for all allocation functions Simon Glass
@ 2020-02-03 14:35 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 14/32] string: Allow arch override of strndup() also Simon Glass
                   ` (26 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:35 UTC (permalink / raw)
  To: u-boot

This file should include the malloc.h header since it references malloc().
Fix it.

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

Changes in v2: None

 common/exports.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/exports.c b/common/exports.c
index b4f1f7af15..18af38a5f6 100644
--- a/common/exports.c
+++ b/common/exports.c
@@ -1,5 +1,6 @@
 #include <common.h>
 #include <exports.h>
+#include <malloc.h>
 #include <spi.h>
 #include <i2c.h>
 
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 14/32] string: Allow arch override of strndup() also
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (12 preceding siblings ...)
  2020-02-03 14:35 ` [PATCH v2 13/32] exports: Add the malloc.h header Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 15/32] sandbox: Rename strdup() functions Simon Glass
                   ` (25 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present architectures can override strdup() but not strndup(). Use
the same option for both.

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

Changes in v2: None

 include/linux/string.h | 2 +-
 lib/string.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 5d63be4ce5..bb1d5ab07e 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -93,8 +93,8 @@ size_t strcspn(const char *s, const char *reject);
 
 #ifndef __HAVE_ARCH_STRDUP
 extern char * strdup(const char *);
-#endif
 extern char * strndup(const char *, size_t);
+#endif
 #ifndef __HAVE_ARCH_STRSWAB
 extern char * strswab(const char *);
 #endif
diff --git a/lib/string.c b/lib/string.c
index 9b779ddc3b..ae7835f600 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -324,7 +324,6 @@ char * strdup(const char *s)
 	strcpy (new, s);
 	return new;
 }
-#endif
 
 char * strndup(const char *s, size_t n)
 {
@@ -348,6 +347,7 @@ char * strndup(const char *s, size_t n)
 
 	return new;
 }
+#endif
 
 #ifndef __HAVE_ARCH_STRSPN
 /**
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 15/32] sandbox: Rename strdup() functions
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (13 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 14/32] string: Allow arch override of strndup() also Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 16/32] sandbox: Drop use of special os_malloc() where possible Simon Glass
                   ` (24 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

These functions include calls to a memory-allocation routine and so need
to use the system routine when called from a library.

To preserve access to these functions for libraries that need it, such as
SDL, rename these functions within U-Boot.

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

Changes in v2: None

 include/linux/string.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index bb1d5ab07e..d67998e5c4 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -91,6 +91,11 @@ extern __kernel_size_t strnlen(const char *,__kernel_size_t);
 size_t strcspn(const char *s, const char *reject);
 #endif
 
+#ifdef CONFIG_SANDBOX
+# define strdup		sandbox_strdup
+# define strndup		sandbox_strndup
+#endif
+
 #ifndef __HAVE_ARCH_STRDUP
 extern char * strdup(const char *);
 extern char * strndup(const char *, size_t);
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 16/32] sandbox: Drop use of special os_malloc() where possible
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (14 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 15/32] sandbox: Rename strdup() functions Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 17/32] sandbox: Drop os_realloc() Simon Glass
                   ` (23 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Some sandbox files are not built with U-Boot headers, so with the renamed
malloc functions there is now no need to use the special os_... allocation
functions to access the system routines. Instead we can just call them
directly.

Update the affected files accordingly.

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

Changes in v2: None

 arch/sandbox/cpu/eth-raw-os.c |  6 +++---
 arch/sandbox/cpu/os.c         | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index 8d05bc2eda..da01d1addf 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -74,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv,
 
 	/* Prepare device struct */
 	priv->local_bind_sd = -1;
-	priv->device = os_malloc(sizeof(struct sockaddr_ll));
+	priv->device = malloc(sizeof(struct sockaddr_ll));
 	if (priv->device == NULL)
 		return -ENOMEM;
 	device = priv->device;
@@ -147,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
 	/* Prepare device struct */
 	priv->local_bind_sd = -1;
 	priv->local_bind_udp_port = 0;
-	priv->device = os_malloc(sizeof(struct sockaddr_in));
+	priv->device = malloc(sizeof(struct sockaddr_in));
 	if (priv->device == NULL)
 		return -ENOMEM;
 	device = priv->device;
@@ -282,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length,
 
 void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
 {
-	os_free(priv->device);
+	free(priv->device);
 	priv->device = NULL;
 	close(priv->sd);
 	priv->sd = -1;
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 79094fb7f3..d5e5b561b6 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -137,7 +137,7 @@ int os_read_file(const char *fname, void **bufp, int *sizep)
 		printf("Cannot seek to start of file '%s'\n", fname);
 		goto err;
 	}
-	*bufp = os_malloc(size);
+	*bufp = malloc(size);
 	if (!*bufp) {
 		printf("Not enough memory to read file '%s'\n", fname);
 		ret = -ENOMEM;
@@ -306,8 +306,8 @@ int os_parse_args(struct sandbox_state *state, int argc, char *argv[])
 	state->argv = argv;
 
 	/* dynamically construct the arguments to the system getopt_long */
-	short_opts = os_malloc(sizeof(*short_opts) * num_options * 2 + 1);
-	long_opts = os_malloc(sizeof(*long_opts) * num_options);
+	short_opts = malloc(sizeof(*short_opts) * num_options * 2 + 1);
+	long_opts = malloc(sizeof(*long_opts) * num_options);
 	if (!short_opts || !long_opts)
 		return 1;
 
@@ -385,7 +385,7 @@ void os_dirent_free(struct os_dirent_node *node)
 
 	while (node) {
 		next = node->next;
-		os_free(node);
+		free(node);
 		node = next;
 	}
 }
@@ -410,7 +410,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 	/* Create a buffer upfront, with typically sufficient size */
 	dirlen = strlen(dirname) + 2;
 	len = dirlen + 256;
-	fname = os_malloc(len);
+	fname = malloc(len);
 	if (!fname) {
 		ret = -ENOMEM;
 		goto done;
@@ -423,7 +423,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 			ret = errno;
 			break;
 		}
-		next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+		next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
 		if (!next) {
 			os_dirent_free(head);
 			ret = -ENOMEM;
@@ -432,10 +432,10 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 		if (dirlen + strlen(entry->d_name) > len) {
 			len = dirlen + strlen(entry->d_name);
 			old_fname = fname;
-			fname = os_realloc(fname, len);
+			fname = realloc(fname, len);
 			if (!fname) {
-				os_free(old_fname);
-				os_free(next);
+				free(old_fname);
+				free(next);
 				os_dirent_free(head);
 				ret = -ENOMEM;
 				goto done;
@@ -469,7 +469,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 
 done:
 	closedir(dir);
-	os_free(fname);
+	free(fname);
 	return ret;
 }
 
@@ -586,7 +586,7 @@ static int add_args(char ***argvp, char *add_args[], int count)
 	for (argc = 0; (*argvp)[argc]; argc++)
 		;
 
-	argv = os_malloc((argc + count + 1) * sizeof(char *));
+	argv = malloc((argc + count + 1) * sizeof(char *));
 	if (!argv) {
 		printf("Out of memory for %d argv\n", count);
 		return -ENOMEM;
@@ -669,7 +669,7 @@ static int os_jump_to_file(const char *fname)
 		os_exit(2);
 
 	err = execv(fname, argv);
-	os_free(argv);
+	free(argv);
 	if (err) {
 		perror("Unable to run image");
 		printf("Image filename '%s'\n", fname);
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 17/32] sandbox: Drop os_realloc()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (15 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 16/32] sandbox: Drop use of special os_malloc() where possible Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 18/32] sandbox: Ensure that long-options array is terminated Simon Glass
                   ` (22 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Due to recent changes this function is no-longer used. Drop it.

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

Changes in v2: None

 arch/sandbox/cpu/os.c | 23 -----------------------
 include/os.h          | 22 +---------------------
 2 files changed, 1 insertion(+), 44 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d5e5b561b6..60011f7abc 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -238,29 +238,6 @@ void os_free(void *ptr)
 	}
 }
 
-void *os_realloc(void *ptr, size_t length)
-{
-	int page_size = getpagesize();
-	struct os_mem_hdr *hdr;
-	void *buf = NULL;
-
-	if (length) {
-		buf = os_malloc(length);
-		if (!buf)
-			return buf;
-		if (ptr) {
-			hdr = ptr - page_size;
-			if (length > hdr->length)
-				length = hdr->length;
-			memcpy(buf, ptr, length);
-		}
-	}
-	if (ptr)
-		os_free(ptr);
-
-	return buf;
-}
-
 void os_usleep(unsigned long usec)
 {
 	usleep(usec);
diff --git a/include/os.h b/include/os.h
index 7a4f78b9b1..1874ae674f 100644
--- a/include/os.h
+++ b/include/os.h
@@ -119,7 +119,7 @@ void os_fd_restore(void);
 void *os_malloc(size_t length);
 
 /**
- * Free memory previous allocated with os_malloc()/os_realloc()
+ * Free memory previous allocated with os_malloc()
  *
  * This returns the memory to the OS.
  *
@@ -127,26 +127,6 @@ void *os_malloc(size_t length);
  */
 void os_free(void *ptr);
 
-/**
- * Reallocate previously-allocated memory to increase/decrease space
- *
- * This works in a similar way to the C library realloc() function. If
- * length is 0, then ptr is freed. Otherwise the space used by ptr is
- * expanded or reduced depending on whether length is larger or smaller
- * than before.
- *
- * If ptr is NULL, then this is similar to calling os_malloc().
- *
- * This function may need to move the memory block to make room for any
- * extra space, in which case the new pointer is returned.
- *
- * \param ptr		Pointer to memory block to reallocate
- * \param length	New length for memory block
- * \return pointer to new memory block, or NULL on failure or if length
- *	is 0.
- */
-void *os_realloc(void *ptr, size_t length);
-
 /**
  * Access to the usleep function of the os
  *
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 18/32] sandbox: Ensure that long-options array is terminated
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (16 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 17/32] sandbox: Drop os_realloc() Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 19/32] sandbox: Add a new header for the system malloc() Simon Glass
                   ` (21 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

The last member of this array is supposed to be all zeroes according to
the getopt_long() man page. Fix the function to do this.

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

Changes in v2: None

 arch/sandbox/cpu/os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 60011f7abc..f7c73e3a0b 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -284,7 +284,7 @@ int os_parse_args(struct sandbox_state *state, int argc, char *argv[])
 
 	/* dynamically construct the arguments to the system getopt_long */
 	short_opts = malloc(sizeof(*short_opts) * num_options * 2 + 1);
-	long_opts = malloc(sizeof(*long_opts) * num_options);
+	long_opts = malloc(sizeof(*long_opts) * (num_options + 1));
 	if (!short_opts || !long_opts)
 		return 1;
 
@@ -314,6 +314,7 @@ int os_parse_args(struct sandbox_state *state, int argc, char *argv[])
 	/* we need to handle output ourselves since u-boot provides printf */
 	opterr = 0;
 
+	memset(&long_opts[num_options], '\0', sizeof(*long_opts));
 	/*
 	 * walk all of the options the user gave us on the command line,
 	 * figure out what u-boot option structure they belong to (via
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 19/32] sandbox: Add a new header for the system malloc()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (17 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 18/32] sandbox: Ensure that long-options array is terminated Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 20/32] sound: Add a new stop_play() method Simon Glass
                   ` (20 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Some files use U-Boot headers but still need to access the system
malloc(). Allow this by creating a new asm/malloc.h which can be used so
long as U-Boot's malloc.h has not been included.

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

Changes in v2: None

 arch/sandbox/cpu/start.c          |  6 +++---
 arch/sandbox/cpu/state.c          | 17 +++++++++--------
 arch/sandbox/include/asm/malloc.h | 26 ++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 11 deletions(-)
 create mode 100644 arch/sandbox/include/asm/malloc.h

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index d3ce61856e..fa53428436 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -8,10 +8,10 @@
 #include <errno.h>
 #include <os.h>
 #include <cli.h>
-#include <malloc.h>
 #include <sort.h>
 #include <asm/getopt.h>
 #include <asm/io.h>
+#include <asm/malloc.h>
 #include <asm/sections.h>
 #include <asm/state.h>
 #include <linux/ctype.h>
@@ -181,7 +181,7 @@ static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state,
 	int len;
 
 	len = strlen(state->argv[0]) + strlen(fmt) + 1;
-	fname = os_malloc(len);
+	fname = malloc(len);
 	if (!fname)
 		return -ENOMEM;
 	snprintf(fname, len, fmt, state->argv[0]);
@@ -201,7 +201,7 @@ static int sandbox_cmdline_cb_test_fdt(struct sandbox_state *state,
 	int len;
 
 	len = strlen(state->argv[0]) + strlen(fmt) + 1;
-	fname = os_malloc(len);
+	fname = malloc(len);
 	if (!fname)
 		return -ENOMEM;
 	strcpy(fname, state->argv[0]);
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index ef2e63f37a..a347cec528 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -7,6 +7,7 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <os.h>
+#include <asm/malloc.h>
 #include <asm/state.h>
 
 /* Main state record for the sandbox */
@@ -27,17 +28,17 @@ static int state_ensure_space(int extra_size)
 		return 0;
 
 	size = used + extra_size;
-	buf = os_malloc(size);
+	buf = malloc(size);
 	if (!buf)
 		return -ENOMEM;
 
 	ret = fdt_open_into(blob, buf, size);
 	if (ret) {
-		os_free(buf);
+		free(buf);
 		return -EIO;
 	}
 
-	os_free(blob);
+	free(blob);
 	state->state_fdt = buf;
 	return 0;
 }
@@ -53,7 +54,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
 		printf("Cannot find sandbox state file '%s'\n", fname);
 		return -ENOENT;
 	}
-	state->state_fdt = os_malloc(size);
+	state->state_fdt = malloc(size);
 	if (!state->state_fdt) {
 		puts("No memory to read sandbox state\n");
 		return -ENOMEM;
@@ -75,7 +76,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
 err_read:
 	os_close(fd);
 err_open:
-	os_free(state->state_fdt);
+	free(state->state_fdt);
 	state->state_fdt = NULL;
 
 	return ret;
@@ -242,7 +243,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
 	/* Create a state FDT if we don't have one */
 	if (!state->state_fdt) {
 		size = 0x4000;
-		state->state_fdt = os_malloc(size);
+		state->state_fdt = malloc(size);
 		if (!state->state_fdt) {
 			puts("No memory to create FDT\n");
 			return -ENOMEM;
@@ -300,7 +301,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
 err_write:
 	os_close(fd);
 err_create:
-	os_free(state->state_fdt);
+	free(state->state_fdt);
 
 	return ret;
 }
@@ -418,7 +419,7 @@ int state_uninit(void)
 		os_unlink(state->jumped_fname);
 
 	if (state->state_fdt)
-		os_free(state->state_fdt);
+		free(state->state_fdt);
 	memset(state, '\0', sizeof(*state));
 
 	return 0;
diff --git a/arch/sandbox/include/asm/malloc.h b/arch/sandbox/include/asm/malloc.h
new file mode 100644
index 0000000000..a1467b5ead
--- /dev/null
+++ b/arch/sandbox/include/asm/malloc.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Sandbox access to system malloc (i.e. not U-Boot's)
+ *
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef __ASM_MALLOC_H
+
+void *malloc(size_t size);
+void free(void *ptr);
+void *calloc(size_t nmemb, size_t size);
+void *realloc(void *ptr, size_t size);
+void *reallocarray(void *ptr, size_t nmemb, size_t size);
+
+/*
+ * This header allows calling the system allocation routines. It makes no
+ * sense to also include U-Boot's malloc.h since that redfines malloc to
+ * have a 'dl' prefix. These two implementations cannot be mixed and matched
+ * in the same file.
+ */
+#ifdef __MALLOC_H__
+#error "This sandbox header file cannot be included with malloc.h"
+#endif
+
+#endif
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 20/32] sound: Add a new stop_play() method
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (18 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 19/32] sandbox: Add a new header for the system malloc() Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 21/32] sandbox: sound: Handle errors better in sound_beep() Simon Glass
                   ` (19 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present there is no positive indication that U-Boot has finished
sending sound data. This means that it is not possible to power down an
audio codec, for example. Add a new method that is called once all sound
data has been sent.

Add a new method for this, called when the sound_play() call is done.

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

Changes in v2: None

 arch/sandbox/include/asm/test.h |  7 +++++++
 drivers/sound/sandbox.c         | 21 ++++++++++++++++++++-
 drivers/sound/sound-uclass.c    | 11 +++++++++++
 include/sound.h                 | 12 ++++++++++++
 test/dm/sound.c                 |  1 +
 5 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 2421922c9e..92ff494453 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -165,6 +165,13 @@ int sandbox_get_i2s_sum(struct udevice *dev);
  */
 int sandbox_get_setup_called(struct udevice *dev);
 
+/**
+ * sandbox_get_sound_active() - Returns whether sound play is in progress
+ *
+ * @return true if active, false if not
+ */
+int sandbox_get_sound_active(struct udevice *dev);
+
 /**
  * sandbox_get_sound_sum() - Read back the sum of the sound data so far
  *
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c
index 363c687baf..9034a8385a 100644
--- a/drivers/sound/sandbox.c
+++ b/drivers/sound/sandbox.c
@@ -26,7 +26,8 @@ struct sandbox_i2s_priv {
 };
 
 struct sandbox_sound_priv {
-	int setup_called;
+	int setup_called;	/* Incremented when setup() method is called */
+	bool active;		/* TX data is being sent */
 	int sum;		/* Use to sum the provided audio data */
 	bool allow_beep;	/* true to allow the start_beep() interface */
 	int frequency_hz;	/* Beep frequency if active, else 0 */
@@ -59,6 +60,13 @@ int sandbox_get_setup_called(struct udevice *dev)
 	return priv->setup_called;
 }
 
+int sandbox_get_sound_active(struct udevice *dev)
+{
+	struct sandbox_sound_priv *priv = dev_get_priv(dev);
+
+	return priv->active;
+}
+
 int sandbox_get_sound_sum(struct udevice *dev)
 {
 	struct sandbox_sound_priv *priv = dev_get_priv(dev);
@@ -163,6 +171,16 @@ static int sandbox_sound_play(struct udevice *dev, void *data, uint data_size)
 	return i2s_tx_data(uc_priv->i2s, data, data_size);
 }
 
+static int sandbox_sound_stop_play(struct udevice *dev)
+{
+	struct sandbox_sound_priv *priv = dev_get_priv(dev);
+
+	sandbox_sdl_sound_stop();
+	priv->active = false;
+
+	return 0;
+}
+
 int sandbox_sound_start_beep(struct udevice *dev, int frequency_hz)
 {
 	struct sandbox_sound_priv *priv = dev_get_priv(dev);
@@ -228,6 +246,7 @@ U_BOOT_DRIVER(sandbox_i2s) = {
 static const struct sound_ops sandbox_sound_ops = {
 	.setup		= sandbox_sound_setup,
 	.play		= sandbox_sound_play,
+	.stop_play	= sandbox_sound_stop_play,
 	.start_beep	= sandbox_sound_start_beep,
 	.stop_beep	= sandbox_sound_stop_beep,
 };
diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c
index d49f29bcd5..c213472d60 100644
--- a/drivers/sound/sound-uclass.c
+++ b/drivers/sound/sound-uclass.c
@@ -31,6 +31,16 @@ int sound_play(struct udevice *dev, void *data, uint data_size)
 	return ops->play(dev, data, data_size);
 }
 
+int sound_stop_play(struct udevice *dev)
+{
+	struct sound_ops *ops = sound_get_ops(dev);
+
+	if (!ops->play)
+		return -ENOSYS;
+
+	return ops->stop_play(dev);
+}
+
 int sound_start_beep(struct udevice *dev, int frequency_hz)
 {
 	struct sound_ops *ops = sound_get_ops(dev);
@@ -97,6 +107,7 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz)
 
 		ret = sound_play(dev, data, size);
 	}
+	sound_stop_play(dev);
 
 	free(data);
 
diff --git a/include/sound.h b/include/sound.h
index 47de9fa3ed..71bd850652 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -68,6 +68,18 @@ struct sound_ops {
 	 */
 	int (*play)(struct udevice *dev, void *data, uint data_size);
 
+	/**
+	 * stop_play() - Indicate that there is no more data coming
+	 *
+	 * This is called once play() has finished sending all the data to the
+	 * output device. This may be used to tell the hardware to turn off the
+	 * codec, for example.
+	 *
+	 * @dev: Sound device
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*stop_play)(struct udevice *dev);
+
 	/**
 	 * start_beep() - Start beeping (optional)
 	 *
diff --git a/test/dm/sound.c b/test/dm/sound.c
index 3767abbd1c..aa5368f05b 100644
--- a/test/dm/sound.c
+++ b/test/dm/sound.c
@@ -28,6 +28,7 @@ static int dm_test_sound(struct unit_test_state *uts)
 	ut_asserteq(4560, sandbox_get_sound_sum(dev));
 	ut_assertok(sound_beep(dev, 1, 100));
 	ut_asserteq(9120, sandbox_get_sound_sum(dev));
+	ut_asserteq(false, sandbox_get_sound_active(dev));
 
 	return 0;
 }
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 21/32] sandbox: sound: Handle errors better in sound_beep()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (19 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 20/32] sound: Add a new stop_play() method Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 22/32] sandbox: Add comments to the sdl struct Simon Glass
                   ` (18 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present an error does not stop the sound-output loop. This is incorrect
since nothing can be gained by trying to continue. Fix it.

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

Changes in v2: None

 drivers/sound/sound-uclass.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c
index c213472d60..bada0c2ba5 100644
--- a/drivers/sound/sound-uclass.c
+++ b/drivers/sound/sound-uclass.c
@@ -97,11 +97,14 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz)
 	sound_create_square_wave(i2s_uc_priv->samplingrate, data, data_size,
 				 frequency_hz, i2s_uc_priv->channels);
 
+	ret = 0;
 	while (msecs >= 1000) {
 		ret = sound_play(dev, data, data_size);
+		if (ret)
+			break;
 		msecs -= 1000;
 	}
-	if (msecs) {
+	if (!ret && msecs) {
 		unsigned long size =
 			(data_size * msecs) / (sizeof(int) * 1000);
 
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 22/32] sandbox: Add comments to the sdl struct
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (20 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 21/32] sandbox: sound: Handle errors better in sound_beep() Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 23/32] sandbox: sdl: Improve error handling Simon Glass
                   ` (17 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Add comments for each struct member. Drop frequency since it is not used.

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

Changes in v2: None

 arch/sandbox/cpu/sdl.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 080c7c8d74..dad059f257 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -24,13 +24,28 @@ struct buf_info {
 	uint8_t *data;
 };
 
+/**
+ * struct sdl_info - Information about our use of the SDL library
+ *
+ * @screen: Surface used to draw on the screen
+ * @width: Width of simulated LCD display
+ * @height: Height of simulated LCD display
+ * @depth: Depth of the display in bits per pixel (16 or 32)
+ * @pitch: Number of bytes per line of the display
+ * @sample_rate: Current sample rate for audio
+ * @audio_active: true if audio can be used
+ * @inited: true if this module is initialised
+ * @cur_buf: Current audio buffer being used by sandbox_sdl_fill_audio (0 or 1)
+ * @buf: The two available audio buffers. SDL can be reading from one while we
+ *	are setting up the next
+ * @running: true if audio is running
+ */
 static struct sdl_info {
 	SDL_Surface *screen;
 	int width;
 	int height;
 	int depth;
 	int pitch;
-	uint frequency;
 	uint sample_rate;
 	bool audio_active;
 	bool inited;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 23/32] sandbox: sdl: Improve error handling
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (21 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 22/32] sandbox: Add comments to the sdl struct Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 24/32] sandbox: sdl: Support waiting for audio to complete Simon Glass
                   ` (16 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

A few errors are not checked. Fix these and use my preferred spelling for
init.

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

Changes in v2: None

 arch/sandbox/cpu/sdl.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index dad059f257..ee62da265b 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -77,7 +77,7 @@ static int sandbox_sdl_ensure_init(void)
 {
 	if (!sdl.inited) {
 		if (SDL_Init(0) < 0) {
-			printf("Unable to initialize SDL: %s\n",
+			printf("Unable to initialise SDL: %s\n",
 			       SDL_GetError());
 			return -EIO;
 		}
@@ -100,7 +100,7 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp)
 	if (err)
 		return err;
 	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
-		printf("Unable to initialize SDL LCD: %s\n", SDL_GetError());
+		printf("Unable to initialise SDL LCD: %s\n", SDL_GetError());
 		return -EPERM;
 	}
 	SDL_WM_SetCaption("U-Boot", "U-Boot");
@@ -298,7 +298,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len)
 
 int sandbox_sdl_sound_init(int rate, int channels)
 {
-	SDL_AudioSpec wanted;
+	SDL_AudioSpec wanted, have;
 	int i;
 
 	if (sandbox_sdl_ensure_init())
@@ -331,15 +331,19 @@ int sandbox_sdl_sound_init(int rate, int channels)
 	}
 
 	if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
-		printf("Unable to initialize SDL audio: %s\n", SDL_GetError());
+		printf("Unable to initialise SDL audio: %s\n", SDL_GetError());
 		goto err;
 	}
 
 	/* Open the audio device, forcing the desired format */
-	if (SDL_OpenAudio(&wanted, NULL) < 0) {
+	if (SDL_OpenAudio(&wanted, &have) < 0) {
 		printf("Couldn't open audio: %s\n", SDL_GetError());
 		goto err;
 	}
+	if (have.format != wanted.format) {
+		printf("Couldn't select required audio format\n");
+		goto err;
+	}
 	sdl.audio_active = true;
 	sdl.sample_rate = wanted.freq;
 	sdl.cur_buf = 0;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 24/32] sandbox: sdl: Support waiting for audio to complete
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (22 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 23/32] sandbox: sdl: Improve error handling Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox Simon Glass
                   ` (15 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present when audio stops, any in-progress output is cut off. Fix this
by waiting for output to finish.

Also use booleans for the boolean variables.

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

Changes in v2: None

 arch/sandbox/cpu/sdl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index ee62da265b..dedf00ed35 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <stdbool.h>
 #include <linux/input.h>
 #include <SDL.h>
 #include <asm/state.h>
@@ -39,6 +40,7 @@ struct buf_info {
  * @buf: The two available audio buffers. SDL can be reading from one while we
  *	are setting up the next
  * @running: true if audio is running
+ * @stopping: true if audio will stop once it runs out of data
  */
 static struct sdl_info {
 	SDL_Surface *screen;
@@ -52,6 +54,7 @@ static struct sdl_info {
 	int cur_buf;
 	struct buf_info buf[2];
 	bool running;
+	bool stopping;
 } sdl;
 
 static void sandbox_sdl_poll_events(void)
@@ -271,6 +274,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len)
 {
 	struct buf_info *buf;
 	int avail;
+	bool have_data = false;
 	int i;
 
 	for (i = 0; i < 2; i++) {
@@ -282,6 +286,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len)
 		}
 		if (avail > len)
 			avail = len;
+		have_data = true;
 
 		SDL_MixAudio(stream, buf->data + buf->pos, avail,
 			     SDL_MIX_MAXVOLUME);
@@ -294,6 +299,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len)
 		else
 			break;
 	}
+	sdl.stopping = !have_data;
 }
 
 int sandbox_sdl_sound_init(int rate, int channels)
@@ -347,7 +353,7 @@ int sandbox_sdl_sound_init(int rate, int channels)
 	sdl.audio_active = true;
 	sdl.sample_rate = wanted.freq;
 	sdl.cur_buf = 0;
-	sdl.running = 0;
+	sdl.running = false;
 
 	return 0;
 
@@ -378,7 +384,8 @@ int sandbox_sdl_sound_play(const void *data, uint size)
 	buf->pos = 0;
 	if (!sdl.running) {
 		SDL_PauseAudio(0);
-		sdl.running = 1;
+		sdl.running = true;
+		sdl.stopping = false;
 	}
 
 	return 0;
@@ -387,8 +394,12 @@ int sandbox_sdl_sound_play(const void *data, uint size)
 int sandbox_sdl_sound_stop(void)
 {
 	if (sdl.running) {
+		while (!sdl.stopping)
+			SDL_Delay(100);
+
 		SDL_PauseAudio(1);
 		sdl.running = 0;
+		sdl.stopping = false;
 	}
 
 	return 0;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 25/32] gitlab: Disable SDL when building sandbox
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (23 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 24/32] sandbox: sdl: Support waiting for audio to complete Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 Simon Glass
                   ` (14 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

I am not sure how to add libsdl2-dev to the gitlab image, so disable
building sandbox with SDL for now.

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

Changes in v2: None

 .gitlab-ci.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c7ca5967dd..303e6b01b3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -32,7 +32,8 @@ stages:
     # use clang only do one configuration.
     - if [[ "${BUILDMAN}" != "" ]]; then
         ret=0;
-        tools/buildman/buildman -o /tmp -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
+        NO_SDL=1 tools/buildman/buildman -o /tmp -P -E ${BUILDMAN}
+          ${OVERRIDE}|| ret=$?;
         if [[ $ret -ne 0 && $ret -ne 129 ]]; then
           tools/buildman/buildman -o /tmp -sdeP ${BUILDMAN};
           exit $ret;
@@ -164,7 +165,7 @@ Run binman, buildman, dtoc and patman testsuites:
       export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/sandbox_spl;
       export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
       export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
-      ./tools/buildman/buildman -o /tmp -P sandbox_spl;
+      NO_SDL=1 ./tools/buildman/buildman -o /tmp -P sandbox_spl;
       ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
       ./tools/buildman/buildman -t;
       ./tools/dtoc/dtoc -t;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 26/32] sandbox: sdl: Move to use SDL2
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (24 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size Simon Glass
                   ` (13 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Sandbox currently uses SDL1.2. SDL2 has been around for quite a while and
is widely supported. It has a number of useful features. It seems
appropriate to move sandbox over.

Update the code to use SDL2 instead of SDL1.2.

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

Changes in v2: None

 .travis.yml            |   2 +-
 arch/sandbox/config.mk |   2 +-
 arch/sandbox/cpu/sdl.c | 279 +++++++++++++++++++++++------------------
 doc/arch/sandbox.rst   |   2 +-
 4 files changed, 158 insertions(+), 127 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 3991eb7716..44e539038a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,7 @@ addons:
     - sparse
     - bc
     - build-essential
-    - libsdl1.2-dev
+    - libsdl2-dev
     - python
     - python-pyelftools
     - python3-virtualenv
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index a225c9cbfa..189e9c2b0c 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -5,7 +5,7 @@ PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
 PLATFORM_CPPFLAGS += -fPIC
 PLATFORM_LIBS += -lrt
-SDL_CONFIG ?= sdl-config
+SDL_CONFIG ?= sdl2-config
 
 # Define this to avoid linking with SDL, which requires SDL libraries
 # This can solve 'sdl-config: Command not found' errors
diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index dedf00ed35..58a9cc8168 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -7,7 +7,7 @@
 #include <unistd.h>
 #include <stdbool.h>
 #include <linux/input.h>
-#include <SDL.h>
+#include <SDL2/SDL.h>
 #include <asm/state.h>
 
 /**
@@ -28,7 +28,6 @@ struct buf_info {
 /**
  * struct sdl_info - Information about our use of the SDL library
  *
- * @screen: Surface used to draw on the screen
  * @width: Width of simulated LCD display
  * @height: Height of simulated LCD display
  * @depth: Depth of the display in bits per pixel (16 or 32)
@@ -41,9 +40,10 @@ struct buf_info {
  *	are setting up the next
  * @running: true if audio is running
  * @stopping: true if audio will stop once it runs out of data
+ * @texture: SDL texture to use for U-Boot display contents
+ * @renderer: SDL renderer to use
  */
 static struct sdl_info {
-	SDL_Surface *screen;
 	int width;
 	int height;
 	int depth;
@@ -55,6 +55,8 @@ static struct sdl_info {
 	struct buf_info buf[2];
 	bool running;
 	bool stopping;
+	SDL_Texture *texture;
+	SDL_Renderer *renderer;
 } sdl;
 
 static void sandbox_sdl_poll_events(void)
@@ -106,13 +108,41 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp)
 		printf("Unable to initialise SDL LCD: %s\n", SDL_GetError());
 		return -EPERM;
 	}
-	SDL_WM_SetCaption("U-Boot", "U-Boot");
-
 	sdl.width = width;
 	sdl.height = height;
 	sdl.depth = 1 << log2_bpp;
 	sdl.pitch = sdl.width * sdl.depth / 8;
-	sdl.screen = SDL_SetVideoMode(width, height, 0, 0);
+	SDL_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED,
+					      SDL_WINDOWPOS_UNDEFINED,
+					      sdl.width, sdl.height, 0);
+	if (!screen) {
+		printf("Unable to initialise SDL screen: %s\n",
+		       SDL_GetError());
+		return -EIO;
+	}
+	if (log2_bpp != 4 && log2_bpp != 5) {
+		printf("U-Boot SDL does not support depth %d\n", log2_bpp);
+		return -EINVAL;
+	}
+	sdl.renderer = SDL_CreateRenderer(screen, -1,
+					  SDL_RENDERER_ACCELERATED |
+					  SDL_RENDERER_PRESENTVSYNC);
+	if (!sdl.renderer) {
+		printf("Unable to initialise SDL renderer: %s\n",
+		       SDL_GetError());
+		return -EIO;
+	}
+
+	sdl.texture = SDL_CreateTexture(sdl.renderer, log2_bpp == 4 ?
+					SDL_PIXELFORMAT_RGB565 :
+					SDL_PIXELFORMAT_RGB888,
+					SDL_TEXTUREACCESS_STREAMING,
+					width, height);
+	if (!sdl.texture) {
+		printf("Unable to initialise SDL texture: %s\n",
+		       SDL_GetError());
+		return -EBADF;
+	}
 	sandbox_sdl_poll_events();
 
 	return 0;
@@ -120,136 +150,137 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp)
 
 int sandbox_sdl_sync(void *lcd_base)
 {
-	SDL_Surface *frame;
-
-	frame = SDL_CreateRGBSurfaceFrom(lcd_base, sdl.width, sdl.height,
-			sdl.depth, sdl.pitch,
-			0x1f << 11, 0x3f << 5, 0x1f << 0, 0);
-	SDL_BlitSurface(frame, NULL, sdl.screen, NULL);
-	SDL_FreeSurface(frame);
-	SDL_UpdateRect(sdl.screen, 0, 0, 0, 0);
+	SDL_UpdateTexture(sdl.texture, NULL, lcd_base, sdl.pitch);
+	SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL);
+	SDL_RenderPresent(sdl.renderer);
 	sandbox_sdl_poll_events();
 
 	return 0;
 }
 
-#define NONE (-1)
-#define NUM_SDL_CODES	(SDLK_UNDO + 1)
-
-static int16_t sdl_to_keycode[NUM_SDL_CODES] = {
-	/* 0 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, KEY_BACKSPACE, KEY_TAB,
-	NONE, NONE, NONE, KEY_ENTER, NONE,
-	NONE, NONE, NONE, NONE, KEY_POWER,	/* use PAUSE as POWER */
-
-	/* 20 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, KEY_ESC, NONE, NONE,
-	NONE, NONE, KEY_SPACE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 40 */
-	NONE, NONE, NONE, NONE, KEY_COMMA,
-	KEY_MINUS, KEY_DOT, KEY_SLASH, KEY_0, KEY_1,
-	KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
-	KEY_7, KEY_8, KEY_9, NONE, KEY_SEMICOLON,
-
-	/* 60 */
-	NONE, KEY_EQUAL, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 80 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, KEY_BACKSLASH, NONE, NONE,
-	NONE, KEY_GRAVE, KEY_A, KEY_B, KEY_C,
-
-	/* 100 */
-	KEY_D, KEY_E, KEY_F, KEY_G, KEY_H,
-	KEY_I, KEY_J, KEY_K, KEY_L, KEY_M,
-	KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R,
-	KEY_S, KEY_T, KEY_U, KEY_V, KEY_W,
-
-	/* 120 */
-	KEY_X, KEY_Y, KEY_Z, NONE, NONE,
-	NONE, NONE, KEY_DELETE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 140 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 160 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 180 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 200 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 220 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 240 */
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-	NONE, KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3,
-
-	/* 260 */
-	KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8,
-	KEY_KP9, KEY_KPDOT, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS,
-	KEY_KPPLUS, KEY_KPENTER, KEY_KPEQUAL, KEY_UP, KEY_DOWN,
-	KEY_RIGHT, KEY_LEFT, KEY_INSERT, KEY_HOME, KEY_END,
-
-	/* 280 */
-	KEY_PAGEUP, KEY_PAGEDOWN, KEY_F1, KEY_F2, KEY_F3,
-	KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8,
-	KEY_F9, KEY_F10, KEY_F11, KEY_F12, NONE,
-	NONE, NONE, NONE, NONE, NONE,
-
-	/* 300 */
-	KEY_NUMLOCK, KEY_CAPSLOCK, KEY_SCROLLLOCK, KEY_RIGHTSHIFT,
-		KEY_LEFTSHIFT,
-	KEY_RIGHTCTRL, KEY_LEFTCTRL, KEY_RIGHTALT, KEY_LEFTALT, KEY_RIGHTMETA,
-	KEY_LEFTMETA, NONE, KEY_FN, NONE, KEY_COMPOSE,
-	NONE, KEY_PRINT, KEY_SYSRQ, KEY_PAUSE, NONE,
-
-	/* 320 */
-	NONE, NONE, NONE,
+static const unsigned short sdl_to_keycode[SDL_NUM_SCANCODES] = {
+	[SDL_SCANCODE_A]	= KEY_A,
+	[SDL_SCANCODE_B]	= KEY_B,
+	[SDL_SCANCODE_C]	= KEY_C,
+	[SDL_SCANCODE_D]	= KEY_D,
+	[SDL_SCANCODE_E]	= KEY_E,
+	[SDL_SCANCODE_F]	= KEY_F,
+	[SDL_SCANCODE_G]	= KEY_G,
+	[SDL_SCANCODE_H]	= KEY_H,
+	[SDL_SCANCODE_I]	= KEY_I,
+	[SDL_SCANCODE_J]	= KEY_J,
+	[SDL_SCANCODE_K]	= KEY_K,
+	[SDL_SCANCODE_L]	= KEY_L,
+	[SDL_SCANCODE_M]	= KEY_M,
+	[SDL_SCANCODE_N]	= KEY_N,
+	[SDL_SCANCODE_O]	= KEY_O,
+	[SDL_SCANCODE_P]	= KEY_P,
+	[SDL_SCANCODE_Q]	= KEY_Q,
+	[SDL_SCANCODE_R]	= KEY_R,
+	[SDL_SCANCODE_S]	= KEY_S,
+	[SDL_SCANCODE_T]	= KEY_T,
+	[SDL_SCANCODE_U]	= KEY_U,
+	[SDL_SCANCODE_V]	= KEY_V,
+	[SDL_SCANCODE_W]	= KEY_W,
+	[SDL_SCANCODE_X]	= KEY_X,
+	[SDL_SCANCODE_Y]	= KEY_Y,
+	[SDL_SCANCODE_Z]	= KEY_Z,
+
+	[SDL_SCANCODE_1]	= KEY_1,
+	[SDL_SCANCODE_2]	= KEY_2,
+	[SDL_SCANCODE_3]	= KEY_3,
+	[SDL_SCANCODE_4]	= KEY_4,
+	[SDL_SCANCODE_5]	= KEY_5,
+	[SDL_SCANCODE_6]	= KEY_6,
+	[SDL_SCANCODE_7]	= KEY_7,
+	[SDL_SCANCODE_8]	= KEY_8,
+	[SDL_SCANCODE_9]	= KEY_9,
+	[SDL_SCANCODE_0]	= KEY_0,
+
+	[SDL_SCANCODE_RETURN]	= KEY_ENTER,
+	[SDL_SCANCODE_ESCAPE]	= KEY_ESC,
+	[SDL_SCANCODE_BACKSPACE]	= KEY_BACKSPACE,
+	[SDL_SCANCODE_TAB]	= KEY_TAB,
+	[SDL_SCANCODE_SPACE]	= KEY_SPACE,
+
+	[SDL_SCANCODE_MINUS]	= KEY_MINUS,
+	[SDL_SCANCODE_EQUALS]	= KEY_EQUAL,
+	[SDL_SCANCODE_BACKSLASH]	= KEY_BACKSLASH,
+	[SDL_SCANCODE_SEMICOLON]	= KEY_SEMICOLON,
+	[SDL_SCANCODE_APOSTROPHE]	= KEY_APOSTROPHE,
+	[SDL_SCANCODE_GRAVE]	= KEY_GRAVE,
+	[SDL_SCANCODE_COMMA]	= KEY_COMMA,
+	[SDL_SCANCODE_PERIOD]	= KEY_DOT,
+	[SDL_SCANCODE_SLASH]	= KEY_SLASH,
+
+	[SDL_SCANCODE_CAPSLOCK]	= KEY_CAPSLOCK,
+
+	[SDL_SCANCODE_F1]	= KEY_F1,
+	[SDL_SCANCODE_F2]	= KEY_F2,
+	[SDL_SCANCODE_F3]	= KEY_F3,
+	[SDL_SCANCODE_F4]	= KEY_F4,
+	[SDL_SCANCODE_F5]	= KEY_F5,
+	[SDL_SCANCODE_F6]	= KEY_F6,
+	[SDL_SCANCODE_F7]	= KEY_F7,
+	[SDL_SCANCODE_F8]	= KEY_F8,
+	[SDL_SCANCODE_F9]	= KEY_F9,
+	[SDL_SCANCODE_F10]	= KEY_F10,
+	[SDL_SCANCODE_F11]	= KEY_F11,
+	[SDL_SCANCODE_F12]	= KEY_F12,
+
+	[SDL_SCANCODE_PRINTSCREEN]	= KEY_PRINT,
+	[SDL_SCANCODE_SCROLLLOCK]	= KEY_SCROLLLOCK,
+	[SDL_SCANCODE_PAUSE]	= KEY_PAUSE,
+	[SDL_SCANCODE_INSERT]	= KEY_INSERT,
+	[SDL_SCANCODE_HOME]	= KEY_HOME,
+	[SDL_SCANCODE_PAGEUP]	= KEY_PAGEUP,
+	[SDL_SCANCODE_DELETE]	= KEY_DELETE,
+	[SDL_SCANCODE_END]	= KEY_END,
+	[SDL_SCANCODE_PAGEDOWN]	= KEY_PAGEDOWN,
+	[SDL_SCANCODE_RIGHT]	= KEY_RIGHT,
+	[SDL_SCANCODE_LEFT]	= KEY_LEFT,
+	[SDL_SCANCODE_DOWN]	= KEY_DOWN,
+	[SDL_SCANCODE_UP]	= KEY_UP,
+
+	[SDL_SCANCODE_NUMLOCKCLEAR]	= KEY_NUMLOCK,
+	[SDL_SCANCODE_KP_DIVIDE]	= KEY_KPSLASH,
+	[SDL_SCANCODE_KP_MULTIPLY]	= KEY_KPASTERISK,
+	[SDL_SCANCODE_KP_MINUS]	= KEY_KPMINUS,
+	[SDL_SCANCODE_KP_PLUS]	= KEY_KPPLUS,
+	[SDL_SCANCODE_KP_ENTER]	= KEY_KPENTER,
+	[SDL_SCANCODE_KP_1]	= KEY_KP1,
+	[SDL_SCANCODE_KP_2]	= KEY_KP2,
+	[SDL_SCANCODE_KP_3]	= KEY_KP3,
+	[SDL_SCANCODE_KP_4]	= KEY_KP4,
+	[SDL_SCANCODE_KP_5]	= KEY_KP5,
+	[SDL_SCANCODE_KP_6]	= KEY_KP6,
+	[SDL_SCANCODE_KP_7]	= KEY_KP7,
+	[SDL_SCANCODE_KP_8]	= KEY_KP8,
+	[SDL_SCANCODE_KP_9]	= KEY_KP9,
+	[SDL_SCANCODE_KP_0]	= KEY_KP0,
+	[SDL_SCANCODE_KP_PERIOD]	= KEY_KPDOT,
+
+	[SDL_SCANCODE_KP_EQUALS]	= KEY_KPEQUAL,
+	[SDL_SCANCODE_KP_COMMA]	= KEY_KPCOMMA,
+
+	[SDL_SCANCODE_SYSREQ]	= KEY_SYSRQ,
 };
 
 int sandbox_sdl_scan_keys(int key[], int max_keys)
 {
-	Uint8 *keystate;
+	const Uint8 *keystate;
+	int num_keys;
 	int i, count;
 
 	sandbox_sdl_poll_events();
-	keystate = SDL_GetKeyState(NULL);
-	for (i = count = 0; i < NUM_SDL_CODES; i++) {
-		if (count >= max_keys)
-			break;
-		else if (keystate[i])
-			key[count++] = sdl_to_keycode[i];
+	keystate = SDL_GetKeyboardState(&num_keys);
+	for (i = count = 0; i < num_keys; i++) {
+		if (count < max_keys && keystate[i]) {
+			int keycode = sdl_to_keycode[i];
+
+			if (keycode)
+				key[count++] = keycode;
+		}
 	}
 
 	return count;
diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
index e1f4dde6f8..e577a95716 100644
--- a/doc/arch/sandbox.rst
+++ b/doc/arch/sandbox.rst
@@ -43,7 +43,7 @@ To run sandbox U-Boot use something like::
    ./u-boot
 
 Note: If you get errors about 'sdl-config: Command not found' you may need to
-install libsdl1.2-dev or similar to get SDL support. Alternatively you can
+install libsdl2.0-dev or similar to get SDL support. Alternatively you can
 build sandbox without SDL (i.e. no display/keyboard support) by removing
 the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using::
 
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (25 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth Simon Glass
                   ` (12 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

On high-DPI displays U-Boot's LCD window can look very small. Add a
-K flag to expand it to make things easier to read, while still using
the existing resolution internally.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 arch/sandbox/cpu/sdl.c           | 17 +++++++++++++++--
 arch/sandbox/cpu/start.c         | 10 ++++++++++
 arch/sandbox/include/asm/sdl.h   |  9 ++++++---
 arch/sandbox/include/asm/state.h |  1 +
 drivers/video/sandbox_sdl.c      |  5 ++++-
 5 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 58a9cc8168..6416cab96c 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -30,6 +30,8 @@ struct buf_info {
  *
  * @width: Width of simulated LCD display
  * @height: Height of simulated LCD display
+ * @vis_width: Visible width (may be larger to allow for scaling up)
+ * @vis_height: Visible height (may be larger to allow for scaling up)
  * @depth: Depth of the display in bits per pixel (16 or 32)
  * @pitch: Number of bytes per line of the display
  * @sample_rate: Current sample rate for audio
@@ -46,6 +48,8 @@ struct buf_info {
 static struct sdl_info {
 	int width;
 	int height;
+	int vis_width;
+	int vis_height;
 	int depth;
 	int pitch;
 	uint sample_rate;
@@ -94,7 +98,8 @@ static int sandbox_sdl_ensure_init(void)
 	return 0;
 }
 
-int sandbox_sdl_init_display(int width, int height, int log2_bpp)
+int sandbox_sdl_init_display(int width, int height, int log2_bpp,
+			     bool double_size)
 {
 	struct sandbox_state *state = state_get_current();
 	int err;
@@ -110,11 +115,19 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp)
 	}
 	sdl.width = width;
 	sdl.height = height;
+	if (double_size) {
+		sdl.vis_width = sdl.width * 2;
+		sdl.vis_height = sdl.height * 2;
+	} else {
+		sdl.vis_width = sdl.width;
+		sdl.vis_height = sdl.height;
+	}
+
 	sdl.depth = 1 << log2_bpp;
 	sdl.pitch = sdl.width * sdl.depth / 8;
 	SDL_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED,
 					      SDL_WINDOWPOS_UNDEFINED,
-					      sdl.width, sdl.height, 0);
+					      sdl.vis_width, sdl.vis_height, 0);
 	if (!screen) {
 		printf("Unable to initialise SDL screen: %s\n",
 		       SDL_GetError());
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index fa53428436..3655ebf157 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -308,6 +308,16 @@ static int sandbox_cmdline_cb_show_lcd(struct sandbox_state *state,
 SANDBOX_CMDLINE_OPT_SHORT(show_lcd, 'l', 0,
 			  "Show the sandbox LCD display");
 
+static int sandbox_cmdline_cb_double_lcd(struct sandbox_state *state,
+					 const char *arg)
+{
+	state->double_lcd = true;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(double_lcd, 'K', 0,
+			  "Double the LCD display size in each direction");
+
 static const char *term_args[STATE_TERM_COUNT] = {
 	"raw-with-sigs",
 	"raw",
diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h
index c45dbddd70..47fc4889d2 100644
--- a/arch/sandbox/include/asm/sdl.h
+++ b/arch/sandbox/include/asm/sdl.h
@@ -17,10 +17,13 @@
  * @height	Window height in pixels
  * @log2_bpp:	Log to base 2 of the number of bits per pixel. So a 32bpp
  *		display will pass 5, since 2*5 = 32
+ * @double_size: true to double the visible size in each direction for high-DPI
+ *		displays
  * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
  *		and -EPERM if the video failed to come up.
  */
-int sandbox_sdl_init_display(int width, int height, int log2_bpp);
+int sandbox_sdl_init_display(int width, int height, int log2_bpp,
+			     bool double_size);
 
 /**
  * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL
@@ -78,8 +81,8 @@ int sandbox_sdl_sound_stop(void);
 int sandbox_sdl_sound_init(int rate, int channels);
 
 #else
-static inline int sandbox_sdl_init_display(int width, int height,
-					    int log2_bpp)
+static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
+					   bool double_size)
 {
 	return -ENODEV;
 }
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index ad3e94beb9..705645d714 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -83,6 +83,7 @@ struct sandbox_state {
 	bool write_state;		/* Write sandbox state on exit */
 	bool ignore_missing_state_on_read;	/* No error if state missing */
 	bool show_lcd;			/* Show LCD on start-up */
+	bool double_lcd;		/* Double display size for high-DPI */
 	enum sysreset_t last_sysreset;	/* Last system reset type */
 	bool sysreset_allowed[SYSRESET_COUNT];	/* Allowed system reset types */
 	enum state_terminal_raw term_raw;	/* Terminal raw/cooked */
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index 913651c565..d1272d0918 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -8,6 +8,7 @@
 #include <fdtdec.h>
 #include <video.h>
 #include <asm/sdl.h>
+#include <asm/state.h>
 #include <asm/u-boot-sandbox.h>
 #include <dm/test.h>
 
@@ -23,9 +24,11 @@ static int sandbox_sdl_probe(struct udevice *dev)
 {
 	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
 	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct sandbox_state *state = state_get_current();
 	int ret;
 
-	ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
+	ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix,
+				       state->double_lcd);
 	if (ret) {
 		puts("LCD init failed\n");
 		return ret;
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 28/32] sandbox: Support changing the LCD colour depth
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (26 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header Simon Glass
                   ` (11 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Add a new device-tree property to control the colour depth. At present we
support 16bpp and 32bpp.

While we are here, update the code to use livetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2:
- Drop the patch with the Roboto font

 arch/sandbox/dts/sandbox.dtsi                 | 1 +
 doc/device-tree-bindings/video/sandbox-fb.txt | 6 +++++-
 drivers/video/sandbox_sdl.c                   | 8 +++-----
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7bf144f532..7cd56c14f2 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -83,6 +83,7 @@
 		compatible = "sandbox,lcd-sdl";
 		xres = <1366>;
 		yres = <768>;
+		log2-depth = <5>;
 	};
 
 	leds {
diff --git a/doc/device-tree-bindings/video/sandbox-fb.txt b/doc/device-tree-bindings/video/sandbox-fb.txt
index eb91b30e3f..230d25c23b 100644
--- a/doc/device-tree-bindings/video/sandbox-fb.txt
+++ b/doc/device-tree-bindings/video/sandbox-fb.txt
@@ -2,7 +2,10 @@ Sandbox LCD
 ===========
 
 This uses the displaymode.txt binding except that only xres and yres are
-required properties.
+required properties. Also an additional optional property is defined:
+
+log2-depth: Log base 2 of the U-Boot display buffer depth (4=16bpp, 5=32bpp).
+	If not provided, a value of 4 is used.
 
 Example:
 
@@ -10,4 +13,5 @@ Example:
 		compatible = "sandbox,lcd-sdl";
 		xres = <800>;
 		yres = <600>;
+		log2-depth = <5>;
 	};
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index d1272d0918..1196e6c671 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -47,13 +47,11 @@ static int sandbox_sdl_bind(struct udevice *dev)
 {
 	struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
 	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	int ret = 0;
 
-	plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
-	plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
-	plat->bpix = VIDEO_BPP16;
+	plat->xres = dev_read_u32_default(dev, "xres", LCD_MAX_WIDTH);
+	plat->yres = dev_read_u32_default(dev, "yres", LCD_MAX_HEIGHT);
+	plat->bpix = dev_read_u32_default(dev, "log2-depth", VIDEO_BPP16);
 	uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
 	debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
 
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 29/32] dm: core: Require users of devres to include the header
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (27 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features Simon Glass
                   ` (10 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present devres.h is included in all files that include dm.h but few
make use of it. Also this pulls in linux/compat which adds several more
headers. Drop the automatic inclusion and require files to include devres
themselves. This provides a good indication of which files use devres.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 arch/arm/mach-aspeed/ast2500/clk_ast2500.c      | 1 +
 arch/arm/mach-imx/cmd_nandbcb.c                 | 1 +
 arch/arm/mach-meson/board-info.c                | 1 +
 arch/arm/mach-meson/sm.c                        | 1 +
 arch/arm/mach-rockchip/px30/clk_px30.c          | 1 +
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c      | 1 +
 arch/arm/mach-rockchip/rk3128/clk_rk3128.c      | 1 +
 arch/arm/mach-rockchip/rk3188/clk_rk3188.c      | 1 +
 arch/arm/mach-rockchip/rk3188/rk3188.c          | 1 +
 arch/arm/mach-rockchip/rk322x/clk_rk322x.c      | 1 +
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c      | 1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c          | 1 +
 arch/arm/mach-rockchip/rk3308/clk_rk3308.c      | 1 +
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c      | 1 +
 arch/arm/mach-rockchip/rk3368/clk_rk3368.c      | 1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c      | 1 +
 arch/arm/mach-rockchip/rv1108/clk_rv1108.c      | 1 +
 arch/arm/mach-stm32mp/pwr_regulator.c           | 1 +
 arch/riscv/lib/andes_plic.c                     | 1 +
 arch/riscv/lib/andes_plmt.c                     | 1 +
 arch/riscv/lib/sifive_clint.c                   | 1 +
 board/google/veyron/veyron.c                    | 1 +
 board/st/stm32mp1/stm32mp1.c                    | 1 +
 cmd/gpio.c                                      | 1 +
 cmd/gpt.c                                       | 1 +
 cmd/mtd.c                                       | 2 ++
 cmd/ubi.c                                       | 1 +
 drivers/adc/rockchip-saradc.c                   | 1 +
 drivers/block/blk-uclass.c                      | 1 +
 drivers/clk/altera/clk-arria10.c                | 1 +
 drivers/clk/aspeed/clk_ast2500.c                | 1 +
 drivers/clk/at91/clk-generated.c                | 1 +
 drivers/clk/at91/clk-usb.c                      | 1 +
 drivers/clk/clk-composite.c                     | 2 ++
 drivers/clk/clk-divider.c                       | 2 ++
 drivers/clk/clk-fixed-factor.c                  | 2 ++
 drivers/clk/clk-gate.c                          | 2 ++
 drivers/clk/clk-mux.c                           | 2 ++
 drivers/clk/clk-ti-sci.c                        | 1 +
 drivers/clk/clk-uclass.c                        | 4 +++-
 drivers/clk/clk_fixed_factor.c                  | 1 +
 drivers/clk/clk_sandbox_ccf.c                   | 2 ++
 drivers/clk/clk_sandbox_test.c                  | 1 +
 drivers/clk/clk_versal.c                        | 1 +
 drivers/clk/clk_zynqmp.c                        | 1 +
 drivers/clk/imx/clk-composite-8m.c              | 2 ++
 drivers/clk/imx/clk-gate2.c                     | 2 ++
 drivers/clk/imx/clk-pfd.c                       | 2 ++
 drivers/clk/imx/clk-pll14xx.c                   | 2 ++
 drivers/clk/imx/clk-pllv3.c                     | 2 ++
 drivers/clk/meson/axg.c                         | 1 +
 drivers/clk/meson/g12a.c                        | 1 +
 drivers/clk/meson/gxbb.c                        | 1 +
 drivers/clk/rockchip/clk_rk3188.c               | 1 +
 drivers/clk/rockchip/clk_rk3288.c               | 1 +
 drivers/clk/sifive/fu540-prci.c                 | 1 +
 drivers/core/devres.c                           | 1 +
 drivers/dfu/dfu_mtd.c                           | 1 +
 drivers/dma/ti/k3-udma.c                        | 3 ++-
 drivers/firmware/ti_sci.c                       | 1 +
 drivers/gpio/dwapb_gpio.c                       | 1 +
 drivers/gpio/mscc_sgpio.c                       | 1 +
 drivers/i2c/ast_i2c.c                           | 1 +
 drivers/i2c/designware_i2c.c                    | 1 +
 drivers/i2c/meson_i2c.c                         | 1 +
 drivers/i2c/muxes/i2c-mux-gpio.c                | 1 +
 drivers/i2c/tegra_i2c.c                         | 1 +
 drivers/misc/microchip_flexcom.c                | 1 +
 drivers/misc/tegra186_bpmp.c                    | 1 +
 drivers/mmc/am654_sdhci.c                       | 1 +
 drivers/mmc/aspeed_sdhci.c                      | 1 +
 drivers/mmc/fsl_esdhc_imx.c                     | 1 +
 drivers/mmc/omap_hsmmc.c                        | 2 ++
 drivers/mmc/rockchip_sdhci.c                    | 1 +
 drivers/mmc/tegra_mmc.c                         | 1 +
 drivers/mmc/zynq_sdhci.c                        | 1 +
 drivers/mtd/mtd_uboot.c                         | 1 +
 drivers/mtd/mtdconcat.c                         | 1 +
 drivers/mtd/mtdcore.c                           | 1 +
 drivers/mtd/mtdpart.c                           | 1 +
 drivers/mtd/nand/bbt.c                          | 1 +
 drivers/mtd/nand/raw/atmel_nand.c               | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c   | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c    | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c    | 1 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c        | 2 ++
 drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c | 1 +
 drivers/mtd/nand/raw/denali.c                   | 2 ++
 drivers/mtd/nand/raw/fsl_elbc_nand.c            | 1 +
 drivers/mtd/nand/raw/fsl_ifc_nand.c             | 1 +
 drivers/mtd/nand/raw/mxs_nand_spl.c             | 1 +
 drivers/mtd/nand/raw/nand_base.c                | 1 +
 drivers/mtd/nand/raw/nand_bbt.c                 | 1 +
 drivers/mtd/nand/raw/nand_bch.c                 | 1 +
 drivers/mtd/nand/raw/nand_timings.c             | 1 +
 drivers/mtd/nand/raw/nand_util.c                | 1 +
 drivers/mtd/nand/raw/pxa3xx_nand.c              | 2 ++
 drivers/mtd/nand/raw/stm32_fmc2_nand.c          | 1 +
 drivers/mtd/nand/raw/sunxi_nand.c               | 2 ++
 drivers/mtd/nand/spi/core.c                     | 1 +
 drivers/mtd/onenand/onenand_base.c              | 1 +
 drivers/mtd/spi/spi-nor-core.c                  | 1 +
 drivers/mtd/ubi/attach.c                        | 1 +
 drivers/mtd/ubi/build.c                         | 1 +
 drivers/mtd/ubi/debug.c                         | 1 +
 drivers/mtd/ubi/eba.c                           | 1 +
 drivers/mtd/ubi/fastmap.c                       | 2 ++
 drivers/mtd/ubi/io.c                            | 1 +
 drivers/mtd/ubi/kapi.c                          | 1 +
 drivers/mtd/ubi/vmt.c                           | 1 +
 drivers/mtd/ubi/vtbl.c                          | 1 +
 drivers/mtd/ubi/wl.c                            | 1 +
 drivers/net/designware.c                        | 1 +
 drivers/net/dwmac_socfpga.c                     | 1 +
 drivers/net/mvneta.c                            | 1 +
 drivers/net/mvpp2.c                             | 2 ++
 drivers/net/phy/dp83867.c                       | 1 +
 drivers/net/sni_ave.c                           | 1 +
 drivers/net/zynq_gem.c                          | 1 +
 drivers/pci/pcie_dw_ti.c                        | 1 +
 drivers/pci/pcie_mediatek.c                     | 1 +
 drivers/phy/allwinner/phy-sun4i-usb.c           | 1 +
 drivers/phy/marvell/comphy_core.c               | 1 +
 drivers/phy/omap-usb2-phy.c                     | 1 +
 drivers/phy/phy-mtk-tphy.c                      | 1 +
 drivers/phy/phy-ti-am654.c                      | 1 +
 drivers/phy/ti-pipe3-phy.c                      | 1 +
 drivers/pinctrl/intel/pinctrl.c                 | 1 +
 drivers/pinctrl/mscc/mscc-common.c              | 1 +
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c     | 1 +
 drivers/pinctrl/nxp/pinctrl-imx.c               | 1 +
 drivers/pinctrl/nxp/pinctrl-mxs.c               | 1 +
 drivers/pinctrl/pinctrl_stm32.c                 | 1 +
 drivers/pinctrl/renesas/pfc.c                   | 1 +
 drivers/power/domain/meson-ee-pwrc.c            | 1 +
 drivers/power/domain/meson-gx-pwrc-vpu.c        | 1 +
 drivers/power/domain/mtk-power-domain.c         | 1 +
 drivers/power/domain/ti-sci-power-domain.c      | 1 +
 drivers/power/regulator/pbias_regulator.c       | 1 +
 drivers/ram/rockchip/dmc-rk3368.c               | 1 +
 drivers/remoteproc/rproc-elf-loader.c           | 1 +
 drivers/remoteproc/stm32_copro.c                | 1 +
 drivers/remoteproc/ti_k3_arm64_rproc.c          | 1 +
 drivers/remoteproc/ti_k3_dsp_rproc.c            | 1 +
 drivers/remoteproc/ti_k3_r5f_rproc.c            | 1 +
 drivers/reset/reset-mediatek.c                  | 1 +
 drivers/reset/reset-ti-sci.c                    | 1 +
 drivers/reset/reset-uclass.c                    | 1 +
 drivers/serial/ns16550.c                        | 1 +
 drivers/serial/serial_mtk.c                     | 3 ++-
 drivers/serial/serial_omap.c                    | 1 +
 drivers/serial/serial_sifive.c                  | 1 +
 drivers/serial/serial_zynq.c                    | 1 +
 drivers/smem/msm_smem.c                         | 2 ++
 drivers/soc/ti/k3-navss-ringacc.c               | 2 ++
 drivers/spi/atmel-quadspi.c                     | 1 +
 drivers/spi/cadence_qspi.c                      | 1 +
 drivers/spi/spi-mem.c                           | 1 +
 drivers/spi/ti_qspi.c                           | 1 +
 drivers/spi/zynqmp_gqspi.c                      | 1 +
 drivers/sysreset/sysreset-ti-sci.c              | 1 +
 drivers/sysreset/sysreset_syscon.c              | 1 +
 drivers/tee/optee/core.c                        | 1 +
 drivers/timer/ast_timer.c                       | 1 +
 drivers/timer/cadence-ttc.c                     | 1 +
 drivers/timer/timer-uclass.c                    | 1 +
 drivers/ufs/cdns-platform.c                     | 1 +
 drivers/ufs/ti-j721e-ufs.c                      | 1 +
 drivers/ufs/ufs.c                               | 1 +
 drivers/usb/cdns3/core.c                        | 1 +
 drivers/usb/cdns3/gadget.c                      | 2 ++
 drivers/usb/cdns3/host.c                        | 1 +
 drivers/usb/dwc3/core.c                         | 2 ++
 drivers/usb/dwc3/dwc3-omap.c                    | 1 +
 drivers/usb/dwc3/gadget.c                       | 1 +
 drivers/usb/dwc3/ti_usb_phy.c                   | 1 +
 drivers/usb/gadget/at91_udc.c                   | 2 ++
 drivers/usb/gadget/composite.c                  | 1 +
 drivers/usb/gadget/dwc2_udc_otg.c               | 1 +
 drivers/usb/gadget/f_mass_storage.c             | 1 +
 drivers/usb/gadget/pxa25x_udc.c                 | 1 +
 drivers/usb/gadget/udc/udc-core.c               | 1 +
 drivers/usb/host/ehci-generic.c                 | 1 +
 drivers/usb/host/ohci-da8xx.c                   | 1 +
 drivers/usb/host/ohci-generic.c                 | 1 +
 drivers/usb/musb-new/am35x.c                    | 1 +
 drivers/usb/musb-new/musb_core.c                | 1 +
 drivers/usb/musb-new/musb_dsps.c                | 1 +
 drivers/usb/musb-new/musb_gadget.c              | 1 +
 drivers/usb/musb-new/musb_host.c                | 1 +
 drivers/usb/musb-new/musb_uboot.c               | 1 +
 drivers/usb/musb-new/omap2430.c                 | 1 +
 drivers/video/exynos/exynos_mipi_dsi.c          | 1 +
 drivers/video/mipi_dsi.c                        | 1 +
 drivers/video/rockchip/rk3288_mipi.c            | 1 +
 drivers/video/rockchip/rk3399_mipi.c            | 1 +
 drivers/video/rockchip/rk_vop.c                 | 1 +
 drivers/video/tegra124/sor.c                    | 1 +
 drivers/virtio/virtio_mmio.c                    | 1 +
 drivers/virtio/virtio_pci_legacy.c              | 1 +
 drivers/virtio/virtio_pci_modern.c              | 1 +
 drivers/virtio/virtio_sandbox.c                 | 1 +
 drivers/watchdog/ast_wdt.c                      | 1 +
 drivers/watchdog/cdns_wdt.c                     | 1 +
 drivers/watchdog/sp805_wdt.c                    | 1 +
 drivers/watchdog/xilinx_tb_wdt.c                | 1 +
 fs/ubifs/debug.c                                | 1 +
 fs/ubifs/gc.c                                   | 1 +
 fs/ubifs/io.c                                   | 1 +
 fs/ubifs/log.c                                  | 1 +
 fs/ubifs/lpt.c                                  | 1 +
 fs/ubifs/lpt_commit.c                           | 1 +
 fs/ubifs/master.c                               | 1 +
 fs/ubifs/orphan.c                               | 1 +
 fs/ubifs/recovery.c                             | 1 +
 fs/ubifs/replay.c                               | 1 +
 fs/ubifs/sb.c                                   | 1 +
 fs/ubifs/scan.c                                 | 1 +
 fs/ubifs/super.c                                | 1 +
 fs/ubifs/tnc.c                                  | 1 +
 fs/ubifs/tnc_misc.c                             | 1 +
 fs/ubifs/ubifs.c                                | 1 +
 fs/yaffs2/yaffs_allocator.c                     | 1 +
 fs/yaffs2/yaffs_checkptrw.c                     | 1 +
 fs/yaffs2/yaffs_guts.c                          | 1 +
 fs/yaffs2/yaffs_summary.c                       | 1 +
 fs/yaffs2/yaffs_yaffs1.c                        | 1 +
 fs/yaffs2/yaffs_yaffs2.c                        | 1 +
 fs/yaffs2/yaffsfs.c                             | 1 +
 include/dm/device.h                             | 2 --
 include/dm/devres.h                             | 4 ++++
 lib/bch.c                                       | 1 +
 lib/crypto/asymmetric_type.c                    | 2 ++
 lib/crypto/pkcs7_parser.c                       | 1 +
 lib/crypto/public_key.c                         | 2 ++
 lib/crypto/x509_cert_parser.c                   | 1 +
 lib/crypto/x509_public_key.c                    | 2 ++
 lib/list_sort.c                                 | 1 +
 test/dm/devres.c                                | 1 +
 test/dm/regmap.c                                | 1 +
 test/dm/syscon.c                                | 1 +
 test/dm/test-fdt.c                              | 1 +
 242 files changed, 275 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
index 7d864a4088..3e9f5e57ed 100644
--- a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
+++ b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/scu_ast2500.h>
+#include <linux/err.h>
 
 int ast_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c
index 334cc0766e..a1c265f46f 100644
--- a/arch/arm/mach-imx/cmd_nandbcb.c
+++ b/arch/arm/mach-imx/cmd_nandbcb.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <nand.h>
+#include <dm/devres.h>
 
 #include <asm/io.h>
 #include <jffs2/jffs2.h>
diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
index 0d3b40a249..4b88afa9b7 100644
--- a/arch/arm/mach-meson/board-info.c
+++ b/arch/arm/mach-meson/board-info.c
@@ -10,6 +10,7 @@
 #include <linux/bitfield.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 #define AO_SEC_SD_CFG8		0xe0
 #define AO_SEC_SOCINFO_OFFSET	AO_SEC_SD_CFG8
diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
index fabcb3bfd7..fac286b9c8 100644
--- a/arch/arm/mach-meson/sm.c
+++ b/arch/arm/mach-meson/sm.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <asm/arch/sm.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <dm.h>
 #include <linux/bitfield.h>
diff --git a/arch/arm/mach-rockchip/px30/clk_px30.c b/arch/arm/mach-rockchip/px30/clk_px30.c
index 0bd6b471da..98a1bcd224 100644
--- a/arch/arm/mach-rockchip/px30/clk_px30.c
+++ b/arch/arm/mach-rockchip/px30/clk_px30.c
@@ -8,6 +8,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_px30.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
index 20e2ed6813..5d0def3b52 100644
--- a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
+++ b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3036.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
index 827750bf98..f9ce1f7234 100644
--- a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
+++ b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
@@ -8,6 +8,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3128.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
index 9d4fc37eda..a0dcac3732 100644
--- a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
+++ b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3188.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3188/rk3188.c b/arch/arm/mach-rockchip/rk3188/rk3188.c
index 61d410d780..e52466fb6f 100644
--- a/arch/arm/mach-rockchip/rk3188/rk3188.c
+++ b/arch/arm/mach-rockchip/rk3188/rk3188.c
@@ -11,6 +11,7 @@
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/grf_rk3188.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <linux/err.h>
 
 #define GRF_BASE	0x20008000
 
diff --git a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
index 958c7b82b9..fc5abd736e 100644
--- a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
+++ b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
@@ -8,6 +8,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk322x.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
index 1730f12443..e05bd06a8d 100644
--- a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 18ea7f35fb..6088911a1b 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -17,6 +17,7 @@
 #include <asm/arch-rockchip/pmu_rk3288.h>
 #include <asm/arch-rockchip/qos_rk3288.h>
 #include <asm/arch-rockchip/sdram.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
index 51b43153e8..1feb237224 100644
--- a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
+++ b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
@@ -8,6 +8,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch/cru_rk3308.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
index f64f0cbbe5..e5375514de 100644
--- a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
+++ b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3328.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
index 55e5dd768a..9a33c67bc9 100644
--- a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
+++ b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3368.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
index a80a46f1db..d23a5e9435 100644
--- a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
+#include <linux/err.h>
 
 static int rockchip_get_cruclk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
index 58a7e889cc..b37ae1c494 100644
--- a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
+++ b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rv1108.h>
+#include <linux/err.h>
 
 int rockchip_get_clk(struct udevice **devp)
 {
diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
index 9484645dbd..977cc7d348 100644
--- a/arch/arm/mach-stm32mp/pwr_regulator.c
+++ b/arch/arm/mach-stm32mp/pwr_regulator.c
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <linux/err.h>
 #include <power/pmic.h>
 #include <power/regulator.h>
 
diff --git a/arch/riscv/lib/andes_plic.c b/arch/riscv/lib/andes_plic.c
index 3868569a65..20529ab3eb 100644
--- a/arch/riscv/lib/andes_plic.c
+++ b/arch/riscv/lib/andes_plic.c
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/syscon.h>
 #include <cpu.h>
+#include <linux/err.h>
 
 /* pending register */
 #define PENDING_REG(base, hart)	((ulong)(base) + 0x1000 + ((hart) / 4) * 4)
diff --git a/arch/riscv/lib/andes_plmt.c b/arch/riscv/lib/andes_plmt.c
index 84f4607500..a7e90ca992 100644
--- a/arch/riscv/lib/andes_plmt.c
+++ b/arch/riscv/lib/andes_plmt.c
@@ -13,6 +13,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/syscon.h>
+#include <linux/err.h>
 
 /* mtime register */
 #define MTIME_REG(base)			((ulong)(base))
diff --git a/arch/riscv/lib/sifive_clint.c b/arch/riscv/lib/sifive_clint.c
index d7899d16d7..5e0d25720b 100644
--- a/arch/riscv/lib/sifive_clint.c
+++ b/arch/riscv/lib/sifive_clint.c
@@ -13,6 +13,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/syscon.h>
+#include <linux/err.h>
 
 /* MSIP registers */
 #define MSIP_REG(base, hart)		((ulong)(base) + (hart) * 4)
diff --git a/board/google/veyron/veyron.c b/board/google/veyron/veyron.c
index dd2c014c60..6b9c34818b 100644
--- a/board/google/veyron/veyron.c
+++ b/board/google/veyron/veyron.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <asm/arch-rockchip/clock.h>
 #include <dt-bindings/clock/rk3288-cru.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 
 /*
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index e82a43074f..9ee2e0b3d3 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -32,6 +32,7 @@
 #include <asm/arch/stm32.h>
 #include <asm/arch/sys_proto.h>
 #include <jffs2/load_kernel.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 #include <usb/dwc2_udc.h>
 
diff --git a/cmd/gpio.c b/cmd/gpio.c
index eff36ab2af..5f4c7ff114 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include <dm.h>
 #include <asm/gpio.h>
+#include <linux/err.h>
 
 __weak int name_to_gpio(const char *name)
 {
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 964702bad4..efaf1bcecb 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -20,6 +20,7 @@
 #include <div64.h>
 #include <memalign.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/sizes.h>
 #include <stdlib.h>
 
diff --git a/cmd/mtd.c b/cmd/mtd.c
index a559b5a4a3..f407c5e445 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -14,6 +14,8 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <mtd.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 
 #include <linux/ctype.h>
 
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 22ba5b1a2c..7fb4cdfc2a 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -19,6 +19,7 @@
 #include <mtd.h>
 #include <nand.h>
 #include <onenand_uboot.h>
+#include <dm/devres.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/err.h>
diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
index ed773b9642..850142cce3 100644
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -11,6 +11,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <asm/io.h>
+#include <linux/err.h>
 
 #define SARADC_CTRL_CHN_MASK		GENMASK(2, 0)
 #define SARADC_CTRL_POWER_CTRL		BIT(3)
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index ca8978f0e1..7771114491 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -10,6 +10,7 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 
 static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[IF_TYPE_IDE]		= "ide",
diff --git a/drivers/clk/altera/clk-arria10.c b/drivers/clk/altera/clk-arria10.c
index 179869df45..a39cd34fe5 100644
--- a/drivers/clk/altera/clk-arria10.c
+++ b/drivers/clk/altera/clk-arria10.c
@@ -7,6 +7,7 @@
 #include <asm/io.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/util.h>
 
diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
index b3a3f3d4dd..f4a441ad68 100644
--- a/drivers/clk/aspeed/clk_ast2500.c
+++ b/drivers/clk/aspeed/clk_ast2500.c
@@ -10,6 +10,7 @@
 #include <asm/arch/scu_ast2500.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/ast2500-scu.h>
+#include <linux/err.h>
 
 /*
  * MAC Clock Delay settings, taken from Aspeed SDK
diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index 70b277e26f..d8562e131d 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
index 24af183b55..c3cb2ba014 100644
--- a/drivers/clk/at91/clk-usb.c
+++ b/drivers/clk/at91/clk-usb.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index a5626c33d1..414185031e 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -9,8 +9,10 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
+#include <linux/err.h>
 
 #include "clk.h"
 
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 822e09b084..d79ae367b8 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -14,10 +14,12 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <dm/uclass.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 #include <linux/clk-provider.h>
+#include <linux/err.h>
 #include <linux/log2.h>
 #include <div64.h>
 #include <clk.h>
diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 711b0588bc..2ceb6bb171 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -9,10 +9,12 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <div64.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_IMX_FIXED_FACTOR "ccf_clk_fixed_factor"
 
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
index 70b8794554..6415c2f1b9 100644
--- a/drivers/clk/clk-gate.c
+++ b/drivers/clk/clk-gate.c
@@ -12,9 +12,11 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_GATE "clk_gate"
 
diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 5acc0b8cbd..b9d2ae6778 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -26,9 +26,11 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_CCF_MUX "ccf_clk_mux"
 
diff --git a/drivers/clk/clk-ti-sci.c b/drivers/clk/clk-ti-sci.c
index 8212435ba8..b085a4fc14 100644
--- a/drivers/clk/clk-ti-sci.c
+++ b/drivers/clk/clk-ti-sci.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <clk-uclass.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <k3-avs.h>
 
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 49fa60eb7c..6787d2569c 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -10,10 +10,12 @@
 #include <clk.h>
 #include <clk-uclass.h>
 #include <dm.h>
-#include <dm/read.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <dm/devres.h>
+#include <dm/read.h>
 #include <linux/clk-provider.h>
+#include <linux/err.h>
 
 static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
 {
diff --git a/drivers/clk/clk_fixed_factor.c b/drivers/clk/clk_fixed_factor.c
index dcdb6ddf5c..cf9c4ae367 100644
--- a/drivers/clk/clk_fixed_factor.c
+++ b/drivers/clk/clk_fixed_factor.c
@@ -9,6 +9,7 @@
 #include <clk-uclass.h>
 #include <div64.h>
 #include <dm.h>
+#include <linux/err.h>
 
 struct clk_fixed_factor {
 	struct clk parent;
diff --git a/drivers/clk/clk_sandbox_ccf.c b/drivers/clk/clk_sandbox_ccf.c
index 9fa27229e1..0903c817a6 100644
--- a/drivers/clk/clk_sandbox_ccf.c
+++ b/drivers/clk/clk_sandbox_ccf.c
@@ -11,8 +11,10 @@
 #include <clk.h>
 #include <asm/clk.h>
 #include <clk-uclass.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <sandbox-clk.h>
+#include <linux/err.h>
 
 /*
  * Sandbox implementation of CCF primitives necessary for clk-uclass testing
diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c
index 41954660ea..628110de3e 100644
--- a/drivers/clk/clk_sandbox_test.c
+++ b/drivers/clk/clk_sandbox_test.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <clk.h>
 #include <asm/clk.h>
+#include <linux/err.h>
 
 struct sandbox_clk_test {
 	struct clk clks[SANDBOX_CLK_TEST_NON_DEVM_COUNT];
diff --git a/drivers/clk/clk_versal.c b/drivers/clk/clk_versal.c
index 7e97b0c4bf..66cbef15ab 100644
--- a/drivers/clk/clk_versal.c
+++ b/drivers/clk/clk_versal.c
@@ -13,6 +13,7 @@
 #include <dm.h>
 #include <asm/arch/sys_proto.h>
 #include <zynqmp_firmware.h>
+#include <linux/err.h>
 
 #define MAX_PARENT			100
 #define MAX_NODES			6
diff --git a/drivers/clk/clk_zynqmp.c b/drivers/clk/clk_zynqmp.c
index 72fc39fa47..a365b565e1 100644
--- a/drivers/clk/clk_zynqmp.c
+++ b/drivers/clk/clk_zynqmp.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <asm/arch/sys_proto.h>
 #include <dm.h>
+#include <linux/err.h>
 
 static const resource_size_t zynqmp_crf_apb_clkc_base = 0xfd1a0020;
 static const resource_size_t zynqmp_crl_apb_clkc_base = 0xff5e0020;
diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index 95120d6559..3e99c528de 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -8,9 +8,11 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_IMX_COMPOSITE "imx_clk_composite"
 
diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c
index 1b9db6e791..b38890d5ba 100644
--- a/drivers/clk/imx/clk-gate2.c
+++ b/drivers/clk/imx/clk-gate2.c
@@ -19,9 +19,11 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_IMX_GATE2 "imx_clk_gate2"
 
diff --git a/drivers/clk/imx/clk-pfd.c b/drivers/clk/imx/clk-pfd.c
index 4ae55f5a07..b8be3167c4 100644
--- a/drivers/clk/imx/clk-pfd.c
+++ b/drivers/clk/imx/clk-pfd.c
@@ -19,10 +19,12 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
 #include <div64.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_IMX_PFD "imx_clk_pfd"
 
diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
index 2246beb21b..1673eb26b2 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -10,7 +10,9 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/clk-provider.h>
+#include <linux/err.h>
 #include <linux/iopoll.h>
 #include <clk.h>
 #include <div64.h>
diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 0cdb9df45d..525442debf 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -10,9 +10,11 @@
 #include <malloc.h>
 #include <clk-uclass.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <dm/uclass.h>
 #include <clk.h>
 #include "clk.h"
+#include <linux/err.h>
 
 #define UBOOT_DM_CLK_IMX_PLLV3_GENERIC	"imx_clk_pllv3_generic"
 #define UBOOT_DM_CLK_IMX_PLLV3_SYS	"imx_clk_pllv3_sys"
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 32cbf752ae..7035b59a13 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -15,6 +15,7 @@
 #include <div64.h>
 #include <dt-bindings/clock/axg-clkc.h>
 #include "clk_meson.h"
+#include <linux/err.h>
 
 #define XTAL_RATE 24000000
 
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index 1b2523bbf1..686d94ebfe 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -14,6 +14,7 @@
 #include <syscon.h>
 #include <div64.h>
 #include <dt-bindings/clock/g12a-clkc.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include "clk_meson.h"
 
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index abb5337e78..e781e08d9d 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -15,6 +15,7 @@
 #include <syscon.h>
 #include <dt-bindings/clock/gxbb-clkc.h>
 #include "clk_meson.h"
+#include <linux/err.h>
 
 /* This driver support only basic clock tree operations :
  * - Can calculate clock frequency on a limited tree
diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c
index 3ea9a81b32..82eea40063 100644
--- a/drivers/clk/rockchip/clk_rk3188.c
+++ b/drivers/clk/rockchip/clk_rk3188.c
@@ -20,6 +20,7 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <linux/log2.h>
 
 enum rk3188_clk_type {
diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c
index cc1c1e81e9..2d42f6ffc5 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -21,6 +21,7 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <linux/log2.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c
index ce0769f2d1..8847178001 100644
--- a/drivers/clk/sifive/fu540-prci.c
+++ b/drivers/clk/sifive/fu540-prci.c
@@ -35,6 +35,7 @@
 #include <div64.h>
 #include <dm.h>
 #include <errno.h>
+#include <linux/err.h>
 
 #include <linux/math64.h>
 #include <linux/clk/analogbits-wrpll-cln28hpc.h>
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 237b42653c..d98e80de26 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <dm/root.h>
 #include <dm/util.h>
 
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index 9528a7b4ee..36cd4e945b 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -11,6 +11,7 @@
 #include <dfu.h>
 #include <mtd.h>
 #include <jffs2/load_kernel.h>
+#include <linux/err.h>
 
 static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
 {
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 5820c8270b..ab516b573c 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -12,7 +12,7 @@
 #include <malloc.h>
 #include <asm/dma-mapping.h>
 #include <dm.h>
-#include <dm/device.h>
+#include <dm/devres.h>
 #include <dm/read.h>
 #include <dm/of_access.h>
 #include <dma.h>
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <dt-bindings/dma/k3-udma.h>
 #include <linux/bitmap.h>
+#include <linux/err.h>
 #include <linux/soc/ti/k3-navss-ringacc.h>
 #include <linux/soc/ti/cppi5.h>
 #include <linux/soc/ti/ti-udma.h>
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 62b1dc2006..5e37ee0570 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -12,6 +12,7 @@
 #include <errno.h>
 #include <mailbox.h>
 #include <dm/device.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/k3-sec-proxy.h>
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 2eb1547b4f..58e3e7b1f7 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <errno.h>
diff --git a/drivers/gpio/mscc_sgpio.c b/drivers/gpio/mscc_sgpio.c
index c899454ec4..3378ebb442 100644
--- a/drivers/gpio/mscc_sgpio.c
+++ b/drivers/gpio/mscc_sgpio.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <errno.h>
 #include <clk.h>
+#include <linux/err.h>
 
 #define MSCC_SGPIOS_PER_BANK	32
 #define MSCC_SGPIO_BANK_DEPTH	4
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 35dc234160..c84d75ac92 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -13,6 +13,7 @@
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/scu_ast2500.h>
+#include <linux/err.h>
 
 #include "ast_i2c.h"
 
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index c8c5d2c331..ae9cf16297 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -12,6 +12,7 @@
 #include <reset.h>
 #include <asm/io.h>
 #include "designware_i2c.h"
+#include <linux/err.h>
 
 #ifdef CONFIG_SYS_I2C_DW_ENABLE_STATUS_UNSUPPORTED
 static int  dw_i2c_enable(struct i2c_regs *i2c_base, bool enable)
diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
index ee59bac123..bcf45160d8 100644
--- a/drivers/i2c/meson_i2c.c
+++ b/drivers/i2c/meson_i2c.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <i2c.h>
+#include <linux/err.h>
 
 #define I2C_TIMEOUT_MS		100
 
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index e8b124f4f5..29e283ce25 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -11,6 +11,7 @@
 #include <asm-generic/gpio.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/pinctrl.h>
 #include <fdtdec.h>
 #include <i2c.h>
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 4be41ddbf0..f37db31c3c 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -18,6 +18,7 @@
 #endif
 #include <asm/arch/gpio.h>
 #include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/err.h>
 
 enum i2c_type {
 	TYPE_114,
diff --git a/drivers/misc/microchip_flexcom.c b/drivers/misc/microchip_flexcom.c
index 1bc19edfcb..4cff160d88 100644
--- a/drivers/misc/microchip_flexcom.c
+++ b/drivers/misc/microchip_flexcom.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <misc.h>
 #include <asm/io.h>
+#include <linux/err.h>
 
 struct microchip_flexcom_regs {
 	u32 cr;
diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c
index 89e27dd526..489337c3d0 100644
--- a/drivers/misc/tegra186_bpmp.c
+++ b/drivers/misc/tegra186_bpmp.c
@@ -12,6 +12,7 @@
 #include <misc.h>
 #include <asm/arch-tegra/bpmp_abi.h>
 #include <asm/arch-tegra/ivc.h>
+#include <linux/err.h>
 
 #define BPMP_IVC_FRAME_COUNT 1
 #define BPMP_IVC_FRAME_SIZE 128
diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c
index 41a90834ff..6053d3d536 100644
--- a/drivers/mmc/am654_sdhci.c
+++ b/drivers/mmc/am654_sdhci.c
@@ -12,6 +12,7 @@
 #include <power-domain.h>
 #include <regmap.h>
 #include <sdhci.h>
+#include <linux/err.h>
 
 /* CTL_CFG Registers */
 #define CTL_CFG_2		0x14
diff --git a/drivers/mmc/aspeed_sdhci.c b/drivers/mmc/aspeed_sdhci.c
index 1321ec37e1..8929e603f3 100644
--- a/drivers/mmc/aspeed_sdhci.c
+++ b/drivers/mmc/aspeed_sdhci.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <malloc.h>
 #include <sdhci.h>
+#include <linux/err.h>
 
 struct aspeed_sdhci_plat {
 	struct mmc_config cfg;
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 462ad2878a..7cbd6e4587 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -19,6 +19,7 @@
 #include <hwconfig.h>
 #include <mmc.h>
 #include <part.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 #include <malloc.h>
 #include <fsl_esdhc_imx.h>
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 5d0cfb2ebd..5334723a9f 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -47,6 +47,8 @@
 #include <asm/arch/mux.h>
 #endif
 #include <dm.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 #include <thermal.h>
 
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index dd3d5574db..b440996b26 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dt-structs.h>
+#include <linux/err.h>
 #include <linux/libfdt.h>
 #include <malloc.h>
 #include <mapmem.h>
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index 22990fa98b..f022e93552 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -14,6 +14,7 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch-tegra/tegra_mmc.h>
+#include <linux/err.h>
 
 struct tegra_mmc_plat {
 	struct mmc_config cfg;
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 529eec9c45..83c32a361a 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include "mmc_private.h"
+#include <linux/err.h>
 #include <linux/libfdt.h>
 #include <malloc.h>
 #include <sdhci.h>
diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index 8aeccb016d..17df8b0ffc 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -7,6 +7,7 @@
 #include <env.h>
 #include <dm/device.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <mtd.h>
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 592f58dcd3..5621c3fd26 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -10,6 +10,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 838c288318..f8d3f4d246 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/ptrace.h>
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index fd8d8e5ea7..56acdbf65b 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
index f3d05e6757..133670cb19 100644
--- a/drivers/mtd/nand/bbt.c
+++ b/drivers/mtd/nand/bbt.c
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt)	"nand-bbt: " fmt
 
 #include <common.h>
+#include <dm/devres.h>
 #include <linux/mtd/nand.h>
 #ifndef __UBOOT__
 #include <linux/slab.h>
diff --git a/drivers/mtd/nand/raw/atmel_nand.c b/drivers/mtd/nand/raw/atmel_nand.c
index 31ad2cfa88..3526585349 100644
--- a/drivers/mtd/nand/raw/atmel_nand.c
+++ b/drivers/mtd/nand/raw/atmel_nand.c
@@ -13,6 +13,7 @@
 #include <common.h>
 #include <asm/gpio.h>
 #include <asm/arch/gpio.h>
+#include <dm/devres.h>
 
 #include <malloc.h>
 #include <nand.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
index 16b0d4440a..ea7c65a1f6 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
@@ -4,6 +4,7 @@
 #include <asm/io.h>
 #include <memalign.h>
 #include <nand.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
index ece944485c..3a136155dd 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
@@ -4,6 +4,7 @@
 #include <asm/io.h>
 #include <memalign.h>
 #include <nand.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
index 3586baa4fa..6aca011db2 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
@@ -4,6 +4,7 @@
 #include <asm/io.h>
 #include <memalign.h>
 #include <nand.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 0745929253..d3e39661e1 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -17,6 +17,8 @@
 #include <memalign.h>
 #include <nand.h>
 #include <clk.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <linux/ioport.h>
 #include <linux/completion.h>
 #include <linux/errno.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
index 883948355c..bb8aea2d01 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include "brcmnand_compat.h"
+#include <dm/devres.h>
 
 static char *devm_kvasprintf(struct udevice *dev, gfp_t gfp, const char *fmt,
 			     va_list ap)
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index b5a98f52f8..235a5fcd52 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -8,8 +8,10 @@
 #include <asm/dma-mapping.h>
 #include <dm.h>
 #include <nand.h>
+#include <dm/devres.h>
 #include <linux/bitfield.h>
 #include <linux/dma-direction.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/raw/fsl_elbc_nand.c b/drivers/mtd/nand/raw/fsl_elbc_nand.c
index cbf689af63..0c1bd7b474 100644
--- a/drivers/mtd/nand/raw/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/raw/fsl_elbc_nand.c
@@ -11,6 +11,7 @@
 #include <command.h>
 #include <malloc.h>
 #include <nand.h>
+#include <dm/devres.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c
index e2419e18a9..cf20238782 100644
--- a/drivers/mtd/nand/raw/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c
@@ -10,6 +10,7 @@
 #include <command.h>
 #include <malloc.h>
 #include <nand.h>
+#include <dm/devres.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c
index 975a91a37d..a653dfa5ed 100644
--- a/drivers/mtd/nand/raw/mxs_nand_spl.c
+++ b/drivers/mtd/nand/raw/mxs_nand_spl.c
@@ -7,6 +7,7 @@
 #include <nand.h>
 #include <malloc.h>
 #include <mxs_nand.h>
+#include <linux/err.h>
 
 static struct mtd_info *mtd;
 static struct nand_chip nand_chip;
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index aba8ac019d..49d5e261b5 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -34,6 +34,7 @@
 #endif
 #include <malloc.h>
 #include <watchdog.h>
+#include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/compat.h>
 #include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c
index ba785c5d53..a6e6e0ef6d 100644
--- a/drivers/mtd/nand/raw/nand_bbt.c
+++ b/drivers/mtd/nand/raw/nand_bbt.c
@@ -59,6 +59,7 @@
 
 #include <common.h>
 #include <malloc.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/bbm.h>
diff --git a/drivers/mtd/nand/raw/nand_bch.c b/drivers/mtd/nand/raw/nand_bch.c
index afa0418168..11a22e021d 100644
--- a/drivers/mtd/nand/raw/nand_bch.c
+++ b/drivers/mtd/nand/raw/nand_bch.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <dm/devres.h>
 /*#include <asm/io.h>*/
 #include <linux/types.h>
 
diff --git a/drivers/mtd/nand/raw/nand_timings.c b/drivers/mtd/nand/raw/nand_timings.c
index c0545a4fb1..e6aa790391 100644
--- a/drivers/mtd/nand/raw/nand_timings.c
+++ b/drivers/mtd/nand/raw/nand_timings.c
@@ -9,6 +9,7 @@
  *
  */
 #include <common.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/mtd/rawnand.h>
 
diff --git a/drivers/mtd/nand/raw/nand_util.c b/drivers/mtd/nand/raw/nand_util.c
index fc2235c1a0..f3c8f7f2cb 100644
--- a/drivers/mtd/nand/raw/nand_util.c
+++ b/drivers/mtd/nand/raw/nand_util.c
@@ -24,6 +24,7 @@
 #include <malloc.h>
 #include <memalign.h>
 #include <div64.h>
+#include <dm/devres.h>
 
 #include <linux/errno.h>
 #include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c
index 4d2712df4c..e179a780db 100644
--- a/drivers/mtd/nand/raw/pxa3xx_nand.c
+++ b/drivers/mtd/nand/raw/pxa3xx_nand.c
@@ -10,6 +10,8 @@
 #include <malloc.h>
 #include <fdtdec.h>
 #include <nand.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index f3179cc21f..1c212daa1d 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <nand.h>
 #include <reset.h>
+#include <linux/err.h>
 #include <linux/iopoll.h>
 #include <linux/ioport.h>
 
diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 3ccb168d13..cd5c31e76b 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -28,6 +28,8 @@
 #include <fdtdec.h>
 #include <memalign.h>
 #include <nand.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 
 #include <linux/kernel.h>
 #include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index fba8cc056a..d976c19b7a 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <dm/devres.h>
 #include <linux/mtd/spinand.h>
 #endif
 
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 371e2ecaa7..693bb78b87 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -21,6 +21,7 @@
 
 #include <common.h>
 #include <watchdog.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include "linux/mtd/flashchip.h"
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index d7020c190b..b27e442218 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/log2.h>
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 19defd8831..f02a06fc35 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -70,6 +70,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/crc32.h>
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 42c5270c7f..7de65bc7c3 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -17,6 +17,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/stringify.h>
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index f3d348da83..aec2613a09 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -10,6 +10,7 @@
 #include "ubi.h"
 #ifndef __UBOOT__
 #include <linux/debugfs.h>
+#include <linux/err.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #endif
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 0c8b998e7e..8428278e21 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -29,6 +29,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/slab.h>
 #include <linux/crc32.h>
 #include <u-boot/crc.h>
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 646c778e87..a3f5e3e1a9 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -7,7 +7,9 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
+#include <linux/err.h>
 #include <u-boot/crc.h>
 #else
 #include <div64.h>
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 608dede492..8ba22d8142 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -74,6 +74,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
 #include <linux/err.h>
 #include <linux/slab.h>
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index bcea71b1b2..41680cdad1 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -8,6 +8,7 @@
 /* This file mostly implements UBI kernel API functions */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/namei.h>
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index a2ff1b5769..2114abbe7c 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -11,6 +11,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/export.h>
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 9c46ef6695..123c2f344d 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -46,6 +46,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
 #include <linux/err.h>
 #include <linux/slab.h>
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 89ca90feb3..4038b7f04e 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -86,6 +86,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/slab.h>
 #include <linux/crc32.h>
 #include <linux/freezer.h>
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 19fc34f771..aa33fd511b 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -17,6 +17,7 @@
 #include <malloc.h>
 #include <pci.h>
 #include <reset.h>
+#include <dm/devres.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
diff --git a/drivers/net/dwmac_socfpga.c b/drivers/net/dwmac_socfpga.c
index b7bf5dbe69..66a5f95112 100644
--- a/drivers/net/dwmac_socfpga.c
+++ b/drivers/net/dwmac_socfpga.c
@@ -14,6 +14,7 @@
 #include <reset.h>
 #include <syscon.h>
 #include "designware.h"
+#include <linux/err.h>
 
 #include <asm/arch/system_manager.h>
 
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 5fe8500199..505fabd3fa 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <dm/devres.h>
 #include <linux/errno.h>
 #include <phy.h>
 #include <miiphy.h>
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index b234b41956..105fdc994a 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -17,12 +17,14 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <net.h>
 #include <netdev.h>
 #include <config.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <phy.h>
 #include <miiphy.h>
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index a43793cd42..08935d9c15 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <phy.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <malloc.h>
 
diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c
index 6d333e24ee..64e92abb03 100644
--- a/drivers/net/sni_ave.c
+++ b/drivers/net/sni_ave.c
@@ -8,6 +8,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <fdt_support.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <miiphy.h>
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index c3fe8e3c56..3d9d5205a1 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -25,6 +25,7 @@
 #include <asm/system.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 
 /* Bit/mask specification */
diff --git a/drivers/pci/pcie_dw_ti.c b/drivers/pci/pcie_dw_ti.c
index b37fc2de7f..199a3bb50a 100644
--- a/drivers/pci/pcie_dw_ti.c
+++ b/drivers/pci/pcie_dw_ti.c
@@ -12,6 +12,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm-generic/gpio.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/pci/pcie_mediatek.c b/drivers/pci/pcie_mediatek.c
index a0dcb258b0..1271227c6a 100644
--- a/drivers/pci/pcie_mediatek.c
+++ b/drivers/pci/pcie_mediatek.c
@@ -14,6 +14,7 @@
 #include <pci.h>
 #include <reset.h>
 #include <asm/io.h>
+#include <dm/devres.h>
 #include <linux/iopoll.h>
 #include <linux/list.h>
 
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index f7309057b9..2c12fa6976 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -21,6 +21,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <linux/err.h>
 
 #define REG_ISCR			0x00
 #define REG_PHYCTL_A10			0x04
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index 9c24692629..d52f42df84 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 
diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c
index 923f2c105d..160a386801 100644
--- a/drivers/phy/omap-usb2-phy.c
+++ b/drivers/phy/omap-usb2-phy.c
@@ -13,6 +13,7 @@
 #include <generic-phy.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT	BIT(0)
 
diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c
index fd33062ae4..255d722ff7 100644
--- a/drivers/phy/phy-mtk-tphy.c
+++ b/drivers/phy/phy-mtk-tphy.c
@@ -11,6 +11,7 @@
 #include <generic-phy.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <dm/devres.h>
 
 #include <dt-bindings/phy/phy.h>
 
diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
index 39490124ea..1c7db0dd0f 100644
--- a/drivers/phy/phy-ti-am654.c
+++ b/drivers/phy/phy-ti-am654.c
@@ -18,6 +18,7 @@
 #include <power-domain.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 #define CMU_R07C		0x7c
 #define CMU_MASTER_CDN_O	BIT(24)
diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c
index 0c59552bb8..7fc36319cb 100644
--- a/drivers/phy/ti-pipe3-phy.c
+++ b/drivers/phy/ti-pipe3-phy.c
@@ -12,6 +12,7 @@
 #include <asm/arch/sys_proto.h>
 #include <syscon.h>
 #include <regmap.h>
+#include <linux/err.h>
 
 /* PLLCTRL Registers */
 #define PLL_STATUS              0x00000004
diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c
index 4875a3b0b5..c4287ec406 100644
--- a/drivers/pinctrl/intel/pinctrl.c
+++ b/drivers/pinctrl/intel/pinctrl.c
@@ -28,6 +28,7 @@
 #include <asm/arch/itss.h>
 #include <dm/device-internal.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <linux/err.h>
 
 #define GPIO_DW_SIZE(x)			(sizeof(u32) * (x))
 #define PAD_CFG_OFFSET(x, dw_num)	((x) + GPIO_DW_SIZE(dw_num))
diff --git a/drivers/pinctrl/mscc/mscc-common.c b/drivers/pinctrl/mscc/mscc-common.c
index bd3e6ea328..2d76c41dea 100644
--- a/drivers/pinctrl/mscc/mscc-common.c
+++ b/drivers/pinctrl/mscc/mscc-common.c
@@ -14,6 +14,7 @@
 #include <config.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <dm/root.h>
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index f197f4a142..da1f091aec 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <dm/root.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c
index 69c4144365..77a8a53202 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <mapmem.h>
+#include <dm/devres.h>
 #include <linux/io.h>
 #include <linux/err.h>
 #include <dm.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-mxs.c b/drivers/pinctrl/nxp/pinctrl-mxs.c
index 6f6ca84674..5147bdc3cc 100644
--- a/drivers/pinctrl/nxp/pinctrl-mxs.c
+++ b/drivers/pinctrl/nxp/pinctrl-mxs.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <dm/devres.h>
 #include <linux/io.h>
 #include <linux/err.h>
 #include <dm.h>
diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index 3a235ae5a7..e0380c349a 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -6,6 +6,7 @@
 #include <asm/io.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index 5ec560ec0f..5ee11615de 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <dm/devres.h>
 #include <dm/pinctrl.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index 7f5d13e872..aa11866591 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -13,6 +13,7 @@
 #include <clk.h>
 #include <dt-bindings/power/meson-g12a-power.h>
 #include <dt-bindings/power/meson-sm1-power.h>
+#include <linux/err.h>
 
 /* AO Offsets */
 
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index bd69aea8dd..02f73548d6 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -13,6 +13,7 @@
 #include <syscon.h>
 #include <reset.h>
 #include <clk.h>
+#include <linux/err.h>
 
 enum {
 	VPU_PWRC_COMPATIBLE_GX		= 0,
diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index 6ea4fe9003..789fc5ab64 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -12,6 +12,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/processor.h>
+#include <linux/err.h>
 #include <linux/iopoll.h>
 
 #include <dt-bindings/power/mt7623-power.h>
diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c
index b59af2b13b..3866db589a 100644
--- a/drivers/power/domain/ti-sci-power-domain.c
+++ b/drivers/power/domain/ti-sci-power-domain.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <power-domain-uclass.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <dt-bindings/soc/ti,sci_pm_domain.h>
 
diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
index 88dc9f273a..60255eeab0 100644
--- a/drivers/power/regulator/pbias_regulator.c
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <errno.h>
 #include <dm.h>
+#include <linux/err.h>
 #include <power/pmic.h>
 #include <power/regulator.h>
 #include <regmap.h>
diff --git a/drivers/ram/rockchip/dmc-rk3368.c b/drivers/ram/rockchip/dmc-rk3368.c
index 8addee8cc3..2d82a176db 100644
--- a/drivers/ram/rockchip/dmc-rk3368.c
+++ b/drivers/ram/rockchip/dmc-rk3368.c
@@ -19,6 +19,7 @@
 #include <asm/arch-rockchip/ddr_rk3368.h>
 #include <asm/arch-rockchip/sdram.h>
 #include <asm/arch-rockchip/sdram_rk3288.h>
+#include <linux/err.h>
 
 struct dram_info {
 	struct ram_info info;
diff --git a/drivers/remoteproc/rproc-elf-loader.c b/drivers/remoteproc/rproc-elf-loader.c
index d234592445..bf44bebc02 100644
--- a/drivers/remoteproc/rproc-elf-loader.c
+++ b/drivers/remoteproc/rproc-elf-loader.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <elf.h>
 #include <remoteproc.h>
+#include <linux/err.h>
 
 /**
  * struct resource_table - firmware resource table header
diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c
index c25488f54d..80e8dffdbb 100644
--- a/drivers/remoteproc/stm32_copro.c
+++ b/drivers/remoteproc/stm32_copro.c
@@ -12,6 +12,7 @@
 #include <reset.h>
 #include <syscon.h>
 #include <asm/io.h>
+#include <linux/err.h>
 
 #define RCC_GCR_HOLD_BOOT	0
 #define RCC_GCR_RELEASE_BOOT	1
diff --git a/drivers/remoteproc/ti_k3_arm64_rproc.c b/drivers/remoteproc/ti_k3_arm64_rproc.c
index 3e35293514..d048cf4161 100644
--- a/drivers/remoteproc/ti_k3_arm64_rproc.c
+++ b/drivers/remoteproc/ti_k3_arm64_rproc.c
@@ -15,6 +15,7 @@
 #include <reset.h>
 #include <asm/io.h>
 #include <power-domain.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include "ti_sci_proc.h"
 
diff --git a/drivers/remoteproc/ti_k3_dsp_rproc.c b/drivers/remoteproc/ti_k3_dsp_rproc.c
index c5dc6b25da..913aca36d6 100644
--- a/drivers/remoteproc/ti_k3_dsp_rproc.c
+++ b/drivers/remoteproc/ti_k3_dsp_rproc.c
@@ -15,6 +15,7 @@
 #include <reset.h>
 #include <asm/io.h>
 #include <power-domain.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include "ti_sci_proc.h"
 
diff --git a/drivers/remoteproc/ti_k3_r5f_rproc.c b/drivers/remoteproc/ti_k3_r5f_rproc.c
index ae1e4b9e04..cecfb0ef86 100644
--- a/drivers/remoteproc/ti_k3_r5f_rproc.c
+++ b/drivers/remoteproc/ti_k3_r5f_rproc.c
@@ -13,6 +13,7 @@
 #include <clk.h>
 #include <reset.h>
 #include <asm/io.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include "ti_sci_proc.h"
diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c
index cfbf2af863..4684cbfb6a 100644
--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -12,6 +12,7 @@
 #include <regmap.h>
 #include <reset-uclass.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 struct mediatek_reset_priv {
 	struct regmap *regmap;
diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c
index 7b6f736f5e..99e3d9ad5c 100644
--- a/drivers/reset/reset-ti-sci.c
+++ b/drivers/reset/reset-ti-sci.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <reset-uclass.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
 /**
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index bf1cba4124..8e6c0a4fd0 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -8,6 +8,7 @@
 #include <fdtdec.h>
 #include <reset.h>
 #include <reset-uclass.h>
+#include <dm/devres.h>
 
 static inline struct reset_ops *reset_dev_ops(struct udevice *dev)
 {
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 9851663dc5..fdfe1f6bcc 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -13,6 +13,7 @@
 #include <reset.h>
 #include <serial.h>
 #include <watchdog.h>
+#include <linux/err.h>
 #include <linux/types.h>
 #include <asm/io.h>
 
diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c
index 18530a4fd1..e63f2306f0 100644
--- a/drivers/serial/serial_mtk.c
+++ b/drivers/serial/serial_mtk.c
@@ -15,6 +15,7 @@
 #include <watchdog.h>
 #include <asm/io.h>
 #include <asm/types.h>
+#include <linux/err.h>
 
 struct mtk_serial_regs {
 	u32 rbr;
@@ -454,4 +455,4 @@ static inline void _debug_uart_putc(int ch)
 
 DEBUG_UART_FUNCS
 
-#endif
\ No newline at end of file
+#endif
diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c
index a31d73766d..4d4d919358 100644
--- a/drivers/serial/serial_omap.c
+++ b/drivers/serial/serial_omap.c
@@ -12,6 +12,7 @@
 #include <ns16550.h>
 #include <serial.h>
 #include <clk.h>
+#include <linux/err.h>
 
 #ifndef CONFIG_SYS_NS16550_CLK
 #define CONFIG_SYS_NS16550_CLK  0
diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c
index c142ccdf3d..5a02f0c8fe 100644
--- a/drivers/serial/serial_sifive.c
+++ b/drivers/serial/serial_sifive.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <linux/compiler.h>
 #include <serial.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c
index 7e486a68ff..c07375901b 100644
--- a/drivers/serial/serial_zynq.c
+++ b/drivers/serial/serial_zynq.c
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <linux/compiler.h>
 #include <serial.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/smem/msm_smem.c b/drivers/smem/msm_smem.c
index 9fa653ad28..711ce626aa 100644
--- a/drivers/smem/msm_smem.c
+++ b/drivers/smem/msm_smem.c
@@ -8,9 +8,11 @@
 #include <common.h>
 #include <errno.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <asm/io.h>
+#include <linux/err.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <smem.h>
diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c
index 17949d2d0a..97c046b0c3 100644
--- a/drivers/soc/ti/k3-navss-ringacc.c
+++ b/drivers/soc/ti/k3-navss-ringacc.c
@@ -12,9 +12,11 @@
 #include <asm/dma-mapping.h>
 #include <asm/bitops.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/read.h>
 #include <dm/uclass.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/soc/ti/k3-navss-ringacc.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 7d9a54011d..195ea5fae6 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -15,6 +15,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/ioport.h>
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index f8b69406d4..0b503dd934 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -13,6 +13,7 @@
 #include <reset.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/sizes.h>
 #include "cadence_qspi.h"
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index cc358bd4f7..b8cf8dd76b 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -7,6 +7,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/dmaengine.h>
 #include <linux/pm_runtime.h>
 #include "internals.h"
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 664b9cad79..e3750b0b17 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -17,6 +17,7 @@
 #include <asm/omap_gpio.h>
 #include <asm/omap_common.h>
 #include <asm/ti-common/ti-edma3.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <regmap.h>
 #include <syscon.h>
diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index 4cca418012..c05d46e084 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -16,6 +16,7 @@
 #include <spi.h>
 #include <ubi_uboot.h>
 #include <wait_bit.h>
+#include <linux/err.h>
 
 #define GQSPI_GFIFO_STRT_MODE_MASK	BIT(29)
 #define GQSPI_CONFIG_MODE_EN_MASK	(3 << 30)
diff --git a/drivers/sysreset/sysreset-ti-sci.c b/drivers/sysreset/sysreset-ti-sci.c
index 890a607c4b..6caea3aab3 100644
--- a/drivers/sysreset/sysreset-ti-sci.c
+++ b/drivers/sysreset/sysreset-ti-sci.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <sysreset.h>
+#include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
 /**
diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c
index d0e586f66f..f64701aab3 100644
--- a/drivers/sysreset/sysreset_syscon.c
+++ b/drivers/sysreset/sysreset_syscon.c
@@ -13,6 +13,7 @@
 #include <regmap.h>
 #include <sysreset.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 struct syscon_reboot_priv {
 	struct regmap *regmap;
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 7f870f2f73..a7b175ee62 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -8,6 +8,7 @@
 #include <log.h>
 #include <tee.h>
 #include <linux/arm-smccc.h>
+#include <linux/err.h>
 #include <linux/io.h>
 
 #include "optee_smc.h"
diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c
index 21ffdbf575..3838601f54 100644
--- a/drivers/timer/ast_timer.c
+++ b/drivers/timer/ast_timer.c
@@ -9,6 +9,7 @@
 #include <timer.h>
 #include <asm/io.h>
 #include <asm/arch/timer.h>
+#include <linux/err.h>
 
 #define AST_TICK_TIMER  1
 #define AST_TMC_RELOAD_VAL  0xffffffff
diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c
index 75263c5375..ed48a145f2 100644
--- a/drivers/timer/cadence-ttc.c
+++ b/drivers/timer/cadence-ttc.c
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <timer.h>
 #include <asm/io.h>
+#include <linux/err.h>
 
 #define CNT_CNTRL_RESET		BIT(4)
 
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 97a4c74851..b619200f00 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <errno.h>
 #include <timer.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/ufs/cdns-platform.c b/drivers/ufs/cdns-platform.c
index c80f4253e4..5bd0c1e0c7 100644
--- a/drivers/ufs/cdns-platform.c
+++ b/drivers/ufs/cdns-platform.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <ufs.h>
+#include <linux/err.h>
 
 #include "ufs.h"
 
diff --git a/drivers/ufs/ti-j721e-ufs.c b/drivers/ufs/ti-j721e-ufs.c
index 24ec3ebea1..6e4d0cd3ac 100644
--- a/drivers/ufs/ti-j721e-ufs.c
+++ b/drivers/ufs/ti-j721e-ufs.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <linux/err.h>
 
 #define UFS_SS_CTRL             0x4
 #define UFS_SS_RST_N_PCS        BIT(0)
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index 23306863d5..512c63a8f2 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -11,6 +11,7 @@
 #include <charset.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 #include <malloc.h>
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 8c8e02169e..6f5e5af47d 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/lists.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 0e02b77965..e095760099 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -57,6 +57,8 @@
  */
 
 #include <dm.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <linux/usb/gadget.h>
 #include <linux/compat.h>
 #include <linux/iopoll.h>
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index 425d9d053d..b44e7df113 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -9,6 +9,7 @@
  *          Pawel Laszczak <pawell@cadence.com>
  */
 #include <dm.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <usb.h>
 #include <usb/xhci.h>
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 77c555e769..cbf21d31dd 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -18,6 +18,8 @@
 #include <malloc.h>
 #include <dwc3-uboot.h>
 #include <asm/dma-mapping.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <linux/ioport.h>
 #include <dm.h>
 #include <generic-phy.h>
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 8b19140182..7ffec12fc5 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -18,6 +18,7 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <dwc3-omap-uboot.h>
+#include <dm/devres.h>
 #include <linux/usb/dwc3-omap.h>
 #include <linux/ioport.h>
 
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 4353dffb6b..677607ab32 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -17,6 +17,7 @@
 #include <cpu_func.h>
 #include <malloc.h>
 #include <asm/dma-mapping.h>
+#include <dm/devres.h>
 #include <linux/bug.h>
 #include <linux/list.h>
 
diff --git a/drivers/usb/dwc3/ti_usb_phy.c b/drivers/usb/dwc3/ti_usb_phy.c
index e7ea12c163..a90868216a 100644
--- a/drivers/usb/dwc3/ti_usb_phy.c
+++ b/drivers/usb/dwc3/ti_usb_phy.c
@@ -19,6 +19,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <ti-usb-phy-uboot.h>
+#include <dm/devres.h>
 #include <linux/ioport.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 2a6626b443..13dec517f6 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -14,6 +14,8 @@
 #undef	PACKET_TRACE
 
 #include <common.h>
+#include <dm/devres.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 4a6f4271d5..b2b279358e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -7,6 +7,7 @@
  */
 #undef DEBUG
 
+#include <dm/devres.h>
 #include <linux/bitops.h>
 #include <linux/usb/composite.h>
 
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 35f4147840..229a61affd 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -23,6 +23,7 @@
 #include <generic-phy.h>
 #include <malloc.h>
 #include <reset.h>
+#include <dm/devres.h>
 
 #include <linux/errno.h>
 #include <linux/list.h>
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index c1e6506659..5250fc8b26 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -245,6 +245,7 @@
 #include <common.h>
 #include <console.h>
 #include <g_dnl.h>
+#include <dm/devres.h>
 
 #include <linux/err.h>
 #include <linux/usb/ch9.h>
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 09c0a30b2b..6e1e57f9fd 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -22,6 +22,7 @@
 #include <asm/system.h>
 #include <asm/mach-types.h>
 #include <asm/unaligned.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <malloc.h>
 #include <asm/io.h>
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index 8d1d90e3e3..52384b9afb 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -13,6 +13,7 @@
  *		       usb_
  */
 
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <malloc.h>
 #include <asm/cache.h>
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 682a070306..80ac876d89 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <clk.h>
+#include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
 #include <reset.h>
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 233df57b4d..29a702052e 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -7,6 +7,7 @@
 #include <asm/io.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
 #include <reset.h>
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 916ea0b955..7b6ec51704 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
 #include <reset.h>
diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c
index bda099c63f..58cde22615 100644
--- a/drivers/usb/musb-new/am35x.c
+++ b/drivers/usb/musb-new/am35x.c
@@ -12,6 +12,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/clk.h>
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index ab5e3aa9d1..cc6e0a71c9 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -65,6 +65,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c
index 0c794b310a..d342eeba80 100644
--- a/drivers/usb/musb-new/musb_dsps.c
+++ b/drivers/usb/musb-new/musb_dsps.c
@@ -15,6 +15,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/err.h>
diff --git a/drivers/usb/musb-new/musb_gadget.c b/drivers/usb/musb-new/musb_gadget.c
index b35d33ffed..74b645715d 100644
--- a/drivers/usb/musb-new/musb_gadget.c
+++ b/drivers/usb/musb-new/musb_gadget.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/timer.h>
diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c
index 8e92ade471..55ad8ead70 100644
--- a/drivers/usb/musb-new/musb_host.c
+++ b/drivers/usb/musb-new/musb_host.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 9eb593402e..f4d0e1fdc2 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -1,6 +1,7 @@
 #include <common.h>
 #include <console.h>
 #include <watchdog.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 05059ce3cb..8a45b05613 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -13,6 +13,7 @@
 #include <serial.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <linux/err.h>
 #include <linux/usb/otg.h>
 #include <asm/omap_common.h>
 #include <asm/omap_musb.h>
diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c
index 74a66e83d2..ad5ef93e01 100644
--- a/drivers/video/exynos/exynos_mipi_dsi.c
+++ b/drivers/video/exynos/exynos_mipi_dsi.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <fdtdec.h>
+#include <dm/devres.h>
 #include <linux/libfdt.h>
 #include <linux/compat.h>
 #include <linux/err.h>
diff --git a/drivers/video/mipi_dsi.c b/drivers/video/mipi_dsi.c
index cdc3ef58ab..ecacea1dbe 100644
--- a/drivers/video/mipi_dsi.c
+++ b/drivers/video/mipi_dsi.c
@@ -38,6 +38,7 @@
 #include <dm.h>
 #include <mipi_display.h>
 #include <mipi_dsi.h>
+#include <dm/devres.h>
 
 /**
  * DOC: dsi helpers
diff --git a/drivers/video/rockchip/rk3288_mipi.c b/drivers/video/rockchip/rk3288_mipi.c
index 65891ce45c..f4444b9c34 100644
--- a/drivers/video/rockchip/rk3288_mipi.c
+++ b/drivers/video/rockchip/rk3288_mipi.c
@@ -16,6 +16,7 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
diff --git a/drivers/video/rockchip/rk3399_mipi.c b/drivers/video/rockchip/rk3399_mipi.c
index a5b7ba69a8..74ebe770a9 100644
--- a/drivers/video/rockchip/rk3399_mipi.c
+++ b/drivers/video/rockchip/rk3399_mipi.c
@@ -16,6 +16,7 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index b56c3f336c..e91d4dfa7f 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -19,6 +19,7 @@
 #include <asm/arch-rockchip/vop_rk3288.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 #include "rk_vop.h"
 
diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c
index 172bb14d6c..8dc3df61aa 100644
--- a/drivers/video/tegra124/sor.c
+++ b/drivers/video/tegra124/sor.c
@@ -15,6 +15,7 @@
 #include <asm/arch-tegra/dc.h>
 #include "displayport.h"
 #include "sor.h"
+#include <linux/err.h>
 
 #define DEBUG_SOR 0
 
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index a67b354122..60ece133ab 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -13,6 +13,7 @@
 #include <virtio.h>
 #include <virtio_ring.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include "virtio_mmio.h"
 
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
index 202e5ab1d3..d9be2601bb 100644
--- a/drivers/virtio/virtio_pci_legacy.c
+++ b/drivers/virtio/virtio_pci_legacy.c
@@ -13,6 +13,7 @@
 #include <virtio_ring.h>
 #include <dm/device.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include "virtio_pci.h"
 
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index da76aea8d1..4673f4ab55 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -13,6 +13,7 @@
 #include <virtio_ring.h>
 #include <dm/device.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include "virtio_pci.h"
 
diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c
index 2addb1ebc5..61f6a96008 100644
--- a/drivers/virtio/virtio_sandbox.c
+++ b/drivers/virtio/virtio_sandbox.c
@@ -11,6 +11,7 @@
 #include <virtio.h>
 #include <virtio_ring.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/io.h>
 
 struct virtio_sandbox_priv {
diff --git a/drivers/watchdog/ast_wdt.c b/drivers/watchdog/ast_wdt.c
index d344d54aee..fe2f6be5a7 100644
--- a/drivers/watchdog/ast_wdt.c
+++ b/drivers/watchdog/ast_wdt.c
@@ -9,6 +9,7 @@
 #include <wdt.h>
 #include <asm/io.h>
 #include <asm/arch/wdt.h>
+#include <linux/err.h>
 
 #define WDT_AST2500	2500
 #define WDT_AST2400	2400
diff --git a/drivers/watchdog/cdns_wdt.c b/drivers/watchdog/cdns_wdt.c
index 6a608b6371..13952e1e97 100644
--- a/drivers/watchdog/cdns_wdt.c
+++ b/drivers/watchdog/cdns_wdt.c
@@ -11,6 +11,7 @@
 #include <wdt.h>
 #include <clk.h>
 #include <div64.h>
+#include <linux/err.h>
 #include <linux/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index f1e781e4e6..ca3ccbe76c 100644
--- a/drivers/watchdog/sp805_wdt.c
+++ b/drivers/watchdog/sp805_wdt.c
@@ -13,6 +13,7 @@
 #include <linux/bitops.h>
 #include <watchdog.h>
 #include <wdt.h>
+#include <linux/err.h>
 
 #define WDTLOAD			0x000
 #define WDTCONTROL		0x008
diff --git a/drivers/watchdog/xilinx_tb_wdt.c b/drivers/watchdog/xilinx_tb_wdt.c
index 929c8e60d3..5580764da7 100644
--- a/drivers/watchdog/xilinx_tb_wdt.c
+++ b/drivers/watchdog/xilinx_tb_wdt.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <dm.h>
 #include <wdt.h>
+#include <linux/err.h>
 #include <linux/io.h>
 
 #define XWT_CSR0_WRS_MASK	0x00000008 /* Reset status Mask */
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 782aa9a250..6835f86fec 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -16,6 +16,7 @@
  */
 
 #include <hexdump.h>
+#include <dm/devres.h>
 
 #ifndef __UBOOT__
 #include <linux/module.h>
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 42f22a487e..f923d07652 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -41,6 +41,7 @@
  * good, and GC takes extra care when moving them.
  */
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/list_sort.h>
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index 7fe94e1093..8148055f67 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -59,6 +59,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
 #include <linux/slab.h>
 #include <u-boot/crc.h>
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
index 331a891a57..5cbb8aa1b2 100644
--- a/fs/ubifs/log.c
+++ b/fs/ubifs/log.c
@@ -16,6 +16,7 @@
  */
 
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/err.h>
 #endif
 #include "ubifs.h"
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index c0076bde74..ebfb1d4dd7 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -33,6 +33,7 @@
 
 #include "ubifs.h"
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc16.h>
 #include <linux/math64.h>
 #include <linux/slab.h>
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 260216205d..aa5956c52e 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -14,6 +14,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc16.h>
 #include <linux/slab.h>
 #include <linux/random.h>
diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
index 5654d45dfb..2740aaee8b 100644
--- a/fs/ubifs/master.c
+++ b/fs/ubifs/master.c
@@ -12,6 +12,7 @@
 
 #include "ubifs.h"
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/err.h>
 #include <ubi_uboot.h>
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index c807ff1beb..a67b3eec93 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -7,6 +7,7 @@
  * Author: Adrian Hunter
  */
 
+#include <dm/devres.h>
 #include <linux/err.h>
 #include "ubifs.h"
 
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index b568012fec..3388efe2b7 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -36,6 +36,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
 #include <linux/slab.h>
 #include <u-boot/crc.h>
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 4064157f15..3a9fa4130e 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -21,6 +21,7 @@
  */
 
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/err.h>
 #endif
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index 52db611d1c..599e1a35fb 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -16,6 +16,7 @@
 
 #include "ubifs.h"
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/math64.h>
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c
index 8ff668eec6..876a6ee661 100644
--- a/fs/ubifs/scan.c
+++ b/fs/ubifs/scan.c
@@ -17,6 +17,7 @@
 
 #ifdef __UBOOT__
 #include <hexdump.h>
+#include <dm/devres.h>
 #include <linux/err.h>
 #endif
 #include "ubifs.h"
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 9939b4404f..b38513660b 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -15,6 +15,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 8afc08ad7d..fc6fdaff8d 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -19,6 +19,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/crc32.h>
 #include <linux/slab.h>
 #include <u-boot/crc.h>
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
index b8ea7e9ddb..dfa9e91903 100644
--- a/fs/ubifs/tnc_misc.c
+++ b/fs/ubifs/tnc_misc.c
@@ -16,6 +16,7 @@
  */
 
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/err.h>
 #endif
 #include "ubifs.h"
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 1ffdfe0d90..388451512a 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -16,6 +16,7 @@
 #include <gzip.h>
 #include <memalign.h>
 #include "ubifs.h"
+#include <dm/devres.h>
 #include <u-boot/zlib.h>
 
 #include <linux/compat.h>
diff --git a/fs/yaffs2/yaffs_allocator.c b/fs/yaffs2/yaffs_allocator.c
index 611061fb45..961dc22ef3 100644
--- a/fs/yaffs2/yaffs_allocator.c
+++ b/fs/yaffs2/yaffs_allocator.c
@@ -15,6 +15,7 @@
 #include "yaffs_guts.h"
 #include "yaffs_trace.h"
 #include "yportenv.h"
+#include <dm/devres.h>
 
 /*
  * Each entry in yaffs_tnode_list and yaffs_obj_list hold blocks
diff --git a/fs/yaffs2/yaffs_checkptrw.c b/fs/yaffs2/yaffs_checkptrw.c
index 997a618aee..628f02bb48 100644
--- a/fs/yaffs2/yaffs_checkptrw.c
+++ b/fs/yaffs2/yaffs_checkptrw.c
@@ -13,6 +13,7 @@
 
 #include "yaffs_checkptrw.h"
 #include "yaffs_getblockinfo.h"
+#include <dm/devres.h>
 
 static int yaffs2_checkpt_space_ok(struct yaffs_dev *dev)
 {
diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index c8b27adda9..e13a73298b 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -13,6 +13,7 @@
 
 #include "yportenv.h"
 #include "yaffs_trace.h"
+#include <dm/devres.h>
 
 #include "yaffs_guts.h"
 #include "yaffs_getblockinfo.h"
diff --git a/fs/yaffs2/yaffs_summary.c b/fs/yaffs2/yaffs_summary.c
index e9e1b5d857..4f9449a844 100644
--- a/fs/yaffs2/yaffs_summary.c
+++ b/fs/yaffs2/yaffs_summary.c
@@ -28,6 +28,7 @@
 #include "yaffs_nand.h"
 #include "yaffs_getblockinfo.h"
 #include "yaffs_bitmap.h"
+#include <dm/devres.h>
 
 /*
  * The summary is built up in an array of summary tags.
diff --git a/fs/yaffs2/yaffs_yaffs1.c b/fs/yaffs2/yaffs_yaffs1.c
index 357d8f75dd..8c176b982f 100644
--- a/fs/yaffs2/yaffs_yaffs1.c
+++ b/fs/yaffs2/yaffs_yaffs1.c
@@ -18,6 +18,7 @@
 #include "yaffs_getblockinfo.h"
 #include "yaffs_nand.h"
 #include "yaffs_attribs.h"
+#include <dm/devres.h>
 
 int yaffs1_scan(struct yaffs_dev *dev)
 {
diff --git a/fs/yaffs2/yaffs_yaffs2.c b/fs/yaffs2/yaffs_yaffs2.c
index f76dcaeeb1..14d497eb99 100644
--- a/fs/yaffs2/yaffs_yaffs2.c
+++ b/fs/yaffs2/yaffs_yaffs2.c
@@ -21,6 +21,7 @@
 #include "yaffs_verify.h"
 #include "yaffs_attribs.h"
 #include "yaffs_summary.h"
+#include <dm/devres.h>
 
 /*
  * Checkpoints are really no benefit on very small partitions.
diff --git a/fs/yaffs2/yaffsfs.c b/fs/yaffs2/yaffsfs.c
index 47abc6beda..510faaeed1 100644
--- a/fs/yaffs2/yaffsfs.c
+++ b/fs/yaffs2/yaffsfs.c
@@ -17,6 +17,7 @@
 #include "yaffscfg.h"
 #include "yportenv.h"
 #include "yaffs_trace.h"
+#include <dm/devres.h>
 
 #define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
 
diff --git a/include/dm/device.h b/include/dm/device.h
index 1138a09149..a93fa22d5d 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -720,8 +720,6 @@ static inline bool device_is_on_pci_bus(struct udevice *dev)
  */
 int dm_scan_fdt_dev(struct udevice *dev);
 
-#include <dm/devres.h>
-
 /*
  * REVISIT:
  * remove the following after resolving conflicts with <linux/compat.h>
diff --git a/include/dm/devres.h b/include/dm/devres.h
index 9c69196054..17bb1ee8da 100644
--- a/include/dm/devres.h
+++ b/include/dm/devres.h
@@ -11,6 +11,10 @@
 #ifndef _DM_DEVRES_H
 #define _DM_DEVRES_H
 
+#include <linux/compat.h>
+
+struct udevice;
+
 /* device resource management */
 typedef void (*dr_release_t)(struct udevice *dev, void *res);
 typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
diff --git a/lib/bch.c b/lib/bch.c
index c4fac77d61..86709cc875 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -56,6 +56,7 @@
 #ifndef USE_HOSTCC
 #include <common.h>
 #include <ubi_uboot.h>
+#include <dm/devres.h>
 
 #include <linux/bitops.h>
 #else
diff --git a/lib/crypto/asymmetric_type.c b/lib/crypto/asymmetric_type.c
index e04666c080..7aa55092ac 100644
--- a/lib/crypto/asymmetric_type.c
+++ b/lib/crypto/asymmetric_type.c
@@ -7,6 +7,7 @@
  * Written by David Howells (dhowells at redhat.com)
  */
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #endif
@@ -14,6 +15,7 @@
 #ifdef __UBOOT__
 #include <linux/compat.h>
 #include <linux/ctype.h>
+#include <linux/err.h>
 #include <linux/string.h>
 #else
 #include <linux/seq_file.h>
diff --git a/lib/crypto/pkcs7_parser.c b/lib/crypto/pkcs7_parser.c
index bf9e7e888f..f5dda1179f 100644
--- a/lib/crypto/pkcs7_parser.c
+++ b/lib/crypto/pkcs7_parser.c
@@ -7,6 +7,7 @@
 
 #define pr_fmt(fmt) "PKCS7: "fmt
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/bitops.h>
 #include <linux/compat.h>
 #endif
diff --git a/lib/crypto/public_key.c b/lib/crypto/public_key.c
index 634377472f..8b4821767a 100644
--- a/lib/crypto/public_key.c
+++ b/lib/crypto/public_key.c
@@ -9,7 +9,9 @@
 
 #define pr_fmt(fmt) "PKEY: "fmt
 #ifdef __UBOOT__
+#include <dm/devres.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #else
 #include <linux/module.h>
 #include <linux/export.h>
diff --git a/lib/crypto/x509_cert_parser.c b/lib/crypto/x509_cert_parser.c
index e6d2a426a0..4e41cffd23 100644
--- a/lib/crypto/x509_cert_parser.c
+++ b/lib/crypto/x509_cert_parser.c
@@ -6,6 +6,7 @@
  */
 
 #define pr_fmt(fmt) "X.509: "fmt
+#include <dm/devres.h>
 #include <linux/kernel.h>
 #ifndef __UBOOT__
 #include <linux/export.h>
diff --git a/lib/crypto/x509_public_key.c b/lib/crypto/x509_public_key.c
index 04bdb672b4..676c0df174 100644
--- a/lib/crypto/x509_public_key.c
+++ b/lib/crypto/x509_public_key.c
@@ -8,7 +8,9 @@
 #define pr_fmt(fmt) "X.509: "fmt
 #ifdef __UBOOT__
 #include <common.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
+#include <linux/err.h>
 #include <linux/errno.h>
 #else
 #include <linux/module.h>
diff --git a/lib/list_sort.c b/lib/list_sort.c
index e841da53ee..beb7273fd3 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -1,4 +1,5 @@
 #ifndef __UBOOT__
+#include <dm/devres.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
diff --git a/test/dm/devres.c b/test/dm/devres.c
index e7331897de..cbd0972c9b 100644
--- a/test/dm/devres.c
+++ b/test/dm/devres.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <malloc.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
 #include <test/ut.h>
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 6fd1f20656..b21f66732b 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -10,6 +10,7 @@
 #include <syscon.h>
 #include <asm/test.h>
 #include <dm/test.h>
+#include <linux/err.h>
 #include <test/ut.h>
 
 /* Base test of register maps */
diff --git a/test/dm/syscon.c b/test/dm/syscon.c
index 0ff9da7ec6..f1021f374b 100644
--- a/test/dm/syscon.c
+++ b/test/dm/syscon.c
@@ -9,6 +9,7 @@
 #include <regmap.h>
 #include <asm/test.h>
 #include <dm/test.h>
+#include <linux/err.h>
 #include <test/ut.h>
 
 /* Base test of system controllers */
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index d59c449ce0..64a94a521b 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -12,6 +12,7 @@
 #include <dm/test.h>
 #include <dm/root.h>
 #include <dm/device-internal.h>
+#include <dm/devres.h>
 #include <dm/uclass-internal.h>
 #include <dm/util.h>
 #include <dm/lists.h>
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (28 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h Simon Glass
                   ` (9 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

At present dm/device.h includes the linux-compatible features. This
requires including linux/compat.h which in turn includes a lot of headers.
One of these is malloc.h which we thus end up including in every file in
U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
which needs to use the system malloc() in some files.

Move the compatibility features into a separate header file.

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

Changes in v2: None

 arch/arm/mach-imx/cmd_nandbcb.c               |  1 +
 arch/arm/mach-imx/imx8/image.c                |  1 +
 arch/arm/mach-mvebu/mbus.c                    |  1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c        |  1 +
 arch/arm/mach-rockchip/rk3308/rk3308.c        |  1 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |  1 +
 arch/arm/mach-socfpga/clock_manager_arria10.c |  1 +
 arch/arm/mach-stm32mp/pwr_regulator.c         |  1 +
 arch/arm/mach-tegra/cboot.c                   |  1 +
 arch/arm/mach-zynq/clk.c                      |  1 +
 arch/arm/mach-zynq/timer.c                    |  1 +
 arch/mips/mach-mtmips/cpu.c                   |  1 +
 arch/mips/mach-pic32/cpu.c                    |  1 +
 arch/sandbox/cpu/cpu.c                        |  1 +
 arch/x86/cpu/apollolake/fsp_s.c               |  1 +
 arch/x86/cpu/apollolake/itss.c                |  1 +
 arch/x86/cpu/apollolake/spl.c                 |  1 +
 arch/x86/cpu/apollolake/uart.c                |  1 +
 arch/x86/cpu/qemu/e820.c                      |  1 +
 arch/x86/cpu/qfw_cpu.c                        |  1 +
 arch/x86/lib/coreboot_table.c                 |  1 +
 arch/x86/lib/fsp1/fsp_common.c                |  1 +
 arch/x86/lib/mrccache.c                       |  1 +
 arch/x86/lib/tables.c                         |  1 +
 board/compulab/common/common.c                |  1 +
 board/corscience/tricorder/tricorder.c        |  1 +
 board/gardena/smart-gateway-mt7688/board.c    |  1 +
 board/ge/common/vpd_reader.c                  |  1 +
 board/isee/igep003x/board.c                   |  1 +
 board/isee/igep00x0/igep00x0.c                |  1 +
 board/menlo/m53menlo/m53menlo.c               |  1 +
 board/microchip/pic32mzda/pic32mzda.c         |  1 +
 board/overo/overo.c                           |  1 +
 board/siemens/common/board.c                  |  1 +
 board/siemens/pxm2/board.c                    |  1 +
 board/siemens/rut/board.c                     |  1 +
 board/st/stm32mp1/stm32mp1.c                  |  1 +
 board/synopsys/hsdk/clk-lib.c                 |  1 +
 board/technexion/tao3530/tao3530.c            |  1 +
 board/ti/am335x/board.c                       |  1 +
 board/ti/am57xx/board.c                       |  1 +
 board/timll/devkit8000/devkit8000.c           |  1 +
 cmd/bootefi.c                                 |  1 +
 cmd/gpio.c                                    |  1 +
 cmd/host.c                                    |  1 +
 cmd/rng.c                                     |  1 +
 cmd/tpm-common.c                              |  1 +
 cmd/ubi.c                                     |  1 +
 cmd/usb_mass_storage.c                        |  1 +
 cmd/ximg.c                                    |  1 +
 common/android_ab.c                           |  1 +
 common/autoboot.c                             |  1 +
 common/image-fdt.c                            |  1 +
 common/image.c                                |  1 +
 common/usb.c                                  |  1 +
 common/usb_hub.c                              |  1 +
 drivers/adc/stm32-adc-core.c                  |  1 +
 drivers/adc/stm32-adc.c                       |  1 +
 drivers/axi/sandbox_store.c                   |  1 +
 drivers/block/blk-uclass.c                    |  1 +
 drivers/block/sandbox.c                       |  1 +
 drivers/clk/altera/clk-arria10.c              |  2 +
 drivers/clk/at91/clk-generated.c              |  1 +
 drivers/clk/at91/clk-h32mx.c                  |  1 +
 drivers/clk/at91/clk-peripheral.c             |  1 +
 drivers/clk/clk-cdce9xx.c                     |  1 +
 drivers/clk/clk-ti-sci.c                      |  2 +
 drivers/clk/clk-uclass.c                      |  1 +
 drivers/clk/clk_sandbox.c                     |  1 +
 drivers/clk/clk_sandbox_ccf.c                 |  1 +
 drivers/clk/clk_sandbox_test.c                |  2 +
 drivers/clk/clk_versal.c                      |  1 +
 drivers/clk/clk_vexpress_osc.c                |  1 +
 drivers/clk/clk_zynq.c                        |  1 +
 drivers/clk/clk_zynqmp.c                      |  2 +
 drivers/clk/imx/clk-imx8.c                    |  1 +
 drivers/clk/mvebu/armada-37xx-periph.c        |  1 +
 drivers/clk/mvebu/armada-37xx-tbg.c           |  1 +
 drivers/clk/rockchip/clk_px30.c               |  1 +
 drivers/clk/rockchip/clk_rk3036.c             |  1 +
 drivers/clk/rockchip/clk_rk3128.c             |  1 +
 drivers/clk/rockchip/clk_rk3188.c             |  1 +
 drivers/clk/rockchip/clk_rk322x.c             |  1 +
 drivers/clk/rockchip/clk_rk3288.c             |  1 +
 drivers/clk/rockchip/clk_rk3308.c             |  1 +
 drivers/clk/rockchip/clk_rk3328.c             |  1 +
 drivers/clk/rockchip/clk_rk3368.c             |  1 +
 drivers/clk/rockchip/clk_rk3399.c             |  1 +
 drivers/clk/rockchip/clk_rv1108.c             |  1 +
 drivers/clk/tegra/tegra-car-clk.c             |  1 +
 drivers/clk/uniphier/clk-uniphier-core.c      |  1 +
 drivers/core/devres.c                         |  1 +
 drivers/core/of_access.c                      |  1 +
 drivers/core/ofnode.c                         |  1 +
 drivers/core/syscon-uclass.c                  |  1 +
 drivers/ddr/altera/sdram_gen5.c               |  1 +
 drivers/ddr/altera/sdram_soc64.c              |  1 +
 drivers/dma/bcm6348-iudma.c                   |  1 +
 drivers/dma/dma-uclass.c                      |  1 +
 drivers/dma/sandbox-dma-test.c                |  1 +
 drivers/dma/ti/k3-udma.c                      |  1 +
 drivers/firmware/ti_sci.c                     |  2 +
 drivers/fpga/fpga.c                           |  1 +
 drivers/gpio/74x164_gpio.c                    |  1 +
 drivers/gpio/adi_gpio2.c                      |  1 +
 drivers/gpio/at91_gpio.c                      |  1 +
 drivers/gpio/atmel_pio4.c                     |  1 +
 drivers/gpio/da8xx_gpio.c                     |  1 +
 drivers/gpio/dwapb_gpio.c                     |  1 +
 drivers/gpio/gpio-rcar.c                      |  2 +
 drivers/gpio/kona_gpio.c                      |  1 +
 drivers/gpio/mpc83xx_gpio.c                   |  1 +
 drivers/gpio/mscc_sgpio.c                     |  1 +
 drivers/gpio/mvgpio.c                         |  1 +
 drivers/gpio/mxs_gpio.c                       |  1 +
 drivers/gpio/pca953x_gpio.c                   |  1 +
 drivers/gpio/pca9698.c                        |  1 +
 drivers/gpio/sh_pfc.c                         |  1 +
 drivers/gpio/spear_gpio.c                     |  1 +
 drivers/gpio/stm32_gpio.c                     |  1 +
 drivers/hwspinlock/hwspinlock-uclass.c        |  2 +
 drivers/hwspinlock/stm32_hwspinlock.c         |  1 +
 drivers/i2c/at91_i2c.c                        |  1 +
 drivers/i2c/designware_i2c.c                  |  2 +
 drivers/i2c/i2c-uniphier-f.c                  |  1 +
 drivers/i2c/i2c-uniphier.c                    |  1 +
 drivers/i2c/imx_lpi2c.c                       |  1 +
 drivers/i2c/muxes/i2c-arb-gpio-challenge.c    |  1 +
 drivers/i2c/muxes/i2c-mux-gpio.c              |  1 +
 drivers/i2c/muxes/i2c-mux-uclass.c            |  1 +
 drivers/i2c/muxes/pca954x.c                   |  1 +
 drivers/i2c/mxc_i2c.c                         |  1 +
 drivers/i2c/rcar_i2c.c                        |  1 +
 drivers/i2c/stm32f7_i2c.c                     |  1 +
 drivers/i2c/xilinx_xiic.c                     |  1 +
 drivers/led/led_gpio.c                        |  1 +
 drivers/mailbox/k3-sec-proxy.c                |  2 +
 drivers/mailbox/mailbox-uclass.c              |  1 +
 drivers/mailbox/sandbox-mbox-test.c           |  1 +
 drivers/mailbox/sandbox-mbox.c                |  1 +
 drivers/mailbox/stm32-ipcc.c                  |  2 +
 drivers/mailbox/tegra-hsp.c                   |  1 +
 drivers/mailbox/zynqmp-ipi.c                  |  1 +
 drivers/misc/imx8/scu_api.c                   |  1 +
 drivers/misc/k3_avs.c                         |  1 +
 drivers/misc/p2sb-uclass.c                    |  1 +
 drivers/misc/stm32_rcc.c                      |  1 +
 drivers/misc/tegra186_bpmp.c                  |  1 +
 drivers/misc/vexpress_config.c                |  1 +
 drivers/mmc/am654_sdhci.c                     |  1 +
 drivers/mmc/arm_pl180_mmci.c                  |  1 +
 drivers/mmc/bcm2835_sdhost.c                  |  1 +
 drivers/mmc/fsl_esdhc.c                       |  1 +
 drivers/mmc/fsl_esdhc_imx.c                   |  1 +
 drivers/mmc/jz_mmc.c                          |  1 +
 drivers/mmc/mmc-uclass.c                      |  2 +
 drivers/mmc/msm_sdhci.c                       |  1 +
 drivers/mmc/mtk-sd.c                          |  1 +
 drivers/mmc/renesas-sdhi.c                    |  2 +
 drivers/mmc/sdhci-cadence.c                   |  1 +
 drivers/mmc/sh_mmcif.c                        |  1 +
 drivers/mmc/sh_sdhi.c                         |  1 +
 drivers/mmc/snps_dw_mmc.c                     |  1 +
 drivers/mmc/socfpga_dw_mmc.c                  |  1 +
 drivers/mmc/stm32_sdmmc2.c                    |  1 +
 drivers/mmc/tmio-common.c                     |  1 +
 drivers/mmc/uniphier-sd.c                     |  2 +
 drivers/mmc/zynq_sdhci.c                      |  1 +
 drivers/mtd/hbmc-am654.c                      |  1 +
 drivers/mtd/mtd_uboot.c                       |  1 +
 drivers/mtd/nand/core.c                       |  1 +
 drivers/mtd/nand/raw/atmel_nand.c             |  1 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      |  1 +
 .../mtd/nand/raw/brcmnand/brcmnand_compat.c   |  3 +-
 drivers/mtd/nand/raw/denali.c                 |  2 +
 drivers/mtd/nand/raw/denali_dt.c              |  1 +
 drivers/mtd/nand/raw/pxa3xx_nand.c            |  1 +
 drivers/mtd/nand/raw/sunxi_nand.c             |  2 +
 drivers/mtd/nand/raw/tegra_nand.c             |  1 +
 drivers/mtd/nand/raw/vf610_nfc.c              |  1 +
 drivers/mtd/nand/spi/core.c                   |  1 +
 drivers/mtd/nand/spi/gigadevice.c             |  1 +
 drivers/mtd/nand/spi/macronix.c               |  1 +
 drivers/mtd/nand/spi/micron.c                 |  1 +
 drivers/mtd/nand/spi/winbond.c                |  1 +
 drivers/mtd/renesas_rpc_hf.c                  |  2 +
 drivers/mtd/spi/sf-uclass.c                   |  1 +
 drivers/mtd/spi/spi-nor-core.c                |  1 +
 drivers/mtd/spi/spi-nor-tiny.c                |  1 +
 drivers/mtd/ubi/debug.c                       |  1 +
 drivers/mtd/ubi/misc.c                        |  1 +
 drivers/mtd/ubi/upd.c                         |  1 +
 drivers/net/bcm6348-eth.c                     |  1 +
 drivers/net/bcm6368-eth.c                     |  2 +
 drivers/net/designware.c                      |  1 +
 drivers/net/dwc_eth_qos.c                     |  1 +
 drivers/net/dwmac_socfpga.c                   |  1 +
 drivers/net/e1000.c                           |  1 +
 drivers/net/e1000_spi.c                       |  1 +
 drivers/net/fsl-mc/dpio/qbman_portal.c        |  1 +
 drivers/net/fsl-mc/mc.c                       |  1 +
 drivers/net/fsl_enetc.c                       |  1 +
 drivers/net/ftgmac100.c                       |  2 +
 drivers/net/higmacv300.c                      |  1 +
 drivers/net/mscc_eswitch/jr2_switch.c         |  1 +
 drivers/net/mscc_eswitch/luton_switch.c       |  1 +
 drivers/net/mscc_eswitch/ocelot_switch.c      |  1 +
 drivers/net/mscc_eswitch/serval_switch.c      |  1 +
 drivers/net/mscc_eswitch/servalt_switch.c     |  1 +
 drivers/net/mtk_eth.c                         |  1 +
 drivers/net/mvneta.c                          |  1 +
 drivers/net/mvpp2.c                           |  1 +
 drivers/net/pch_gbe.c                         |  1 +
 drivers/net/pfe_eth/pfe_driver.c              |  1 +
 drivers/net/pfe_eth/pfe_eth.c                 |  1 +
 drivers/net/pfe_eth/pfe_firmware.c            |  1 +
 drivers/net/pfe_eth/pfe_mdio.c                |  1 +
 drivers/net/phy/fixed.c                       |  1 +
 drivers/net/pic32_eth.c                       |  1 +
 drivers/net/sandbox-raw-bus.c                 |  1 +
 drivers/net/sni_ave.c                         |  8 +-
 drivers/net/sun8i_emac.c                      |  1 +
 drivers/net/sunxi_emac.c                      |  1 +
 drivers/net/ti/am65-cpsw-nuss.c               |  2 +
 drivers/net/ti/cpsw-common.c                  |  1 +
 drivers/net/ti/cpsw.c                         |  1 +
 drivers/net/ti/cpsw_mdio.c                    |  1 +
 drivers/net/zynq_gem.c                        |  1 +
 drivers/nvme/nvme.c                           |  2 +
 drivers/pci/pci-aardvark.c                    |  1 +
 drivers/pci/pci-uclass.c                      |  1 +
 drivers/pci/pci_mvebu.c                       |  1 +
 drivers/pci/pcie_dw_ti.c                      |  1 +
 drivers/pci/pcie_fsl.c                        |  1 +
 drivers/pci/pcie_imx.c                        |  1 +
 drivers/pci/pcie_intel_fpga.c                 |  1 +
 drivers/pci/pcie_mediatek.c                   |  1 +
 drivers/phy/allwinner/phy-sun4i-usb.c         |  1 +
 drivers/phy/bcm6318-usbh-phy.c                |  1 +
 drivers/phy/bcm6348-usbh-phy.c                |  1 +
 drivers/phy/bcm6358-usbh-phy.c                |  1 +
 drivers/phy/bcm6368-usbh-phy.c                |  1 +
 drivers/phy/marvell/comphy_core.c             |  1 +
 drivers/phy/meson-g12a-usb2.c                 |  1 +
 drivers/phy/meson-g12a-usb3-pcie.c            |  1 +
 drivers/phy/meson-gxl-usb2.c                  |  1 +
 drivers/phy/meson-gxl-usb3.c                  |  1 +
 drivers/phy/phy-mtk-tphy.c                    |  2 +
 drivers/phy/phy-rcar-gen2.c                   |  2 +
 drivers/phy/phy-rcar-gen3.c                   |  1 +
 drivers/phy/phy-stm32-usbphyc.c               |  1 +
 drivers/phy/phy-ti-am654.c                    |  1 +
 drivers/pinctrl/broadcom/pinctrl-bcm6838.c    |  1 +
 drivers/pinctrl/intel/pinctrl.c               |  1 +
 drivers/pinctrl/meson/pinctrl-meson.c         |  2 +
 drivers/pinctrl/mscc/mscc-common.c            |  1 +
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  1 +
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c   |  2 +
 drivers/pinctrl/nxp/pinctrl-imx.c             |  2 +
 drivers/pinctrl/nxp/pinctrl-mxs.c             |  1 +
 drivers/pinctrl/pinctrl-generic.c             |  1 +
 drivers/pinctrl/pinctrl-single.c              |  1 +
 drivers/pinctrl/pinctrl-stmfx.c               |  1 +
 drivers/pinctrl/pinctrl-uclass.c              |  2 +
 drivers/pinctrl/pinctrl_stm32.c               |  2 +
 drivers/pinctrl/renesas/pfc.c                 |  1 +
 .../pinctrl/uniphier/pinctrl-uniphier-core.c  |  1 +
 drivers/power/domain/bcm6328-power-domain.c   |  1 +
 .../power/domain/imx8-power-domain-legacy.c   |  1 +
 drivers/power/domain/imx8-power-domain.c      |  1 +
 drivers/power/domain/imx8m-power-domain.c     |  1 +
 drivers/power/domain/meson-ee-pwrc.c          |  1 +
 drivers/power/domain/meson-gx-pwrc-vpu.c      |  1 +
 drivers/power/domain/mtk-power-domain.c       |  1 +
 drivers/power/domain/power-domain-uclass.c    |  1 +
 .../power/domain/sandbox-power-domain-test.c  |  1 +
 drivers/power/domain/sandbox-power-domain.c   |  1 +
 drivers/power/domain/tegra186-power-domain.c  |  1 +
 drivers/power/domain/ti-sci-power-domain.c    |  2 +
 drivers/power/pmic/fan53555.c                 |  1 +
 drivers/power/pmic/i2c_pmic_emul.c            |  1 +
 drivers/power/pmic/stpmic1.c                  |  1 +
 drivers/power/regulator/pwm_regulator.c       |  1 +
 drivers/power/regulator/stm32-vrefbuf.c       |  1 +
 drivers/power/regulator/tps62360_regulator.c  |  1 +
 drivers/ram/k3-am654-ddrss.c                  |  1 +
 drivers/ram/k3-j721e/k3-j721e-ddrss.c         |  1 +
 drivers/ram/stm32_sdram.c                     |  1 +
 drivers/remoteproc/k3_system_controller.c     |  1 +
 drivers/remoteproc/rproc-elf-loader.c         |  3 +-
 drivers/remoteproc/stm32_copro.c              |  1 +
 drivers/remoteproc/ti_k3_arm64_rproc.c        |  1 +
 drivers/remoteproc/ti_k3_dsp_rproc.c          |  2 +
 drivers/remoteproc/ti_k3_r5f_rproc.c          |  2 +
 drivers/reset/reset-bcm6345.c                 |  1 +
 drivers/reset/reset-hisilicon.c               |  1 +
 drivers/reset/reset-imx7.c                    |  1 +
 drivers/reset/reset-mediatek.c                |  1 +
 drivers/reset/reset-meson.c                   |  1 +
 drivers/reset/reset-mtmips.c                  |  1 +
 drivers/reset/reset-rockchip.c                |  1 +
 drivers/reset/reset-socfpga.c                 |  1 +
 drivers/reset/reset-sunxi.c                   |  1 +
 drivers/reset/reset-ti-sci.c                  |  2 +
 drivers/reset/reset-uclass.c                  |  1 +
 drivers/reset/reset-uniphier.c                |  2 +
 drivers/reset/sandbox-reset-test.c            |  1 +
 drivers/reset/sandbox-reset.c                 |  1 +
 drivers/reset/sti-reset.c                     |  1 +
 drivers/reset/stm32-reset.c                   |  1 +
 drivers/reset/tegra-car-reset.c               |  1 +
 drivers/reset/tegra186-reset.c                |  1 +
 drivers/rtc/ds3232.c                          |  1 +
 drivers/rtc/rv3029.c                          |  1 +
 drivers/rtc/stm32_rtc.c                       |  2 +
 drivers/serial/atmel_usart.c                  |  1 +
 drivers/serial/serial-uclass.c                |  1 +
 drivers/serial/serial_bcm6345.c               |  1 +
 drivers/serial/serial_lpuart.c                |  1 +
 drivers/serial/serial_msm.c                   |  1 +
 drivers/serial/serial_pic32.c                 |  1 +
 drivers/serial/serial_stm32.c                 |  1 +
 drivers/serial/serial_zynq.c                  |  1 +
 drivers/smem/msm_smem.c                       |  1 +
 drivers/soc/ti/k3-navss-ringacc.c             |  1 +
 drivers/sound/sound-uclass.c                  |  1 +
 drivers/spi/atmel-quadspi.c                   |  2 +
 drivers/spi/bcm63xx_hsspi.c                   |  1 +
 drivers/spi/bcm63xx_spi.c                     |  1 +
 drivers/spi/cadence_qspi.c                    |  1 +
 drivers/spi/designware_spi.c                  |  1 +
 drivers/spi/mvebu_a3700_spi.c                 |  1 +
 drivers/spi/mxc_spi.c                         |  1 +
 drivers/spi/spi-mem-nodm.c                    |  1 +
 drivers/spi/spi-mem.c                         |  1 +
 drivers/spi/spi-sunxi.c                       |  1 +
 drivers/spi/stm32_qspi.c                      |  1 +
 drivers/spi/stm32_spi.c                       |  2 +
 drivers/spi/uniphier_spi.c                    |  1 +
 drivers/spi/zynqmp_gqspi.c                    |  1 +
 drivers/spmi/spmi-msm.c                       |  1 +
 drivers/sysreset/sysreset-ti-sci.c            |  1 +
 drivers/tee/optee/core.c                      |  1 +
 drivers/tee/optee/rpmb.c                      |  1 +
 drivers/tee/optee/supplicant.c                |  1 +
 drivers/tee/tee-uclass.c                      |  3 +-
 drivers/timer/dw-apb-timer.c                  |  2 +
 drivers/timer/ostm_timer.c                    |  1 +
 drivers/timer/stm32_timer.c                   |  1 +
 drivers/ufs/cdns-platform.c                   |  1 +
 drivers/ufs/ti-j721e-ufs.c                    |  1 +
 drivers/ufs/ufs.c                             |  1 +
 drivers/usb/cdns3/cdns3-ti.c                  |  1 +
 drivers/usb/cdns3/core.c                      |  1 +
 drivers/usb/cdns3/drd.c                       |  1 +
 drivers/usb/cdns3/ep0.c                       |  1 +
 drivers/usb/cdns3/gadget.c                    |  1 +
 drivers/usb/dwc3/core.c                       |  1 +
 drivers/usb/dwc3/dwc3-omap.c                  |  1 +
 drivers/usb/dwc3/dwc3-uniphier.c              |  1 +
 drivers/usb/dwc3/ep0.c                        |  1 +
 drivers/usb/dwc3/gadget.c                     |  1 +
 drivers/usb/dwc3/ti_usb_phy.c                 |  1 +
 drivers/usb/gadget/dwc2_udc_otg.c             |  1 +
 drivers/usb/gadget/storage_common.c           |  1 +
 drivers/usb/gadget/udc/udc-core.c             |  1 +
 drivers/usb/host/dwc2.c                       |  1 +
 drivers/usb/host/ehci-atmel.c                 |  1 +
 drivers/usb/host/ehci-generic.c               |  1 +
 drivers/usb/host/ehci-hcd.c                   |  1 +
 drivers/usb/host/ohci-da8xx.c                 |  2 +
 drivers/usb/host/ohci-generic.c               |  1 +
 drivers/usb/host/r8a66597-hcd.c               |  1 +
 drivers/usb/host/xhci-rcar.c                  |  2 +
 drivers/usb/musb-new/am35x.c                  |  1 +
 drivers/usb/musb-new/da8xx.c                  |  1 +
 drivers/usb/musb-new/musb_core.c              |  1 +
 drivers/usb/musb-new/musb_dsps.c              |  1 +
 drivers/usb/musb-new/musb_gadget.c            |  1 +
 drivers/usb/musb-new/musb_gadget_ep0.c        |  1 +
 drivers/usb/musb-new/musb_host.c              |  1 +
 drivers/usb/musb-new/musb_uboot.c             |  1 +
 drivers/usb/musb-new/omap2430.c               |  1 +
 drivers/usb/musb-new/pic32.c                  |  1 +
 drivers/usb/musb-new/sunxi.c                  |  2 +
 drivers/usb/musb-new/ti-musb.c                |  1 +
 drivers/usb/phy/omap_usb_phy.c                |  1 +
 drivers/video/atmel_hlcdfb.c                  |  1 +
 drivers/video/console_truetype.c              |  1 +
 drivers/video/da8xx-fb.c                      |  1 +
 drivers/video/dw_mipi_dsi.c                   |  1 +
 drivers/video/hitachi_tx18d42vm_lcd.c         |  1 +
 drivers/video/mali_dp.c                       |  2 +
 drivers/video/mvebu_lcd.c                     |  1 +
 drivers/video/mxsfb.c                         |  1 +
 drivers/video/orisetech_otm8009a.c            |  1 +
 drivers/video/pwm_backlight.c                 |  1 +
 drivers/video/raydium-rm68200.c               |  1 +
 drivers/video/rockchip/rk3288_hdmi.c          |  1 +
 drivers/video/rockchip/rk_edp.c               |  1 +
 drivers/video/sandbox_osd.c                   |  1 +
 drivers/video/scf0403_lcd.c                   |  1 +
 drivers/video/ssd2828.c                       |  1 +
 drivers/video/stm32/stm32_dsi.c               |  1 +
 drivers/video/stm32/stm32_ltdc.c              |  1 +
 drivers/video/video-uclass.c                  |  1 +
 drivers/virtio/virtio-uclass.c                |  1 +
 drivers/virtio/virtio_ring.c                  |  1 +
 drivers/w1-eeprom/ds2502.c                    |  1 +
 drivers/w1/mxc_w1.c                           |  1 +
 drivers/watchdog/armada-37xx-wdt.c            |  1 +
 drivers/watchdog/cdns_wdt.c                   |  1 +
 fs/ext4/ext4_write.c                          |  1 +
 fs/ext4/ext4fs.c                              |  1 +
 fs/fat/fat_write.c                            |  1 +
 fs/sandbox/sandboxfs.c                        |  1 +
 fs/ubifs/lprops.c                             |  1 +
 fs/ubifs/ubifs.c                              |  1 +
 fs/yaffs2/yaffs_nandif.c                      |  1 +
 fs/yaffs2/yaffs_uboot_glue.c                  |  1 +
 include/dm/device.h                           | 71 ---------------
 include/dm/device_compat.h                    | 86 +++++++++++++++++++
 include/linux/clk-provider.h                  |  1 +
 lib/bch.c                                     |  1 +
 lib/binman.c                                  |  1 +
 lib/bzip2/bzlib.c                             |  1 +
 lib/crypto/rsa_helper.c                       |  1 +
 lib/efi/efi.c                                 |  1 +
 lib/efi/efi_app.c                             |  1 +
 lib/efi/efi_stub.c                            |  1 +
 lib/efi_driver/efi_block_device.c             |  1 +
 lib/efi_driver/efi_uclass.c                   |  1 +
 lib/efi_loader/efi_console.c                  |  1 +
 lib/efi_loader/efi_runtime.c                  |  1 +
 lib/fdtdec.c                                  |  1 +
 lib/libavb/avb_cmdline.c                      |  1 +
 lib/libavb/avb_descriptor.c                   |  1 +
 lib/libavb/avb_rsa.c                          |  1 +
 lib/libavb/avb_slot_verify.c                  |  1 +
 lib/libavb/avb_sysdeps_posix.c                |  1 +
 lib/libavb/avb_util.c                         |  1 +
 lib/linux_compat.c                            |  1 +
 lib/lmb.c                                     |  1 +
 lib/rsa/rsa-sign.c                            |  1 +
 lib/rsa/rsa-verify.c                          |  1 +
 lib/zstd/decompress.c                         |  1 +
 lib/zstd/zstd_common.c                        |  1 +
 net/mdio-uclass.c                             |  3 +
 post/post.c                                   |  1 +
 test/dm/clk.c                                 |  1 +
 test/dm/dma.c                                 |  1 +
 test/dm/gpio.c                                |  1 +
 test/dm/mailbox.c                             |  1 +
 test/dm/power-domain.c                        |  1 +
 test/dm/reset.c                               |  1 +
 test/dm/spmi.c                                |  1 +
 test/dm/tee.c                                 |  1 +
 test/dm/video.c                               |  1 +
 test/lib/lmb.c                                |  1 +
 test/unicode_ut.c                             |  1 +
 460 files changed, 593 insertions(+), 77 deletions(-)
 create mode 100644 include/dm/device_compat.h

diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c
index a1c265f46f..b3e59b1b00 100644
--- a/arch/arm/mach-imx/cmd_nandbcb.c
+++ b/arch/arm/mach-imx/cmd_nandbcb.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <nand.h>
 #include <dm/devres.h>
 
diff --git a/arch/arm/mach-imx/imx8/image.c b/arch/arm/mach-imx/imx8/image.c
index 58a29e8a03..c956a8092d 100644
--- a/arch/arm/mach-imx/imx8/image.c
+++ b/arch/arm/mach-imx/imx8/image.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <errno.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <mmc.h>
 #include <spi_flash.h>
diff --git a/arch/arm/mach-mvebu/mbus.c b/arch/arm/mach-mvebu/mbus.c
index c68e93ba10..a95db5e5c3 100644
--- a/arch/arm/mach-mvebu/mbus.c
+++ b/arch/arm/mach-mvebu/mbus.c
@@ -47,6 +47,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 6088911a1b..812f3bd5f3 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -7,6 +7,7 @@
 #include <env.h>
 #include <clk.h>
 #include <init.h>
+#include <malloc.h>
 #include <asm/armv7.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/bootrom.h>
diff --git a/arch/arm/mach-rockchip/rk3308/rk3308.c b/arch/arm/mach-rockchip/rk3308/rk3308.c
index b6815ddc55..edf5994709 100644
--- a/arch/arm/mach-rockchip/rk3308/rk3308.c
+++ b/arch/arm/mach-rockchip/rk3308/rk3308.c
@@ -3,6 +3,7 @@
  *Copyright (c) 2018 Rockchip Electronics Co., Ltd
  */
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/arch/grf_rk3308.h>
 #include <asm/arch-rockchip/hardware.h>
diff --git a/arch/arm/mach-socfpga/clock_manager_agilex.c b/arch/arm/mach-socfpga/clock_manager_agilex.c
index 791066d25b..4ee2b7b4bb 100644
--- a/arch/arm/mach-socfpga/clock_manager_agilex.c
+++ b/arch/arm/mach-socfpga/clock_manager_agilex.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/system_manager.h>
 #include <asm/io.h>
diff --git a/arch/arm/mach-socfpga/clock_manager_arria10.c b/arch/arm/mach-socfpga/clock_manager_arria10.c
index 392f2eb915..d7c8eaf47d 100644
--- a/arch/arm/mach-socfpga/clock_manager_arria10.c
+++ b/arch/arm/mach-socfpga/clock_manager_arria10.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <dm.h>
 #include <clk.h>
diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
index 977cc7d348..4559ef599d 100644
--- a/arch/arm/mach-stm32mp/pwr_regulator.c
+++ b/arch/arm/mach-stm32mp/pwr_regulator.c
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <power/pmic.h>
 #include <power/regulator.h>
diff --git a/arch/arm/mach-tegra/cboot.c b/arch/arm/mach-tegra/cboot.c
index c5361ca73d..390229436e 100644
--- a/arch/arm/mach-tegra/cboot.c
+++ b/arch/arm/mach-tegra/cboot.c
@@ -8,6 +8,7 @@
 #include <fdt_support.h>
 #include <fdtdec.h>
 #include <hang.h>
+#include <malloc.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/arch/arm/mach-zynq/clk.c b/arch/arm/mach-zynq/clk.c
index 1a6acd46cd..b578f6538a 100644
--- a/arch/arm/mach-zynq/clk.c
+++ b/arch/arm/mach-zynq/clk.c
@@ -6,6 +6,7 @@
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/arch/clk.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/arm/mach-zynq/timer.c b/arch/arm/mach-zynq/timer.c
index 211ea15884..d822e20d2b 100644
--- a/arch/arm/mach-zynq/timer.c
+++ b/arch/arm/mach-zynq/timer.c
@@ -32,6 +32,7 @@
 #include <div64.h>
 #include <dm.h>
 #include <time.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/clk.h>
diff --git a/arch/mips/mach-mtmips/cpu.c b/arch/mips/mach-mtmips/cpu.c
index cee3c0cb0a..8976ef57c7 100644
--- a/arch/mips/mach-mtmips/cpu.c
+++ b/arch/mips/mach-mtmips/cpu.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <init.h>
+#include <malloc.h>
 #include <ram.h>
 #include <wdt.h>
 #include <asm/io.h>
diff --git a/arch/mips/mach-pic32/cpu.c b/arch/mips/mach-pic32/cpu.c
index 8bb12a52c6..8075d93d41 100644
--- a/arch/mips/mach-pic32/cpu.c
+++ b/arch/mips/mach-pic32/cpu.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <mach/pic32.h>
 #include <mach/ddr.h>
 #include <dt-bindings/clock/microchip,clock.h>
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index ff7430393f..56ee3f5826 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -10,6 +10,7 @@
 #include <linux/libfdt.h>
 #include <os.h>
 #include <asm/io.h>
+#include <asm/malloc.h>
 #include <asm/setjmp.h>
 #include <asm/state.h>
 #include <dm/root.h>
diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c
index 9804227f80..92ecacf98a 100644
--- a/arch/x86/cpu/apollolake/fsp_s.c
+++ b/arch/x86/cpu/apollolake/fsp_s.c
@@ -9,6 +9,7 @@
 #include <binman.h>
 #include <dm.h>
 #include <irq.h>
+#include <malloc.h>
 #include <asm/intel_pinctrl.h>
 #include <asm/io.h>
 #include <asm/intel_regs.h>
diff --git a/arch/x86/cpu/apollolake/itss.c b/arch/x86/cpu/apollolake/itss.c
index 8789f8e6bb..a44770b7d4 100644
--- a/arch/x86/cpu/apollolake/itss.c
+++ b/arch/x86/cpu/apollolake/itss.c
@@ -13,6 +13,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <irq.h>
+#include <malloc.h>
 #include <p2sb.h>
 #include <spl.h>
 #include <asm/arch/itss.h>
diff --git a/arch/x86/cpu/apollolake/spl.c b/arch/x86/cpu/apollolake/spl.c
index 7ab7243311..d32f2a9898 100644
--- a/arch/x86/cpu/apollolake/spl.c
+++ b/arch/x86/cpu/apollolake/spl.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <binman_sym.h>
 #include <dm.h>
+#include <malloc.h>
 #include <spi.h>
 #include <spl.h>
 #include <spi_flash.h>
diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index f2b356eb44..f368f7d2db 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dt-structs.h>
+#include <malloc.h>
 #include <ns16550.h>
 #include <spl.h>
 #include <asm/io.h>
diff --git a/arch/x86/cpu/qemu/e820.c b/arch/x86/cpu/qemu/e820.c
index a4136eb98c..0da36bddea 100644
--- a/arch/x86/cpu/qemu/e820.c
+++ b/arch/x86/cpu/qemu/e820.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <env_internal.h>
+#include <malloc.h>
 #include <asm/e820.h>
 #include <asm/arch/qemu.h>
 
diff --git a/arch/x86/cpu/qfw_cpu.c b/arch/x86/cpu/qfw_cpu.c
index 49e9dfcf69..349bab1583 100644
--- a/arch/x86/cpu/qfw_cpu.c
+++ b/arch/x86/cpu/qfw_cpu.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <cpu.h>
 #include <dm.h>
+#include <malloc.h>
 #include <qfw.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
diff --git a/arch/x86/lib/coreboot_table.c b/arch/x86/lib/coreboot_table.c
index 8685aa3046..2943e11d2a 100644
--- a/arch/x86/lib/coreboot_table.c
+++ b/arch/x86/lib/coreboot_table.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <acpi_s3.h>
+#include <malloc.h>
 #include <vbe.h>
 #include <asm/coreboot_tables.h>
 #include <asm/e820.h>
diff --git a/arch/x86/lib/fsp1/fsp_common.c b/arch/x86/lib/fsp1/fsp_common.c
index ec9c218778..aee2a05044 100644
--- a/arch/x86/lib/fsp1/fsp_common.c
+++ b/arch/x86/lib/fsp1/fsp_common.c
@@ -7,6 +7,7 @@
 #include <acpi_s3.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <rtc.h>
 #include <asm/cmos_layout.h>
 #include <asm/early_cmos.h>
diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index b9420a4cab..8914960226 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <net.h>
 #include <spi.h>
 #include <spi_flash.h>
diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 99f1429363..7aea722d0b 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <smbios.h>
 #include <asm/sfi.h>
 #include <asm/mpspec.h>
diff --git a/board/compulab/common/common.c b/board/compulab/common/common.c
index cbac112dd8..2f92c6564d 100644
--- a/board/compulab/common/common.c
+++ b/board/compulab/common/common.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/bootm.h>
 #include <asm/gpio.h>
 #include <asm/setup.h>
diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c
index da33f8441c..cec819b36f 100644
--- a/board/corscience/tricorder/tricorder.c
+++ b/board/corscience/tricorder/tricorder.c
@@ -10,6 +10,7 @@
  * Frederik Kriewitz <frederik@kriewitz.eu>
  */
 #include <common.h>
+#include <malloc.h>
 #include <twl4030.h>
 #include <status_led.h>
 #include <asm/io.h>
diff --git a/board/gardena/smart-gateway-mt7688/board.c b/board/gardena/smart-gateway-mt7688/board.c
index ae03f0a434..48cf3091e9 100644
--- a/board/gardena/smart-gateway-mt7688/board.c
+++ b/board/gardena/smart-gateway-mt7688/board.c
@@ -8,6 +8,7 @@
 #include <env_internal.h>
 #include <init.h>
 #include <led.h>
+#include <malloc.h>
 #include <net.h>
 #include <spi.h>
 #include <spi_flash.h>
diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index 12410d9b71..94eeab9748 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -4,6 +4,7 @@
  */
 
 #include "vpd_reader.h"
+#include <malloc.h>
 
 #include <i2c.h>
 #include <linux/bch.h>
diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index bc9fdcd1e6..b0f8d8a314 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -9,6 +9,7 @@
 #include <env.h>
 #include <errno.h>
 #include <init.h>
+#include <malloc.h>
 #include <serial.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 74fc5f0890..1b871fdcc5 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <env.h>
+#include <malloc.h>
 #include <status_led.h>
 #include <dm.h>
 #include <ns16550.h>
diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c
index 065e6a2ccc..70a13aa17b 100644
--- a/board/menlo/m53menlo/m53menlo.c
+++ b/board/menlo/m53menlo/m53menlo.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <init.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
diff --git a/board/microchip/pic32mzda/pic32mzda.c b/board/microchip/pic32mzda/pic32mzda.c
index 8bfdee91e5..aa8aab39ce 100644
--- a/board/microchip/pic32mzda/pic32mzda.c
+++ b/board/microchip/pic32mzda/pic32mzda.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <dm.h>
 #include <clk.h>
+#include <malloc.h>
 #include <dt-bindings/clock/microchip,clock.h>
 #include <mach/pic32.h>
 
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 442028a764..baa7997477 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <dm.h>
 #include <env.h>
+#include <malloc.h>
 #include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c
index 5f5e2eb544..24429d2837 100644
--- a/board/siemens/common/board.c
+++ b/board/siemens/common/board.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <env.h>
 #include <errno.h>
+#include <malloc.h>
 #include <serial.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/siemens/pxm2/board.c b/board/siemens/pxm2/board.c
index b5a10ebf8b..58bb5bab1a 100644
--- a/board/siemens/pxm2/board.c
+++ b/board/siemens/pxm2/board.c
@@ -16,6 +16,7 @@
 #include <env.h>
 #include <errno.h>
 #include <init.h>
+#include <malloc.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
diff --git a/board/siemens/rut/board.c b/board/siemens/rut/board.c
index d7d9738a6d..bd4eaa4f3a 100644
--- a/board/siemens/rut/board.c
+++ b/board/siemens/rut/board.c
@@ -14,6 +14,7 @@
 #include <env.h>
 #include <errno.h>
 #include <init.h>
+#include <malloc.h>
 #include <spi.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 9ee2e0b3d3..ca76579405 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -16,6 +16,7 @@
 #include <i2c.h>
 #include <init.h>
 #include <led.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <misc.h>
 #include <mtd.h>
diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
index 6c75ce0870..6b6bb70e3c 100644
--- a/board/synopsys/hsdk/clk-lib.c
+++ b/board/synopsys/hsdk/clk-lib.c
@@ -5,6 +5,7 @@
  */
 
 #include <clk.h>
+#include <malloc.h>
 #include <dm/device.h>
 
 #include "clk-lib.h"
diff --git a/board/technexion/tao3530/tao3530.c b/board/technexion/tao3530/tao3530.c
index 22d26e550e..7d7c427392 100644
--- a/board/technexion/tao3530/tao3530.c
+++ b/board/technexion/tao3530/tao3530.c
@@ -4,6 +4,7 @@
  *      Tapani Utriainen <linuxfae@technexion.com>
  */
 #include <common.h>
+#include <malloc.h>
 #include <netdev.h>
 #include <twl4030.h>
 #include <asm/io.h>
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 3d7f73843c..01b28e8da4 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -12,6 +12,7 @@
 #include <env.h>
 #include <errno.h>
 #include <init.h>
+#include <malloc.h>
 #include <spl.h>
 #include <serial.h>
 #include <asm/arch/cpu.h>
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index d70ab0c4d0..7528de3e5c 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -11,6 +11,7 @@
 #include <env.h>
 #include <fdt_support.h>
 #include <init.h>
+#include <malloc.h>
 #include <palmas.h>
 #include <sata.h>
 #include <serial.h>
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index 490d8cbcd0..b037d725c3 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -18,6 +18,7 @@
 #include <common.h>
 #include <dm.h>
 #include <env.h>
+#include <malloc.h>
 #include <ns16550.h>
 #include <twl4030.h>
 #include <asm/io.h>
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 56bdff33c6..d347bd5ec0 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -13,6 +13,7 @@
 #include <efi_selftest.h>
 #include <env.h>
 #include <errno.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <linux/libfdt_env.h>
 #include <mapmem.h>
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 5f4c7ff114..8ce8ba909d 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -10,6 +10,7 @@
 #include <command.h>
 #include <errno.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/gpio.h>
 #include <linux/err.h>
 
diff --git a/cmd/host.c b/cmd/host.c
index 98c4d2a099..eefc4f255e 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -8,6 +8,7 @@
 #include <fs.h>
 #include <part.h>
 #include <sandboxblockdev.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 
 static int host_curr_device = -1;
diff --git a/cmd/rng.c b/cmd/rng.c
index 36ca7a101c..76367fed94 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -8,6 +8,7 @@
 #include <command.h>
 #include <dm.h>
 #include <hexdump.h>
+#include <malloc.h>
 #include <rng.h>
 
 static int do_rng(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 38900fb159..9eecb12ec2 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -7,6 +7,7 @@
 #include <command.h>
 #include <dm.h>
 #include <env.h>
+#include <malloc.h>
 #include <asm/unaligned.h>
 #include <linux/string.h>
 #include <tpm-common.h>
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 7fb4cdfc2a..cecf251fdb 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -15,6 +15,7 @@
 #include <command.h>
 #include <env.h>
 #include <exports.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <mtd.h>
 #include <nand.h>
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 570cf3aa50..c5c6899787 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -11,6 +11,7 @@
 #include <command.h>
 #include <console.h>
 #include <g_dnl.h>
+#include <malloc.h>
 #include <part.h>
 #include <usb.h>
 #include <usb_mass_storage.h>
diff --git a/cmd/ximg.c b/cmd/ximg.c
index dccd1143a7..770f6a3eed 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -17,6 +17,7 @@
 #include <env.h>
 #include <gzip.h>
 #include <image.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <watchdog.h>
 #if defined(CONFIG_BZIP2)
diff --git a/common/android_ab.c b/common/android_ab.c
index 6c4df419b2..e0fe32d24d 100644
--- a/common/android_ab.c
+++ b/common/android_ab.c
@@ -5,6 +5,7 @@
 #include <common.h>
 #include <android_ab.h>
 #include <android_bootloader_message.h>
+#include <malloc.h>
 #include <linux/err.h>
 #include <memalign.h>
 #include <u-boot/crc.h>
diff --git a/common/autoboot.c b/common/autoboot.c
index 94a1b4abeb..4ea9be6da9 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -13,6 +13,7 @@
 #include <env.h>
 #include <fdtdec.h>
 #include <hash.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <menu.h>
 #include <post.h>
diff --git a/common/image-fdt.c b/common/image-fdt.c
index dbb1e6e131..851bf4d85f 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -14,6 +14,7 @@
 #include <env.h>
 #include <errno.h>
 #include <image.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
diff --git a/common/image.c b/common/image.c
index 2288cff126..94873cb6ed 100644
--- a/common/image.c
+++ b/common/image.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <env.h>
+#include <malloc.h>
 #include <u-boot/crc.h>
 #include <watchdog.h>
 
diff --git a/common/usb.c b/common/usb.c
index d9bcb5a57e..349e838f1d 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <command.h>
 #include <dm.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/processor.h>
 #include <linux/compiler.h>
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 25c2ac4345..c642b683e7 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -26,6 +26,7 @@
 #include <dm.h>
 #include <env.h>
 #include <errno.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/processor.h>
 #include <asm/unaligned.h>
diff --git a/drivers/adc/stm32-adc-core.c b/drivers/adc/stm32-adc-core.c
index 04b6a8a2f5..2ca0fb4f10 100644
--- a/drivers/adc/stm32-adc-core.c
+++ b/drivers/adc/stm32-adc-core.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 #include "stm32-adc-core.h"
 
diff --git a/drivers/adc/stm32-adc.c b/drivers/adc/stm32-adc.c
index 029338e4af..ca1ac3e757 100644
--- a/drivers/adc/stm32-adc.c
+++ b/drivers/adc/stm32-adc.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <adc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 #include "stm32-adc-core.h"
 
diff --git a/drivers/axi/sandbox_store.c b/drivers/axi/sandbox_store.c
index d724f19079..a6f483ed25 100644
--- a/drivers/axi/sandbox_store.c
+++ b/drivers/axi/sandbox_store.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <axi.h>
 #include <dm.h>
+#include <malloc.h>
 
 /**
  * struct sandbox_store_priv - Private data structure of a AXI store device
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 7771114491..7c39aa5f2f 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <blk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index d3b1aaaba3..cca2237136 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -11,6 +11,7 @@
 #include <os.h>
 #include <malloc.h>
 #include <sandboxblockdev.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <dm/device-internal.h>
 
diff --git a/drivers/clk/altera/clk-arria10.c b/drivers/clk/altera/clk-arria10.c
index a39cd34fe5..affeb31fc2 100644
--- a/drivers/clk/altera/clk-arria10.c
+++ b/drivers/clk/altera/clk-arria10.c
@@ -4,9 +4,11 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/util.h>
diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index d8562e131d..a80f259a72 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <malloc.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c
index 8f02d73d8d..86bb71f612 100644
--- a/drivers/clk/at91/clk-h32mx.c
+++ b/drivers/clk/at91/clk-h32mx.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/util.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c
index c880af8155..c55e6214b2 100644
--- a/drivers/clk/at91/clk-peripheral.c
+++ b/drivers/clk/at91/clk-peripheral.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <malloc.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/clk-cdce9xx.c b/drivers/clk/clk-cdce9xx.c
index 5d1489ab0e..f1f76b0a4d 100644
--- a/drivers/clk/clk-cdce9xx.c
+++ b/drivers/clk/clk-cdce9xx.c
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <clk-uclass.h>
 #include <i2c.h>
+#include <dm/device_compat.h>
 
 #define MAX_NUMBER_OF_PLLS		4
 #define MAX_NUMER_OF_OUTPUTS		9
diff --git a/drivers/clk/clk-ti-sci.c b/drivers/clk/clk-ti-sci.c
index b085a4fc14..82241d9f3f 100644
--- a/drivers/clk/clk-ti-sci.c
+++ b/drivers/clk/clk-ti-sci.c
@@ -12,6 +12,8 @@
 #include <dm.h>
 #include <errno.h>
 #include <clk-uclass.h>
+#include <malloc.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <k3-avs.h>
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 6787d2569c..71878474eb 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <malloc.h>
 #include <dm/devres.h>
 #include <dm/read.h>
 #include <linux/clk-provider.h>
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index cc084b0644..768fbb7c52 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -7,6 +7,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <asm/clk.h>
 
 struct sandbox_clk_priv {
diff --git a/drivers/clk/clk_sandbox_ccf.c b/drivers/clk/clk_sandbox_ccf.c
index 0903c817a6..3543bea70d 100644
--- a/drivers/clk/clk_sandbox_ccf.c
+++ b/drivers/clk/clk_sandbox_ccf.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <clk.h>
+#include <malloc.h>
 #include <asm/clk.h>
 #include <clk-uclass.h>
 #include <dm/devres.h>
diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c
index 628110de3e..873383856f 100644
--- a/drivers/clk/clk_sandbox_test.c
+++ b/drivers/clk/clk_sandbox_test.c
@@ -6,7 +6,9 @@
 #include <common.h>
 #include <dm.h>
 #include <clk.h>
+#include <malloc.h>
 #include <asm/clk.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 struct sandbox_clk_test {
diff --git a/drivers/clk/clk_versal.c b/drivers/clk/clk_versal.c
index 66cbef15ab..9d4d2149e3 100644
--- a/drivers/clk/clk_versal.c
+++ b/drivers/clk/clk_versal.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <linux/bitfield.h>
 #include <malloc.h>
diff --git a/drivers/clk/clk_vexpress_osc.c b/drivers/clk/clk_vexpress_osc.c
index c692a6d0b8..82e589e239 100644
--- a/drivers/clk/clk_vexpress_osc.c
+++ b/drivers/clk/clk_vexpress_osc.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <errno.h>
 #include <misc.h>
diff --git a/drivers/clk/clk_zynq.c b/drivers/clk/clk_zynq.c
index b09c37db40..4ca1cc0d52 100644
--- a/drivers/clk/clk_zynq.c
+++ b/drivers/clk/clk_zynq.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <errno.h>
 #include <asm/io.h>
diff --git a/drivers/clk/clk_zynqmp.c b/drivers/clk/clk_zynqmp.c
index a365b565e1..e0eb897da8 100644
--- a/drivers/clk/clk_zynqmp.c
+++ b/drivers/clk/clk_zynqmp.c
@@ -6,6 +6,8 @@
  */
 
 #include <common.h>
+#include <malloc.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <clk-uclass.h>
 #include <clk.h>
diff --git a/drivers/clk/imx/clk-imx8.c b/drivers/clk/imx/clk-imx8.c
index a755e26501..671054d9be 100644
--- a/drivers/clk/imx/clk-imx8.c
+++ b/drivers/clk/imx/clk-imx8.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/arch/sci/sci.h>
 #include <asm/arch/clock.h>
 #include <dt-bindings/clock/imx8qxp-clock.h>
diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c
index b1a35968e1..068e48ea04 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -15,6 +15,7 @@
 #include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
+#include <dm/device_compat.h>
 
 #define TBG_SEL		0x0
 #define DIV_SEL0	0x4
diff --git a/drivers/clk/mvebu/armada-37xx-tbg.c b/drivers/clk/mvebu/armada-37xx-tbg.c
index aa7ccd690f..233926e9b6 100644
--- a/drivers/clk/mvebu/armada-37xx-tbg.c
+++ b/drivers/clk/mvebu/armada-37xx-tbg.c
@@ -14,6 +14,7 @@
 #include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
+#include <dm/device_compat.h>
 
 #define NUM_TBG	    4
 
diff --git a/drivers/clk/rockchip/clk_px30.c b/drivers/clk/rockchip/clk_px30.c
index 36764c128b..b88534145e 100644
--- a/drivers/clk/rockchip/clk_px30.c
+++ b/drivers/clk/rockchip/clk_px30.c
@@ -8,6 +8,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_px30.h>
diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c
index 6d5ae3d003..6e085c4136 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -7,6 +7,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/clock.h>
diff --git a/drivers/clk/rockchip/clk_rk3128.c b/drivers/clk/rockchip/clk_rk3128.c
index efda8c830b..a6f7902941 100644
--- a/drivers/clk/rockchip/clk_rk3128.c
+++ b/drivers/clk/rockchip/clk_rk3128.c
@@ -7,6 +7,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/clock.h>
diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c
index 82eea40063..2b82a40d28 100644
--- a/drivers/clk/rockchip/clk_rk3188.c
+++ b/drivers/clk/rockchip/clk_rk3188.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <syscon.h>
 #include <asm/io.h>
diff --git a/drivers/clk/rockchip/clk_rk322x.c b/drivers/clk/rockchip/clk_rk322x.c
index 6e8a164d62..ef33adbf29 100644
--- a/drivers/clk/rockchip/clk_rk322x.c
+++ b/drivers/clk/rockchip/clk_rk322x.c
@@ -7,6 +7,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/clock.h>
diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c
index 2d42f6ffc5..81cdb8ee9c 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <syscon.h>
 #include <asm/io.h>
diff --git a/drivers/clk/rockchip/clk_rk3308.c b/drivers/clk/rockchip/clk_rk3308.c
index f212c5ffc2..c0f1285e4c 100644
--- a/drivers/clk/rockchip/clk_rk3308.c
+++ b/drivers/clk/rockchip/clk_rk3308.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <div64.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch/cru_rk3308.h>
diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
index e700a1bc25..8e867c58df 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -8,6 +8,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3328.h>
diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c
index b51d529ade..2cce1b967d 100644
--- a/drivers/clk/rockchip/clk_rk3368.c
+++ b/drivers/clk/rockchip/clk_rk3368.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <syscon.h>
 #include <bitfield.h>
diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
index 37fc142a7a..865b80cc0f 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <syscon.h>
 #include <bitfield.h>
diff --git a/drivers/clk/rockchip/clk_rv1108.c b/drivers/clk/rockchip/clk_rv1108.c
index 97fdd099ef..da9c48b962 100644
--- a/drivers/clk/rockchip/clk_rv1108.c
+++ b/drivers/clk/rockchip/clk_rv1108.c
@@ -9,6 +9,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/clock.h>
diff --git a/drivers/clk/tegra/tegra-car-clk.c b/drivers/clk/tegra/tegra-car-clk.c
index 07e8734b3a..6083f14e75 100644
--- a/drivers/clk/tegra/tegra-car-clk.c
+++ b/drivers/clk/tegra/tegra-car-clk.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/arch/clock.h>
 #include <asm/arch-tegra/clk_rst.h>
 
diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c
index 1da63819e7..9f24050992 100644
--- a/drivers/clk/uniphier/clk-uniphier-core.c
+++ b/drivers/clk/uniphier/clk-uniphier-core.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index d98e80de26..457e1309c5 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -10,6 +10,7 @@
 #define LOG_CATEGORY LOGC_DEVRES
 
 #include <common.h>
+#include <malloc.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 945b81448c..acd745c121 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -20,6 +20,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <dm/of_access.h>
 #include <linux/ctype.h>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 8f0eab2ca6..e523c2e2bf 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <fdt_support.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index 5bb38e329c..ac2de47515 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <regmap.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <linux/err.h>
diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c
index a3b914fdfc..381b11b503 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -15,6 +15,7 @@
 #include <asm/arch/sdram.h>
 #include <asm/arch/system_manager.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 #include "sequencer.h"
 
diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c
index e0d04ccca2..1f7ead0c67 100644
--- a/drivers/ddr/altera/sdram_soc64.c
+++ b/drivers/ddr/altera/sdram_soc64.c
@@ -19,6 +19,7 @@
 #include <asm/arch/system_manager.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/sizes.h>
 
 #define PGTABLE_OFF	0x4000
diff --git a/drivers/dma/bcm6348-iudma.c b/drivers/dma/bcm6348-iudma.c
index 96250eb5d2..d99460f2fb 100644
--- a/drivers/dma/bcm6348-iudma.c
+++ b/drivers/dma/bcm6348-iudma.c
@@ -20,6 +20,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <dma-uclass.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <reset.h>
 #include <asm/io.h>
diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index a0159d7888..9d5a7fc796 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/read.h>
 #include <dma-uclass.h>
 #include <dt-structs.h>
diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c
index d009bb2168..234a7d2134 100644
--- a/drivers/dma/sandbox-dma-test.c
+++ b/drivers/dma/sandbox-dma-test.c
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/read.h>
 #include <dma-uclass.h>
 #include <dt-structs.h>
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index ab516b573c..f274100f32 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -12,6 +12,7 @@
 #include <malloc.h>
 #include <asm/dma-mapping.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/read.h>
 #include <dm/of_access.h>
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 5e37ee0570..99b2e5dfed 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -11,7 +11,9 @@
 #include <dm.h>
 #include <errno.h>
 #include <mailbox.h>
+#include <malloc.h>
 #include <dm/device.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/err.h>
diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
index 7e8bd7eae8..0917871d49 100644
--- a/drivers/fpga/fpga.c
+++ b/drivers/fpga/fpga.c
@@ -9,6 +9,7 @@
 #include <xilinx.h>             /* xilinx specific definitions */
 #include <altera.h>             /* altera specific definitions */
 #include <lattice.h>
+#include <dm/device_compat.h>
 
 /* Local definitions */
 #ifndef CONFIG_MAX_FPGA_DEVICES
diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c
index dcb1c1b369..64717a6780 100644
--- a/drivers/gpio/74x164_gpio.c
+++ b/drivers/gpio/74x164_gpio.c
@@ -15,6 +15,7 @@
 #include <malloc.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <dt-bindings/gpio/gpio.h>
 #include <spi.h>
 
diff --git a/drivers/gpio/adi_gpio2.c b/drivers/gpio/adi_gpio2.c
index 1012f2d8eb..9d293b6994 100644
--- a/drivers/gpio/adi_gpio2.c
+++ b/drivers/gpio/adi_gpio2.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <linux/errno.h>
 #include <asm/gpio.h>
 
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 5ea3e77b2d..3621cf2408 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <linux/sizes.h>
 #include <asm/gpio.h>
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index 8e6f32de1f..a3f5e7a2e0 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -9,6 +9,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <asm/arch/hardware.h>
 #include <asm/gpio.h>
 #include <mach/gpio.h>
diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c
index bd5a366aef..eb1b22c187 100644
--- a/drivers/gpio/da8xx_gpio.c
+++ b/drivers/gpio/da8xx_gpio.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dt-bindings/gpio/gpio.h>
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 58e3e7b1f7..e3439eebb5 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/root.h>
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index a8c5b7f879..9dc4cd6042 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -6,6 +6,8 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <errno.h>
 #include <asm/gpio.h>
diff --git a/drivers/gpio/kona_gpio.c b/drivers/gpio/kona_gpio.c
index 912a4cac59..29791882a3 100644
--- a/drivers/gpio/kona_gpio.c
+++ b/drivers/gpio/kona_gpio.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/arch/sysmap.h>
 
diff --git a/drivers/gpio/mpc83xx_gpio.c b/drivers/gpio/mpc83xx_gpio.c
index dcd78e7e88..276a3b350d 100644
--- a/drivers/gpio/mpc83xx_gpio.c
+++ b/drivers/gpio/mpc83xx_gpio.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <mpc83xx.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
diff --git a/drivers/gpio/mscc_sgpio.c b/drivers/gpio/mscc_sgpio.c
index 3378ebb442..c65ca81728 100644
--- a/drivers/gpio/mscc_sgpio.c
+++ b/drivers/gpio/mscc_sgpio.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <errno.h>
 #include <clk.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #define MSCC_SGPIOS_PER_BANK	32
diff --git a/drivers/gpio/mvgpio.c b/drivers/gpio/mvgpio.c
index ea2f689d60..12e7197daf 100644
--- a/drivers/gpio/mvgpio.c
+++ b/drivers/gpio/mvgpio.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <linux/errno.h>
 #include "mvgpio.h"
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index 77778e9ce5..405e9ac135 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/arch/iomux.h>
diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c
index 07a3356b3c..5527e575e9 100644
--- a/drivers/gpio/pca953x_gpio.c
+++ b/drivers/gpio/pca953x_gpio.c
@@ -27,6 +27,7 @@
 #include <malloc.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <dt-bindings/gpio/gpio.h>
 
 #define PCA953X_INPUT           0
diff --git a/drivers/gpio/pca9698.c b/drivers/gpio/pca9698.c
index ab0c4c1b97..11274c7810 100644
--- a/drivers/gpio/pca9698.c
+++ b/drivers/gpio/pca9698.c
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <linux/errno.h>
 #include <pca9698.h>
 
diff --git a/drivers/gpio/sh_pfc.c b/drivers/gpio/sh_pfc.c
index ad8da9ef28..6320a6280d 100644
--- a/drivers/gpio/sh_pfc.c
+++ b/drivers/gpio/sh_pfc.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/bitops.h>
 #include <asm/io.h>
 #include <sh_pfc.h>
diff --git a/drivers/gpio/spear_gpio.c b/drivers/gpio/spear_gpio.c
index 525aa3b9ac..4e4cd12545 100644
--- a/drivers/gpio/spear_gpio.c
+++ b/drivers/gpio/spear_gpio.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/arch/hardware.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
index 302a434947..f55f834e7d 100644
--- a/drivers/gpio/stm32_gpio.c
+++ b/drivers/gpio/stm32_gpio.c
@@ -12,6 +12,7 @@
 #include <asm/arch/stm32.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 
diff --git a/drivers/hwspinlock/hwspinlock-uclass.c b/drivers/hwspinlock/hwspinlock-uclass.c
index 195f079707..61d226bcbb 100644
--- a/drivers/hwspinlock/hwspinlock-uclass.c
+++ b/drivers/hwspinlock/hwspinlock-uclass.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 #include <hwspinlock.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
+#include <linux/compat.h>
 
 static inline const struct hwspinlock_ops *
 hwspinlock_dev_ops(struct udevice *dev)
diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c
index a32bde4906..74afb4aec2 100644
--- a/drivers/hwspinlock/stm32_hwspinlock.c
+++ b/drivers/hwspinlock/stm32_hwspinlock.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <hwspinlock.h>
+#include <malloc.h>
 #include <asm/io.h>
 
 #define STM32_MUTEX_COREID	BIT(8)
diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index 846b3d5320..c817ed6bf9 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -5,6 +5,7 @@
  * (C) Copyright 2016 Songjun Wu <songjun.wu@atmel.com>
  */
 
+#include <malloc.h>
 #include <asm/io.h>
 #include <common.h>
 #include <clk.h>
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index ae9cf16297..e1d5aeb19d 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -8,10 +8,12 @@
 #include <clk.h>
 #include <dm.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <pci.h>
 #include <reset.h>
 #include <asm/io.h>
 #include "designware_i2c.h"
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #ifdef CONFIG_SYS_I2C_DW_ENABLE_STATUS_UNSUPPORTED
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index 62acd28e1b..d8b4a683bc 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -5,6 +5,7 @@
  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  */
 
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 07a7e03033..f06523ab99 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -5,6 +5,7 @@
  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  */
 
+#include <dm/device_compat.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/io.h>
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index c9d3faa911..62e68046d6 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -13,6 +13,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <i2c.h>
+#include <dm/device_compat.h>
 
 #define LPI2C_FIFO_SIZE 4
 #define LPI2C_NACK_TOUT_MS 1
diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
index 413aaa6ba3..5029c71adc 100644
--- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
+++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 29e283ce25..0575bd8937 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -11,6 +11,7 @@
 #include <asm-generic/gpio.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/pinctrl.h>
 #include <fdtdec.h>
diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index 8b1149997a..9a3dd7ec4a 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <dm/lists.h>
 #include <dm/root.h>
 
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index bb2935f8ec..be90a7b24a 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <i2c.h>
+#include <malloc.h>
 
 #include <asm-generic/gpio.h>
 
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 786b5a2226..5afb6a2958 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -16,6 +16,7 @@
 #include <common.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <asm/mach-imx/mxc_i2c.h>
 #include <asm/io.h>
diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
index 05d0dc6012..b877602aab 100644
--- a/drivers/i2c/rcar_i2c.c
+++ b/drivers/i2c/rcar_i2c.c
@@ -17,6 +17,7 @@
 #include <i2c.h>
 #include <asm/io.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 
 #define RCAR_I2C_ICSCR			0x00 /* slave ctrl */
 #define RCAR_I2C_ICMCR			0x04 /* master ctrl */
diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index 21dfa5023b..7d046c1a1e 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <reset.h>
 
 #include <dm/device.h>
diff --git a/drivers/i2c/xilinx_xiic.c b/drivers/i2c/xilinx_xiic.c
index 5ce0f869c7..149bd327bd 100644
--- a/drivers/i2c/xilinx_xiic.c
+++ b/drivers/i2c/xilinx_xiic.c
@@ -15,6 +15,7 @@
 #include <i2c.h>
 #include <wait_bit.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 struct xilinx_xiic_priv {
 	void __iomem		*base;
diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 93f6b913c6..af6b8245c9 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <led.h>
+#include <malloc.h>
 #include <asm/gpio.h>
 #include <dm/lists.h>
 
diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c
index 1194c6f029..a560209f03 100644
--- a/drivers/mailbox/k3-sec-proxy.c
+++ b/drivers/mailbox/k3-sec-proxy.c
@@ -7,7 +7,9 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/soc/ti/k3-sec-proxy.h>
diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index a6d2d1f5b8..291f5c218e 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <mailbox.h>
 #include <mailbox-uclass.h>
+#include <malloc.h>
 #include <time.h>
 
 static inline struct mbox_ops *mbox_dev_ops(struct udevice *dev)
diff --git a/drivers/mailbox/sandbox-mbox-test.c b/drivers/mailbox/sandbox-mbox-test.c
index ba1bb1cf95..faca8fcc44 100644
--- a/drivers/mailbox/sandbox-mbox-test.c
+++ b/drivers/mailbox/sandbox-mbox-test.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <mailbox.h>
+#include <malloc.h>
 #include <asm/io.h>
 
 struct sandbox_mbox_test {
diff --git a/drivers/mailbox/sandbox-mbox.c b/drivers/mailbox/sandbox-mbox.c
index 442ca633a1..25e23eb05b 100644
--- a/drivers/mailbox/sandbox-mbox.c
+++ b/drivers/mailbox/sandbox-mbox.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <mailbox-uclass.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/mbox.h>
 
diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
index d4035a85f2..13e642ab70 100644
--- a/drivers/mailbox/stm32-ipcc.c
+++ b/drivers/mailbox/stm32-ipcc.c
@@ -7,7 +7,9 @@
 #include <clk.h>
 #include <dm.h>
 #include <mailbox-uclass.h>
+#include <malloc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 /*
  * IPCC has one set of registers per CPU
diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index c463e6a2be..60f6a38321 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <dm.h>
 #include <mailbox-uclass.h>
diff --git a/drivers/mailbox/zynqmp-ipi.c b/drivers/mailbox/zynqmp-ipi.c
index c181a7b817..17b46545f5 100644
--- a/drivers/mailbox/zynqmp-ipi.c
+++ b/drivers/mailbox/zynqmp-ipi.c
@@ -9,6 +9,7 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <mailbox-uclass.h>
+#include <dm/device_compat.h>
 #include <mach/sys_proto.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c
index b34191753b..3ad21c1ea0 100644
--- a/drivers/misc/imx8/scu_api.c
+++ b/drivers/misc/imx8/scu_api.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <hang.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <dm.h>
 #include <asm/arch/sci/sci.h>
diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c
index c19c3c0646..47e42738e0 100644
--- a/drivers/misc/k3_avs.c
+++ b/drivers/misc/k3_avs.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <i2c.h>
 #include <k3-avs.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 
 #define AM6_VTM_DEVINFO(i)	(priv->base + 0x100 + 0x20 * (i))
diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c
index a198700b5f..9fe0aca342 100644
--- a/drivers/misc/p2sb-uclass.c
+++ b/drivers/misc/p2sb-uclass.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <p2sb.h>
 #include <spl.h>
diff --git a/drivers/misc/stm32_rcc.c b/drivers/misc/stm32_rcc.c
index e7efcdeafa..980b84453e 100644
--- a/drivers/misc/stm32_rcc.c
+++ b/drivers/misc/stm32_rcc.c
@@ -9,6 +9,7 @@
 #include <misc.h>
 #include <stm32_rcc.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 
 struct stm32_rcc_clk stm32_rcc_clk_f42x = {
diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c
index 489337c3d0..ce2b925173 100644
--- a/drivers/misc/tegra186_bpmp.c
+++ b/drivers/misc/tegra186_bpmp.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <time.h>
 #include <dm/lists.h>
 #include <dm/root.h>
diff --git a/drivers/misc/vexpress_config.c b/drivers/misc/vexpress_config.c
index 9f5baa5288..53d7e1d154 100644
--- a/drivers/misc/vexpress_config.c
+++ b/drivers/misc/vexpress_config.c
@@ -6,6 +6,7 @@
  */
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/read.h>
 #include <asm/io.h>
 #include <linux/delay.h>
diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c
index 6053d3d536..aad9d8b85b 100644
--- a/drivers/mmc/am654_sdhci.c
+++ b/drivers/mmc/am654_sdhci.c
@@ -12,6 +12,7 @@
 #include <power-domain.h>
 #include <regmap.h>
 #include <sdhci.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 /* CTL_CFG Registers */
diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index ea8eb0d509..d396afc14c 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -16,6 +16,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <mmc.h>
+#include <dm/device_compat.h>
 
 #include <asm/io.h>
 #include <asm-generic/gpio.h>
diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c
index 7f70acaf39..8cebf99c58 100644
--- a/drivers/mmc/bcm2835_sdhost.c
+++ b/drivers/mmc/bcm2835_sdhost.c
@@ -36,6 +36,7 @@
 #include <asm/arch/msg.h>
 #include <asm/arch/mbox.h>
 #include <asm/unaligned.h>
+#include <dm/device_compat.h>
 #include <linux/compat.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 112f115015..ab40019ccb 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -22,6 +22,7 @@
 #include <fdt_support.h>
 #include <asm/io.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 7cbd6e4587..4900498e9b 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -19,6 +19,7 @@
 #include <hwconfig.h>
 #include <mmc.h>
 #include <part.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <power/regulator.h>
 #include <malloc.h>
diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c
index cb2a7c3eb5..8d4f886cb4 100644
--- a/drivers/mmc/jz_mmc.c
+++ b/drivers/mmc/jz_mmc.c
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <asm/unaligned.h>
 #include <errno.h>
+#include <dm/device_compat.h>
 #include <mach/jz4780.h>
 #include <wait_bit.h>
 
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index c7a832ca90..0b90a97650 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -8,7 +8,9 @@
 #include <mmc.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
+#include <linux/compat.h>
 #include "mmc_private.h"
 
 int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index cae42ec4ac..da3ae2ec35 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <sdhci.h>
 #include <wait_bit.h>
 #include <asm/io.h>
diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index d4870818a8..bd1fb09d1c 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -15,6 +15,7 @@
 #include <mapmem.h>
 #include <stdbool.h>
 #include <asm/gpio.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index e01ac310e9..c3b13136f8 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -6,8 +6,10 @@
 #include <common.h>
 #include <clk.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <mmc.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/compat.h>
 #include <linux/dma-direction.h>
 #include <linux/io.h>
diff --git a/drivers/mmc/sdhci-cadence.c b/drivers/mmc/sdhci-cadence.c
index 4736263bf2..e9108dabd1 100644
--- a/drivers/mmc/sdhci-cadence.c
+++ b/drivers/mmc/sdhci-cadence.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/bitfield.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
diff --git a/drivers/mmc/sh_mmcif.c b/drivers/mmc/sh_mmcif.c
index c8875ce8f8..29bbb4b3a6 100644
--- a/drivers/mmc/sh_mmcif.c
+++ b/drivers/mmc/sh_mmcif.c
@@ -13,6 +13,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <malloc.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <linux/compat.h>
 #include <linux/io.h>
diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c
index e38e8abfef..2202158c88 100644
--- a/drivers/mmc/sh_sdhi.c
+++ b/drivers/mmc/sh_sdhi.c
@@ -13,6 +13,7 @@
 #include <malloc.h>
 #include <mmc.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <linux/compat.h>
 #include <linux/io.h>
diff --git a/drivers/mmc/snps_dw_mmc.c b/drivers/mmc/snps_dw_mmc.c
index 5a413f0ec7..c606ef011b 100644
--- a/drivers/mmc/snps_dw_mmc.c
+++ b/drivers/mmc/snps_dw_mmc.c
@@ -13,6 +13,7 @@
 #include <dwmmc.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <dm/device_compat.h>
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <malloc.h>
diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
index 568a3e77d3..786cdc700a 100644
--- a/drivers/mmc/socfpga_dw_mmc.c
+++ b/drivers/mmc/socfpga_dw_mmc.c
@@ -11,6 +11,7 @@
 #include <dwmmc.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <dm/device_compat.h>
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <malloc.h>
diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
index 0a7a2fe624..6f3b2ad653 100644
--- a/drivers/mmc/stm32_sdmmc2.c
+++ b/drivers/mmc/stm32_sdmmc2.c
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <mmc.h>
 #include <reset.h>
diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index 5a8506dcb6..092b740f56 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <mmc.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <linux/compat.h>
 #include <linux/dma-direction.h>
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 8f89bda233..4dbe71fa2e 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -7,8 +7,10 @@
 #include <common.h>
 #include <clk.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <mmc.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/compat.h>
 #include <linux/dma-direction.h>
 #include <linux/io.h>
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 83c32a361a..24fabeee95 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include "mmc_private.h"
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/libfdt.h>
 #include <malloc.h>
diff --git a/drivers/mtd/hbmc-am654.c b/drivers/mtd/hbmc-am654.c
index 5a560f1253..846b0e832b 100644
--- a/drivers/mtd/hbmc-am654.c
+++ b/drivers/mtd/hbmc-am654.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <dm/device_compat.h>
 
 #define FSS_SYSC_REG	0x4
 
diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index 17df8b0ffc..db20a6b0b2 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <env.h>
+#include <malloc.h>
 #include <dm/device.h>
 #include <dm/uclass-internal.h>
 #include <linux/err.h>
diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 3abaef23c5..bc0accf8c6 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #ifndef __UBOOT__
+#include <linux/compat.h>
 #include <linux/module.h>
 #endif
 #include <linux/mtd/nand.h>
diff --git a/drivers/mtd/nand/raw/atmel_nand.c b/drivers/mtd/nand/raw/atmel_nand.c
index 3526585349..996d3dbb71 100644
--- a/drivers/mtd/nand/raw/atmel_nand.c
+++ b/drivers/mtd/nand/raw/atmel_nand.c
@@ -13,6 +13,7 @@
 #include <common.h>
 #include <asm/gpio.h>
 #include <asm/arch/gpio.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 
 #include <malloc.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index d3e39661e1..5232328e1e 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -17,6 +17,7 @@
 #include <memalign.h>
 #include <nand.h>
 #include <clk.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/ioport.h>
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
index bb8aea2d01..c58679834e 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
@@ -1,8 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0+
 
 #include <common.h>
-#include "brcmnand_compat.h"
+#include <malloc.h>
 #include <dm/devres.h>
+#include "brcmnand_compat.h"
 
 static char *devm_kvasprintf(struct udevice *dev, gfp_t gfp, const char *fmt,
 			     va_list ap)
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index 235a5fcd52..f51d3e25c7 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -7,7 +7,9 @@
 
 #include <asm/dma-mapping.h>
 #include <dm.h>
+#include <malloc.h>
 #include <nand.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/bitfield.h>
 #include <linux/dma-direction.h>
diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index 759ad40e51..41b93e660a 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -6,6 +6,7 @@
 
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c
index e179a780db..03f210bdb0 100644
--- a/drivers/mtd/nand/raw/pxa3xx_nand.c
+++ b/drivers/mtd/nand/raw/pxa3xx_nand.c
@@ -10,6 +10,7 @@
 #include <malloc.h>
 #include <fdtdec.h>
 #include <nand.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/errno.h>
diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index cd5c31e76b..9b99be10e6 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -26,8 +26,10 @@
 
 #include <common.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <nand.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 
diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c
index 74acdfb308..ae699d1da5 100644
--- a/drivers/mtd/nand/raw/tegra_nand.c
+++ b/drivers/mtd/nand/raw/tegra_nand.c
@@ -13,6 +13,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
 #include <asm/arch-tegra/clk_rst.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <fdtdec.h>
diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index 3326c2b096..52c8a94778 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -23,6 +23,7 @@
 
 #include <common.h>
 #include <malloc.h>
+#include <dm/device_compat.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index d976c19b7a..cd624ec6ae 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/mtd/spinand.h>
 #endif
diff --git a/drivers/mtd/nand/spi/gigadevice.c b/drivers/mtd/nand/spi/gigadevice.c
index e329c3cfc0..0b228dcb5b 100644
--- a/drivers/mtd/nand/spi/gigadevice.c
+++ b/drivers/mtd/nand/spi/gigadevice.c
@@ -7,6 +7,7 @@
  */
 
 #ifndef __UBOOT__
+#include <malloc.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #endif
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 1119677f6f..67d092be2c 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -6,6 +6,7 @@
  */
 
 #ifndef __UBOOT__
+#include <malloc.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #endif
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 9c24542f96..687306e33e 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -7,6 +7,7 @@
  */
 
 #ifndef __UBOOT__
+#include <malloc.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #endif
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index de9352e48f..6ede98c85d 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -8,6 +8,7 @@
  */
 
 #ifndef __UBOOT__
+#include <malloc.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #endif
diff --git a/drivers/mtd/renesas_rpc_hf.c b/drivers/mtd/renesas_rpc_hf.c
index f5c6515c9b..fc2aa22d7f 100644
--- a/drivers/mtd/renesas_rpc_hf.c
+++ b/drivers/mtd/renesas_rpc_hf.c
@@ -8,9 +8,11 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/of_access.h>
 #include <errno.h>
 #include <fdt_support.h>
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index c6107522be..5ebcca590a 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <spi.h>
 #include <spi_flash.h>
 #include <dm/device-internal.h>
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index b27e442218..7b6ad495ac 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/errno.h>
diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index c19d468d62..ccc0ab07af 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/log2.h>
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index aec2613a09..d2b7ca5e33 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -6,6 +6,7 @@
  */
 
 #include <hexdump.h>
+#include <malloc.h>
 #include <ubi_uboot.h>
 #include "ubi.h"
 #ifndef __UBOOT__
diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c
index 685324d7d2..3f7ee59c94 100644
--- a/drivers/mtd/ubi/misc.c
+++ b/drivers/mtd/ubi/misc.c
@@ -7,6 +7,7 @@
 
 /* Here we keep miscellaneous functions which are used all over the UBI code */
 
+#include <malloc.h>
 #include <ubi_uboot.h>
 #include "ubi.h"
 
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index d0a6a1bd18..0f7951c859 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -26,6 +26,7 @@
  */
 
 #ifndef __UBOOT__
+#include <malloc.h>
 #include <linux/uaccess.h>
 #else
 #include <div64.h>
diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c
index 7100e68bd2..fe3532930a 100644
--- a/drivers/net/bcm6348-eth.c
+++ b/drivers/net/bcm6348-eth.c
@@ -10,6 +10,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <dma.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
 #include <phy.h>
diff --git a/drivers/net/bcm6368-eth.c b/drivers/net/bcm6368-eth.c
index 110985ed1d..1200049007 100644
--- a/drivers/net/bcm6368-eth.c
+++ b/drivers/net/bcm6368-eth.c
@@ -10,11 +10,13 @@
 #include <clk.h>
 #include <dm.h>
 #include <dma.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
 #include <reset.h>
 #include <wait_bit.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 #define ETH_PORT_STR			"brcm,enetsw-port"
 
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index aa33fd511b..baac277a84 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -17,6 +17,7 @@
 #include <malloc.h>
 #include <pci.h>
 #include <reset.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 4632111635..0564bebf76 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -31,6 +31,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <miiphy.h>
 #include <net.h>
diff --git a/drivers/net/dwmac_socfpga.c b/drivers/net/dwmac_socfpga.c
index 66a5f95112..e93561dffa 100644
--- a/drivers/net/dwmac_socfpga.c
+++ b/drivers/net/dwmac_socfpga.c
@@ -14,6 +14,7 @@
 #include <reset.h>
 #include <syscon.h>
 #include "designware.h"
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #include <asm/arch/system_manager.h>
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 0946011844..9212920549 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -33,6 +33,7 @@ tested on both gig copper and gig fiber boards
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <pci.h>
 #include "e1000.h"
diff --git a/drivers/net/e1000_spi.c b/drivers/net/e1000_spi.c
index aecd290d72..52b3c79794 100644
--- a/drivers/net/e1000_spi.c
+++ b/drivers/net/e1000_spi.c
@@ -1,6 +1,7 @@
 #include <common.h>
 #include <console.h>
 #include "e1000.h"
+#include <malloc.h>
 #include <linux/compiler.h>
 
 /*-----------------------------------------------------------------------
diff --git a/drivers/net/fsl-mc/dpio/qbman_portal.c b/drivers/net/fsl-mc/dpio/qbman_portal.c
index c51354cfa1..e161b4e077 100644
--- a/drivers/net/fsl-mc/dpio/qbman_portal.c
+++ b/drivers/net/fsl-mc/dpio/qbman_portal.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2014 Freescale Semiconductor
  */
 
+#include <malloc.h>
 #include <asm/arch/clock.h>
 #include "qbman_portal.h"
 
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 8ff43a91c7..07bbcc9b23 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -8,6 +8,7 @@
 #include <cpu_func.h>
 #include <env.h>
 #include <errno.h>
+#include <malloc.h>
 #include <linux/bug.h>
 #include <asm/io.h>
 #include <linux/libfdt.h>
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index f0d15febcc..bee73153d0 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/io.h>
 #include <pci.h>
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index ebb74339b2..40e6b3ba39 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -14,9 +14,11 @@
 #include <clk.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 
diff --git a/drivers/net/higmacv300.c b/drivers/net/higmacv300.c
index 897741ab82..0c1dd6834a 100644
--- a/drivers/net/higmacv300.c
+++ b/drivers/net/higmacv300.c
@@ -4,6 +4,7 @@
  */
 
 #include <cpu_func.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <common.h>
 #include <console.h>
diff --git a/drivers/net/mscc_eswitch/jr2_switch.c b/drivers/net/mscc_eswitch/jr2_switch.c
index 665517775e..33dd002146 100644
--- a/drivers/net/mscc_eswitch/jr2_switch.c
+++ b/drivers/net/mscc_eswitch/jr2_switch.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <fdt_support.h>
diff --git a/drivers/net/mscc_eswitch/luton_switch.c b/drivers/net/mscc_eswitch/luton_switch.c
index dffe81d873..9d24c005c1 100644
--- a/drivers/net/mscc_eswitch/luton_switch.c
+++ b/drivers/net/mscc_eswitch/luton_switch.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <fdt_support.h>
diff --git a/drivers/net/mscc_eswitch/ocelot_switch.c b/drivers/net/mscc_eswitch/ocelot_switch.c
index 0ba84ab78a..fe48f371c3 100644
--- a/drivers/net/mscc_eswitch/ocelot_switch.c
+++ b/drivers/net/mscc_eswitch/ocelot_switch.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <fdt_support.h>
diff --git a/drivers/net/mscc_eswitch/serval_switch.c b/drivers/net/mscc_eswitch/serval_switch.c
index 1a21360a96..f05fa42ff3 100644
--- a/drivers/net/mscc_eswitch/serval_switch.c
+++ b/drivers/net/mscc_eswitch/serval_switch.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <fdt_support.h>
diff --git a/drivers/net/mscc_eswitch/servalt_switch.c b/drivers/net/mscc_eswitch/servalt_switch.c
index d20ec49d56..bf95a38354 100644
--- a/drivers/net/mscc_eswitch/servalt_switch.c
+++ b/drivers/net/mscc_eswitch/servalt_switch.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
 #include <fdt_support.h>
diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c
index c22e590387..77589b2a04 100644
--- a/drivers/net/mtk_eth.c
+++ b/drivers/net/mtk_eth.c
@@ -17,6 +17,7 @@
 #include <wait_bit.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/ioport.h>
 #include <linux/mdio.h>
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 505fabd3fa..d737400a20 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/errno.h>
 #include <phy.h>
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 105fdc994a..fcd24868af 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -17,6 +17,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <net.h>
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index e4507bf7fd..b2823701a4 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <pci.h>
 #include <miiphy.h>
diff --git a/drivers/net/pfe_eth/pfe_driver.c b/drivers/net/pfe_eth/pfe_driver.c
index 14a8c68276..f70a235217 100644
--- a/drivers/net/pfe_eth/pfe_driver.c
+++ b/drivers/net/pfe_eth/pfe_driver.c
@@ -4,6 +4,7 @@
  * Copyright 2017 NXP
  */
 
+#include <malloc.h>
 #include <net/pfe_eth/pfe_eth.h>
 #include <net/pfe_eth/pfe_firmware.h>
 
diff --git a/drivers/net/pfe_eth/pfe_eth.c b/drivers/net/pfe_eth/pfe_eth.c
index c525674fb8..1b5d11ef32 100644
--- a/drivers/net/pfe_eth/pfe_eth.c
+++ b/drivers/net/pfe_eth/pfe_eth.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/platform_data/pfe_dm_eth.h>
 #include <net.h>
 #include <net/pfe_eth/pfe_eth.h>
diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c
index e4563f192b..13112d9c1a 100644
--- a/drivers/net/pfe_eth/pfe_firmware.c
+++ b/drivers/net/pfe_eth/pfe_firmware.c
@@ -10,6 +10,7 @@
  * files.
  */
 
+#include <malloc.h>
 #include <net/pfe_eth/pfe_eth.h>
 #include <net/pfe_eth/pfe_firmware.h>
 #ifdef CONFIG_CHAIN_OF_TRUST
diff --git a/drivers/net/pfe_eth/pfe_mdio.c b/drivers/net/pfe_eth/pfe_mdio.c
index 62309670fa..b990e7fbe2 100644
--- a/drivers/net/pfe_eth/pfe_mdio.c
+++ b/drivers/net/pfe_eth/pfe_mdio.c
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/platform_data/pfe_dm_eth.h>
 #include <net.h>
 #include <net/pfe_eth/pfe_eth.h>
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 0ae0edd0e1..9d9f746e1d 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -7,6 +7,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <malloc.h>
 #include <phy.h>
 #include <dm.h>
 #include <fdt_support.h>
diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c
index 3458440b6f..e966be038a 100644
--- a/drivers/net/pic32_eth.c
+++ b/drivers/net/pic32_eth.c
@@ -7,6 +7,7 @@
 #include <cpu_func.h>
 #include <errno.h>
 #include <dm.h>
+#include <malloc.h>
 #include <net.h>
 #include <miiphy.h>
 #include <console.h>
diff --git a/drivers/net/sandbox-raw-bus.c b/drivers/net/sandbox-raw-bus.c
index 0086f25fc1..fb1ba5a8c8 100644
--- a/drivers/net/sandbox-raw-bus.c
+++ b/drivers/net/sandbox-raw-bus.c
@@ -8,6 +8,7 @@
 #include <asm/eth-raw-os.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 
diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c
index 64e92abb03..5d66a63a8b 100644
--- a/drivers/net/sni_ave.c
+++ b/drivers/net/sni_ave.c
@@ -8,14 +8,16 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <fdt_support.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/iopoll.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
 #include <regmap.h>
 #include <reset.h>
 #include <syscon.h>
+#include <dm/device_compat.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
 
 #define AVE_GRST_DELAY_MSEC	40
 #define AVE_MIN_XMITSIZE	60
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 6f10578c88..1ae776b446 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -18,6 +18,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <fdt_support.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <malloc.h>
 #include <miiphy.h>
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index 9a5f7fd3c7..a9874e4220 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <malloc.h>
 #include <miiphy.h>
diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
index 2590486810..2b77213001 100644
--- a/drivers/net/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ti/am65-cpsw-nuss.c
@@ -7,10 +7,12 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dma-uclass.h>
 #include <dm/of_access.h>
diff --git a/drivers/net/ti/cpsw-common.c b/drivers/net/ti/cpsw-common.c
index 21b8bbda3d..ca93edb70e 100644
--- a/drivers/net/ti/cpsw-common.c
+++ b/drivers/net/ti/cpsw-common.c
@@ -10,6 +10,7 @@
 #include <fdt_support.h>
 #include <asm/io.h>
 #include <cpsw.h>
+#include <dm/device_compat.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 57625623c2..04b01a8129 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -14,6 +14,7 @@
 #include <net.h>
 #include <netdev.h>
 #include <cpsw.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
diff --git a/drivers/net/ti/cpsw_mdio.c b/drivers/net/ti/cpsw_mdio.c
index 6e8f652011..1fa520be0f 100644
--- a/drivers/net/ti/cpsw_mdio.c
+++ b/drivers/net/ti/cpsw_mdio.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <miiphy.h>
 #include <wait_bit.h>
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 3d9d5205a1..288037e2a0 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -25,6 +25,7 @@
 #include <asm/system.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 2593eb174b..ef4382da1a 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -8,10 +8,12 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <pci.h>
 #include <time.h>
 #include <dm/device-internal.h>
+#include <linux/compat.h>
 #include "nvme.h"
 
 #define NVME_Q_DEPTH		2
diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c
index aa0b4bc845..bf0b7611ba 100644
--- a/drivers/pci/pci-aardvark.c
+++ b/drivers/pci/pci-aardvark.c
@@ -29,6 +29,7 @@
 #include <pci.h>
 #include <asm/io.h>
 #include <asm-generic/gpio.h>
+#include <dm/device_compat.h>
 #include <linux/ioport.h>
 
 /* PCIe core registers */
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 5be2dfd0bf..3240a00ac7 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <pci.h>
 #include <asm/io.h>
 #include <dm/device-internal.h>
diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c
index f9b08f38a1..ba6c41cb3b 100644
--- a/drivers/pci/pci_mvebu.c
+++ b/drivers/pci/pci_mvebu.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/of_access.h>
diff --git a/drivers/pci/pcie_dw_ti.c b/drivers/pci/pcie_dw_ti.c
index 199a3bb50a..8938d43802 100644
--- a/drivers/pci/pcie_dw_ti.c
+++ b/drivers/pci/pcie_dw_ti.c
@@ -12,6 +12,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm-generic/gpio.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/pci/pcie_fsl.c b/drivers/pci/pcie_fsl.c
index ab25aeee73..b5b72c9abc 100644
--- a/drivers/pci/pcie_fsl.c
+++ b/drivers/pci/pcie_fsl.c
@@ -15,6 +15,7 @@
 #include <asm/fsl_serdes.h>
 #include <asm/io.h>
 #include "pcie_fsl.h"
+#include <dm/device_compat.h>
 
 LIST_HEAD(fsl_pcie_list);
 
diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
index 3621636cb2..24ee746b26 100644
--- a/drivers/pci/pcie_imx.c
+++ b/drivers/pci/pcie_imx.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <init.h>
+#include <malloc.h>
 #include <pci.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/iomux.h>
diff --git a/drivers/pci/pcie_intel_fpga.c b/drivers/pci/pcie_intel_fpga.c
index a5ea4888f3..4731ba4623 100644
--- a/drivers/pci/pcie_intel_fpga.c
+++ b/drivers/pci/pcie_intel_fpga.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <pci.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 #define RP_TX_REG0			0x2000
 #define RP_TX_CNTRL			0x2004
diff --git a/drivers/pci/pcie_mediatek.c b/drivers/pci/pcie_mediatek.c
index 1271227c6a..3ec697af0f 100644
--- a/drivers/pci/pcie_mediatek.c
+++ b/drivers/pci/pcie_mediatek.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <pci.h>
 #include <reset.h>
 #include <asm/io.h>
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 2c12fa6976..612c428cf5 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -21,6 +21,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #define REG_ISCR			0x00
diff --git a/drivers/phy/bcm6318-usbh-phy.c b/drivers/phy/bcm6318-usbh-phy.c
index de055a3585..2de343de29 100644
--- a/drivers/phy/bcm6318-usbh-phy.c
+++ b/drivers/phy/bcm6318-usbh-phy.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <power-domain.h>
 #include <reset.h>
 #include <asm/io.h>
diff --git a/drivers/phy/bcm6348-usbh-phy.c b/drivers/phy/bcm6348-usbh-phy.c
index e7761e3b28..ed9f02b375 100644
--- a/drivers/phy/bcm6348-usbh-phy.c
+++ b/drivers/phy/bcm6348-usbh-phy.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <dm/device.h>
diff --git a/drivers/phy/bcm6358-usbh-phy.c b/drivers/phy/bcm6358-usbh-phy.c
index 189a1c11d3..f0fda0290e 100644
--- a/drivers/phy/bcm6358-usbh-phy.c
+++ b/drivers/phy/bcm6358-usbh-phy.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <dm/device.h>
diff --git a/drivers/phy/bcm6368-usbh-phy.c b/drivers/phy/bcm6368-usbh-phy.c
index 99da97aa0c..53d1f45bb9 100644
--- a/drivers/phy/bcm6368-usbh-phy.c
+++ b/drivers/phy/bcm6368-usbh-phy.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <power-domain.h>
 #include <reset.h>
 #include <asm/io.h>
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index d52f42df84..244beef18d 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <asm/io.h>
diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index ad1a77fcfc..c23bc87d0f 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <bitfield.h>
 #include <dm.h>
diff --git a/drivers/phy/meson-g12a-usb3-pcie.c b/drivers/phy/meson-g12a-usb3-pcie.c
index 920675dc99..82655f26dd 100644
--- a/drivers/phy/meson-g12a-usb3-pcie.c
+++ b/drivers/phy/meson-g12a-usb3-pcie.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <regmap.h>
 #include <errno.h>
 #include <asm/io.h>
diff --git a/drivers/phy/meson-gxl-usb2.c b/drivers/phy/meson-gxl-usb2.c
index 86e69c73ba..c98d12b627 100644
--- a/drivers/phy/meson-gxl-usb2.c
+++ b/drivers/phy/meson-gxl-usb2.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <bitfield.h>
 #include <dm.h>
diff --git a/drivers/phy/meson-gxl-usb3.c b/drivers/phy/meson-gxl-usb3.c
index 5cbbd4d8f7..c2a8593b39 100644
--- a/drivers/phy/meson-gxl-usb3.c
+++ b/drivers/phy/meson-gxl-usb3.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <bitfield.h>
 #include <dm.h>
diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c
index 255d722ff7..bd089b7a43 100644
--- a/drivers/phy/phy-mtk-tphy.c
+++ b/drivers/phy/phy-mtk-tphy.c
@@ -9,8 +9,10 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 
 #include <dt-bindings/phy/phy.h>
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
index ee70b81d88..e93130aee6 100644
--- a/drivers/phy/phy-rcar-gen2.c
+++ b/drivers/phy/phy-rcar-gen2.c
@@ -11,10 +11,12 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <reset.h>
 #include <syscon.h>
 #include <usb.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <power/regulator.h>
 
diff --git a/drivers/phy/phy-rcar-gen3.c b/drivers/phy/phy-rcar-gen3.c
index b662935626..ce39cd8f9e 100644
--- a/drivers/phy/phy-rcar-gen3.c
+++ b/drivers/phy/phy-rcar-gen3.c
@@ -11,6 +11,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <reset.h>
 #include <syscon.h>
 #include <usb.h>
diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index 6f1119036d..6ba37213cb 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -13,6 +13,7 @@
 #include <syscon.h>
 #include <usb.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <power/regulator.h>
 
diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
index 1c7db0dd0f..0b2b2410b2 100644
--- a/drivers/phy/phy-ti-am654.c
+++ b/drivers/phy/phy-ti-am654.c
@@ -10,6 +10,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <dm/device.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dt-bindings/phy/phy.h>
 #include <generic-phy.h>
diff --git a/drivers/pinctrl/broadcom/pinctrl-bcm6838.c b/drivers/pinctrl/broadcom/pinctrl-bcm6838.c
index 48c0b6b374..6c8a990f57 100644
--- a/drivers/pinctrl/broadcom/pinctrl-bcm6838.c
+++ b/drivers/pinctrl/broadcom/pinctrl-bcm6838.c
@@ -4,6 +4,7 @@
 #include <dm.h>
 #include <regmap.h>
 #include <syscon.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 
 #define BCM6838_CMD_LOAD_MUX            0x21
diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c
index c4287ec406..db70762e00 100644
--- a/drivers/pinctrl/intel/pinctrl.c
+++ b/drivers/pinctrl/intel/pinctrl.c
@@ -19,6 +19,7 @@
 #include <common.h>
 #include <dm.h>
 #include <irq.h>
+#include <malloc.h>
 #include <p2sb.h>
 #include <spl.h>
 #include <asm-generic/gpio.h>
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index f664d76b54..7fbe2810a2 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -5,7 +5,9 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <fdt_support.h>
diff --git a/drivers/pinctrl/mscc/mscc-common.c b/drivers/pinctrl/mscc/mscc-common.c
index 2d76c41dea..90c54b45c3 100644
--- a/drivers/pinctrl/mscc/mscc-common.c
+++ b/drivers/pinctrl/mscc/mscc-common.c
@@ -14,6 +14,7 @@
 #include <config.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
diff --git a/drivers/pinctrl/mtmips/pinctrl-mtmips-common.c b/drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
index ee6a9d1fc8..e361916eb2 100644
--- a/drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
+++ b/drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/pinctrl.h>
 #include <linux/io.h>
 
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index da1f091aec..6e0bcae991 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -19,7 +19,9 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c
index 77a8a53202..474c38a049 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -4,7 +4,9 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <mapmem.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/io.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-mxs.c b/drivers/pinctrl/nxp/pinctrl-mxs.c
index 5147bdc3cc..8d61dfe863 100644
--- a/drivers/pinctrl/nxp/pinctrl-mxs.c
+++ b/drivers/pinctrl/nxp/pinctrl-mxs.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/io.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c
index eecf0f5dc1..1098366b5f 100644
--- a/drivers/pinctrl/pinctrl-generic.c
+++ b/drivers/pinctrl/pinctrl-generic.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/compat.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 1dfc97dcea..380b0da271 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <linux/libfdt.h>
 #include <asm/io.h>
diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c
index 0b5a0433cd..c8e61e2918 100644
--- a/drivers/pinctrl/pinctrl-stmfx.c
+++ b/drivers/pinctrl/pinctrl-stmfx.c
@@ -11,6 +11,7 @@
 #include <asm/gpio.h>
 #include <dm/device.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <linux/bitfield.h>
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 3425ed11b1..aba8810474 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -4,6 +4,8 @@
  */
 
 #include <common.h>
+#include <malloc.h>
+#include <dm/device_compat.h>
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <linux/list.h>
diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index e0380c349a..9926235b52 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -1,9 +1,11 @@
 #include <common.h>
 #include <dm.h>
 #include <hwspinlock.h>
+#include <malloc.h>
 #include <asm/arch/gpio.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index 5ee11615de..ab64f4f0c8 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/pinctrl.h>
 #include <linux/io.h>
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
index a5935e84de..abeba965c4 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
diff --git a/drivers/power/domain/bcm6328-power-domain.c b/drivers/power/domain/bcm6328-power-domain.c
index 425451e4cd..a6426bee27 100644
--- a/drivers/power/domain/bcm6328-power-domain.c
+++ b/drivers/power/domain/bcm6328-power-domain.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <asm/io.h>
 
diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c
index 74fcb05c15..6f01a60b34 100644
--- a/drivers/power/domain/imx8-power-domain-legacy.c
+++ b/drivers/power/domain/imx8-power-domain-legacy.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <asm/io.h>
 #include <asm/arch/power-domain.h>
diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain.c
index 8e328f02c2..571146e19d 100644
--- a/drivers/power/domain/imx8-power-domain.c
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -6,6 +6,7 @@
 #define DEBUG
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <asm/arch/power-domain.h>
 #include <asm/arch/sci/sci.h>
diff --git a/drivers/power/domain/imx8m-power-domain.c b/drivers/power/domain/imx8m-power-domain.c
index fbfd17718b..5b6467cda7 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <asm/io.h>
 #include <asm/arch/power-domain.h>
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index aa11866591..7082c80bfa 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <regmap.h>
 #include <syscon.h>
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index 02f73548d6..12cdfcdd1f 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <regmap.h>
 #include <syscon.h>
diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index 789fc5ab64..3ff7ca1bef 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <regmap.h>
 #include <syscon.h>
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index be0a8026f6..d9c623b56e 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain.h>
 #include <power-domain-uclass.h>
 #include <dm/device-internal.h>
diff --git a/drivers/power/domain/sandbox-power-domain-test.c b/drivers/power/domain/sandbox-power-domain-test.c
index 148b6b1707..2191a94146 100644
--- a/drivers/power/domain/sandbox-power-domain-test.c
+++ b/drivers/power/domain/sandbox-power-domain-test.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain.h>
 #include <asm/io.h>
 #include <asm/power-domain.h>
diff --git a/drivers/power/domain/sandbox-power-domain.c b/drivers/power/domain/sandbox-power-domain.c
index a5ae235d53..3a834a9f1e 100644
--- a/drivers/power/domain/sandbox-power-domain.c
+++ b/drivers/power/domain/sandbox-power-domain.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
 #include <asm/io.h>
 #include <asm/power-domain.h>
diff --git a/drivers/power/domain/tegra186-power-domain.c b/drivers/power/domain/tegra186-power-domain.c
index d2a25ca333..e87244197f 100644
--- a/drivers/power/domain/tegra186-power-domain.c
+++ b/drivers/power/domain/tegra186-power-domain.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <misc.h>
 #include <power-domain-uclass.h>
 #include <asm/arch-tegra/bpmp_abi.h>
diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c
index 3866db589a..a5866703ae 100644
--- a/drivers/power/domain/ti-sci-power-domain.c
+++ b/drivers/power/domain/ti-sci-power-domain.c
@@ -11,7 +11,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <power-domain-uclass.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <dt-bindings/soc/ti,sci_pm_domain.h>
diff --git a/drivers/power/pmic/fan53555.c b/drivers/power/pmic/fan53555.c
index 11304d2146..a5f855ce2a 100644
--- a/drivers/power/pmic/fan53555.c
+++ b/drivers/power/pmic/fan53555.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <i2c.h>
 #include <power/fan53555.h>
diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c
index 80efc0265d..4926d872fa 100644
--- a/drivers/power/pmic/i2c_pmic_emul.c
+++ b/drivers/power/pmic/i2c_pmic_emul.c
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <dm.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <power/pmic.h>
 #include <power/sandbox_pmic.h>
 
diff --git a/drivers/power/pmic/stpmic1.c b/drivers/power/pmic/stpmic1.c
index 2297af4157..2c85410b1b 100644
--- a/drivers/power/pmic/stpmic1.c
+++ b/drivers/power/pmic/stpmic1.c
@@ -11,6 +11,7 @@
 #include <sysreset.h>
 #include <time.h>
 #include <dm/device.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <power/pmic.h>
 #include <power/stpmic1.h>
diff --git a/drivers/power/regulator/pwm_regulator.c b/drivers/power/regulator/pwm_regulator.c
index cd05c9b603..4030144dd3 100644
--- a/drivers/power/regulator/pwm_regulator.c
+++ b/drivers/power/regulator/pwm_regulator.c
@@ -11,6 +11,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <pwm.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/power/regulator/stm32-vrefbuf.c b/drivers/power/regulator/stm32-vrefbuf.c
index 645528e84e..08a10f05b4 100644
--- a/drivers/power/regulator/stm32-vrefbuf.c
+++ b/drivers/power/regulator/stm32-vrefbuf.c
@@ -10,6 +10,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <power/regulator.h>
diff --git a/drivers/power/regulator/tps62360_regulator.c b/drivers/power/regulator/tps62360_regulator.c
index 2c076c0db5..ce54495490 100644
--- a/drivers/power/regulator/tps62360_regulator.c
+++ b/drivers/power/regulator/tps62360_regulator.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <i2c.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 
 #define TPS62360_REG_SET0	0
diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c
index 7015d8cfe7..8cf74861a8 100644
--- a/drivers/ram/k3-am654-ddrss.c
+++ b/drivers/ram/k3-am654-ddrss.c
@@ -14,6 +14,7 @@
 #include <power-domain.h>
 #include <dm.h>
 #include <asm/arch/sys_proto.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 #include "k3-am654-ddrss.h"
 
diff --git a/drivers/ram/k3-j721e/k3-j721e-ddrss.c b/drivers/ram/k3-j721e/k3-j721e-ddrss.c
index a9b7d40890..352483c4d7 100644
--- a/drivers/ram/k3-j721e/k3-j721e-ddrss.c
+++ b/drivers/ram/k3-j721e/k3-j721e-ddrss.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <power-domain.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 
 #include "lpddr4_obj_if.h"
 #include "lpddr4_if.h"
diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
index f6cac8eb90..2d03333b1b 100644
--- a/drivers/ram/stm32_sdram.c
+++ b/drivers/ram/stm32_sdram.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <ram.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 #define MEM_MODE_MASK	GENMASK(2, 0)
 #define SWP_FMC_OFFSET 10
diff --git a/drivers/remoteproc/k3_system_controller.c b/drivers/remoteproc/k3_system_controller.c
index 44e56c759f..88430299c9 100644
--- a/drivers/remoteproc/k3_system_controller.c
+++ b/drivers/remoteproc/k3_system_controller.c
@@ -11,6 +11,7 @@
 #include <remoteproc.h>
 #include <errno.h>
 #include <mailbox.h>
+#include <dm/device_compat.h>
 #include <linux/soc/ti/k3-sec-proxy.h>
 
 #define K3_MSG_R5_TO_M3_M3FW			0x8105
diff --git a/drivers/remoteproc/rproc-elf-loader.c b/drivers/remoteproc/rproc-elf-loader.c
index bf44bebc02..f2e033aa74 100644
--- a/drivers/remoteproc/rproc-elf-loader.c
+++ b/drivers/remoteproc/rproc-elf-loader.c
@@ -7,7 +7,8 @@
 #include <dm.h>
 #include <elf.h>
 #include <remoteproc.h>
-#include <linux/err.h>
+#include <dm/device_compat.h>
+#include <linux/compat.h>
 
 /**
  * struct resource_table - firmware resource table header
diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c
index 80e8dffdbb..e9dce0d173 100644
--- a/drivers/remoteproc/stm32_copro.c
+++ b/drivers/remoteproc/stm32_copro.c
@@ -12,6 +12,7 @@
 #include <reset.h>
 #include <syscon.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #define RCC_GCR_HOLD_BOOT	0
diff --git a/drivers/remoteproc/ti_k3_arm64_rproc.c b/drivers/remoteproc/ti_k3_arm64_rproc.c
index d048cf4161..28c6ddb691 100644
--- a/drivers/remoteproc/ti_k3_arm64_rproc.c
+++ b/drivers/remoteproc/ti_k3_arm64_rproc.c
@@ -15,6 +15,7 @@
 #include <reset.h>
 #include <asm/io.h>
 #include <power-domain.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include "ti_sci_proc.h"
diff --git a/drivers/remoteproc/ti_k3_dsp_rproc.c b/drivers/remoteproc/ti_k3_dsp_rproc.c
index 913aca36d6..09e050ffb2 100644
--- a/drivers/remoteproc/ti_k3_dsp_rproc.c
+++ b/drivers/remoteproc/ti_k3_dsp_rproc.c
@@ -9,12 +9,14 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <remoteproc.h>
 #include <errno.h>
 #include <clk.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <power-domain.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include "ti_sci_proc.h"
diff --git a/drivers/remoteproc/ti_k3_r5f_rproc.c b/drivers/remoteproc/ti_k3_r5f_rproc.c
index cecfb0ef86..ea56689552 100644
--- a/drivers/remoteproc/ti_k3_r5f_rproc.c
+++ b/drivers/remoteproc/ti_k3_r5f_rproc.c
@@ -8,11 +8,13 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <remoteproc.h>
 #include <errno.h>
 #include <clk.h>
 #include <reset.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
diff --git a/drivers/reset/reset-bcm6345.c b/drivers/reset/reset-bcm6345.c
index bbaaea9bb3..c1f1e7f70b 100644
--- a/drivers/reset/reset-bcm6345.c
+++ b/drivers/reset/reset-bcm6345.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <asm/io.h>
 
diff --git a/drivers/reset/reset-hisilicon.c b/drivers/reset/reset-hisilicon.c
index d449e3d25e..a678b8f745 100644
--- a/drivers/reset/reset-hisilicon.c
+++ b/drivers/reset/reset-hisilicon.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2019, Linaro Limited
  */
 
+#include <malloc.h>
 #include <asm/io.h>
 #include <common.h>
 #include <dm.h>
diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c
index a2bad65a3b..a61855e9ed 100644
--- a/drivers/reset/reset-imx7.c
+++ b/drivers/reset/reset-imx7.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2017, Impinj, Inc.
  */
 
+#include <malloc.h>
 #include <asm/io.h>
 #include <common.h>
 #include <dm.h>
diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c
index 4684cbfb6a..6d17f52ac7 100644
--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/lists.h>
 #include <regmap.h>
 #include <reset-uclass.h>
diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c
index 9026e034c3..70f96355b3 100644
--- a/drivers/reset/reset-meson.c
+++ b/drivers/reset/reset-meson.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <regmap.h>
 
diff --git a/drivers/reset/reset-mtmips.c b/drivers/reset/reset-mtmips.c
index 71254a93dd..677de0a6f9 100644
--- a/drivers/reset/reset-mtmips.c
+++ b/drivers/reset/reset-mtmips.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <linux/io.h>
 
diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c
index 4fb9571b18..100afc8103 100644
--- a/drivers/reset/reset-rockchip.c
+++ b/drivers/reset/reset-rockchip.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <linux/io.h>
 #include <asm/arch-rockchip/hardware.h>
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 98524eb2b7..3ad5e35cc2 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -14,6 +14,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/lists.h>
 #include <dm/of_access.h>
 #include <env.h>
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 1c717b20c3..f21bf3b1ae 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <asm/io.h>
 #include <dm/lists.h>
diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c
index 99e3d9ad5c..f5d82b5681 100644
--- a/drivers/reset/reset-ti-sci.c
+++ b/drivers/reset/reset-ti-sci.c
@@ -11,7 +11,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset-uclass.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 8e6c0a4fd0..8ec8e462e6 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <reset.h>
 #include <reset-uclass.h>
 #include <dm/devres.h>
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 97f7b0ed5f..348f3886d1 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -6,7 +6,9 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset-uclass.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/reset/sandbox-reset-test.c b/drivers/reset/sandbox-reset-test.c
index 95ce2ca117..ae79be0730 100644
--- a/drivers/reset/sandbox-reset-test.c
+++ b/drivers/reset/sandbox-reset-test.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <asm/reset.h>
diff --git a/drivers/reset/sandbox-reset.c b/drivers/reset/sandbox-reset.c
index c03fce3531..bdf53a3de9 100644
--- a/drivers/reset/sandbox-reset.c
+++ b/drivers/reset/sandbox-reset.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <asm/io.h>
 #include <asm/reset.h>
diff --git a/drivers/reset/sti-reset.c b/drivers/reset/sti-reset.c
index 614da9da59..31b3e48e0e 100644
--- a/drivers/reset/sti-reset.c
+++ b/drivers/reset/sti-reset.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <errno.h>
+#include <malloc.h>
 #include <wait_bit.h>
 #include <dm.h>
 #include <reset-uclass.h>
diff --git a/drivers/reset/stm32-reset.c b/drivers/reset/stm32-reset.c
index 4d7745abce..5dda522a4e 100644
--- a/drivers/reset/stm32-reset.c
+++ b/drivers/reset/stm32-reset.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <stm32_rcc.h>
 #include <asm/io.h>
diff --git a/drivers/reset/tegra-car-reset.c b/drivers/reset/tegra-car-reset.c
index 886ea04e2e..23c6facff2 100644
--- a/drivers/reset/tegra-car-reset.c
+++ b/drivers/reset/tegra-car-reset.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset-uclass.h>
 #include <asm/arch/clock.h>
 #include <asm/arch-tegra/clk_rst.h>
diff --git a/drivers/reset/tegra186-reset.c b/drivers/reset/tegra186-reset.c
index 84ed77b96f..e85f42b3a3 100644
--- a/drivers/reset/tegra186-reset.c
+++ b/drivers/reset/tegra186-reset.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <misc.h>
 #include <reset-uclass.h>
 #include <asm/arch-tegra/bpmp_abi.h>
diff --git a/drivers/rtc/ds3232.c b/drivers/rtc/ds3232.c
index 09a106aa4e..e3b3579c4a 100644
--- a/drivers/rtc/ds3232.c
+++ b/drivers/rtc/ds3232.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <i2c.h>
 #include <rtc.h>
+#include <dm/device_compat.h>
 
 /*
  * RTC register addresses
diff --git a/drivers/rtc/rv3029.c b/drivers/rtc/rv3029.c
index 2367062777..87c4320d5f 100644
--- a/drivers/rtc/rv3029.c
+++ b/drivers/rtc/rv3029.c
@@ -13,6 +13,7 @@
 #include <eeprom.h>
 #include <i2c.h>
 #include <rtc.h>
+#include <dm/device_compat.h>
 
 #define RTC_RV3029_PAGE_LEN             7
 
diff --git a/drivers/rtc/stm32_rtc.c b/drivers/rtc/stm32_rtc.c
index 2674714442..3e12f57ce0 100644
--- a/drivers/rtc/stm32_rtc.c
+++ b/drivers/rtc/stm32_rtc.c
@@ -5,8 +5,10 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <rtc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 
 #define STM32_RTC_TR		0x00
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index c450a4e08a..98d209072d 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -9,6 +9,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <watchdog.h>
 #include <serial.h>
 #include <debug_uart.h>
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 0f5f1fa406..30f9b8c939 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <env_internal.h>
 #include <errno.h>
+#include <malloc.h>
 #include <os.h>
 #include <serial.h>
 #include <stdio_dev.h>
diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c
index 9ad8c770d5..5b963ce45b 100644
--- a/drivers/serial/serial_bcm6345.c
+++ b/drivers/serial/serial_bcm6345.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <debug_uart.h>
 #include <errno.h>
+#include <malloc.h>
 #include <serial.h>
 #include <asm/io.h>
 #include <asm/types.h>
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index ccb3ce6701..d7907a228f 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -11,6 +11,7 @@
 #include <watchdog.h>
 #include <asm/io.h>
 #include <serial.h>
+#include <dm/device_compat.h>
 #include <linux/compiler.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
index c462394dbd..0cc1aadce4 100644
--- a/drivers/serial/serial_msm.c
+++ b/drivers/serial/serial_msm.c
@@ -12,6 +12,7 @@
 #include <clk.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <serial.h>
 #include <watchdog.h>
 #include <asm/io.h>
diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c
index 84600b1201..bac506ed79 100644
--- a/drivers/serial/serial_pic32.c
+++ b/drivers/serial/serial_pic32.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <serial.h>
 #include <wait_bit.h>
 #include <mach/pic32.h>
diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index 00a8e7249b..016082814f 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <asm/arch/stm32.h>
 #include "serial_stm32.h"
+#include <dm/device_compat.h>
 
 static void _stm32_serial_setbrg(fdt_addr_t base,
 				 struct stm32_uart_info *uart_info,
diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c
index c07375901b..e4e4c39285 100644
--- a/drivers/serial/serial_zynq.c
+++ b/drivers/serial/serial_zynq.c
@@ -12,6 +12,7 @@
 #include <fdtdec.h>
 #include <watchdog.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/compiler.h>
 #include <serial.h>
 #include <linux/err.h>
diff --git a/drivers/smem/msm_smem.c b/drivers/smem/msm_smem.c
index 711ce626aa..5557fd29ce 100644
--- a/drivers/smem/msm_smem.c
+++ b/drivers/smem/msm_smem.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <errno.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/of_access.h>
 #include <dm/of_addr.h>
diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c
index 97c046b0c3..8cbfe2bf49 100644
--- a/drivers/soc/ti/k3-navss-ringacc.c
+++ b/drivers/soc/ti/k3-navss-ringacc.c
@@ -12,6 +12,7 @@
 #include <asm/dma-mapping.h>
 #include <asm/bitops.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/read.h>
 #include <dm/uclass.h>
diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c
index bada0c2ba5..d9b3a38f18 100644
--- a/drivers/sound/sound-uclass.c
+++ b/drivers/sound/sound-uclass.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <i2s.h>
+#include <malloc.h>
 #include <sound.h>
 
 #define SOUND_BITS_IN_BYTE 8
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 195ea5fae6..a09bf884e8 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -9,12 +9,14 @@
  * Author: Piotr Bugalski <bugalski.piotr@gmail.com>
  */
 
+#include <malloc.h>
 #include <asm/io.h>
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
diff --git a/drivers/spi/bcm63xx_hsspi.c b/drivers/spi/bcm63xx_hsspi.c
index 529adfbc4e..f88702df4d 100644
--- a/drivers/spi/bcm63xx_hsspi.c
+++ b/drivers/spi/bcm63xx_hsspi.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <spi.h>
 #include <reset.h>
 #include <wait_bit.h>
diff --git a/drivers/spi/bcm63xx_spi.c b/drivers/spi/bcm63xx_spi.c
index 69f88c9e08..719f53d08e 100644
--- a/drivers/spi/bcm63xx_spi.c
+++ b/drivers/spi/bcm63xx_spi.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <spi.h>
 #include <reset.h>
 #include <wait_bit.h>
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index 0b503dd934..83b114ffe7 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -13,6 +13,7 @@
 #include <reset.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/sizes.h>
diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 66ff8eeccd..2dc16736a3 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -18,6 +18,7 @@
 #include <spi.h>
 #include <fdtdec.h>
 #include <reset.h>
+#include <dm/device_compat.h>
 #include <linux/compat.h>
 #include <linux/iopoll.h>
 #include <asm/io.h>
diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c
index 99ad505f24..1469771619 100644
--- a/drivers/spi/mvebu_a3700_spi.c
+++ b/drivers/spi/mvebu_a3700_spi.c
@@ -12,6 +12,7 @@
 #include <clk.h>
 #include <wait_bit.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index d94aaf9fdb..4d1317c364 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <malloc.h>
 #include <spi.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
diff --git a/drivers/spi/spi-mem-nodm.c b/drivers/spi/spi-mem-nodm.c
index 4447d44991..83dde4806e 100644
--- a/drivers/spi/spi-mem-nodm.c
+++ b/drivers/spi/spi-mem-nodm.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
  */
 
+#include <malloc.h>
 #include <spi.h>
 #include <spi-mem.h>
 
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index b8cf8dd76b..e900c997bd 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -12,6 +12,7 @@
 #include <linux/pm_runtime.h>
 #include "internals.h"
 #else
+#include <dm/device_compat.h>
 #include <spi.h>
 #include <spi-mem.h>
 #endif
diff --git a/drivers/spi/spi-sunxi.c b/drivers/spi/spi-sunxi.c
index dbfeac77ee..c59fee10a8 100644
--- a/drivers/spi/spi-sunxi.c
+++ b/drivers/spi/spi-sunxi.c
@@ -26,6 +26,7 @@
 #include <fdt_support.h>
 #include <reset.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 
 #include <asm/bitops.h>
 #include <asm/gpio.h>
diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 958c394a1a..6857a87dc5 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <reset.h>
 #include <spi-mem.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 #include <linux/ioport.h>
 #include <linux/sizes.h>
diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
index 75b6006b45..ebf2b98fcd 100644
--- a/drivers/spi/stm32_spi.c
+++ b/drivers/spi/stm32_spi.c
@@ -8,8 +8,10 @@
 #include <clk.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <reset.h>
 #include <spi.h>
+#include <dm/device_compat.h>
 
 #include <asm/io.h>
 #include <asm/gpio.h>
diff --git a/drivers/spi/uniphier_spi.c b/drivers/spi/uniphier_spi.c
index e47b969864..153fbb2889 100644
--- a/drivers/spi/uniphier_spi.c
+++ b/drivers/spi/uniphier_spi.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <time.h>
+#include <dm/device_compat.h>
 #include <linux/bitfield.h>
 #include <linux/io.h>
 #include <spi.h>
diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index c05d46e084..02b78df843 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -16,6 +16,7 @@
 #include <spi.h>
 #include <ubi_uboot.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #define GQSPI_GFIFO_STRT_MODE_MASK	BIT(29)
diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c
index 6f1114699e..ed93faffcb 100644
--- a/drivers/spmi/spmi-msm.c
+++ b/drivers/spmi/spmi-msm.c
@@ -12,6 +12,7 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <spmi/spmi.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/sysreset/sysreset-ti-sci.c b/drivers/sysreset/sysreset-ti-sci.c
index 6caea3aab3..e7fcfcd4d1 100644
--- a/drivers/sysreset/sysreset-ti-sci.c
+++ b/drivers/sysreset/sysreset-ti-sci.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <sysreset.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index a7b175ee62..9fb5e658f9 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm.h>
 #include <log.h>
+#include <malloc.h>
 #include <tee.h>
 #include <linux/arm-smccc.h>
 #include <linux/err.h>
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
index cf1ce77e6e..0804fc963c 100644
--- a/drivers/tee/optee/rpmb.c
+++ b/drivers/tee/optee/rpmb.c
@@ -8,6 +8,7 @@
 #include <log.h>
 #include <tee.h>
 #include <mmc.h>
+#include <dm/device_compat.h>
 
 #include "optee_msg.h"
 #include "optee_private.h"
diff --git a/drivers/tee/optee/supplicant.c b/drivers/tee/optee/supplicant.c
index c5726ecb91..ae042b9a20 100644
--- a/drivers/tee/optee/supplicant.c
+++ b/drivers/tee/optee/supplicant.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <log.h>
+#include <malloc.h>
 #include <tee.h>
 #include <linux/types.h>
 
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
index abb88c0fee..1fb3c16a14 100644
--- a/drivers/tee/tee-uclass.c
+++ b/drivers/tee/tee-uclass.c
@@ -5,9 +5,10 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
+#include <tee.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
-#include <tee.h>
 
 /**
  * struct tee_uclass_priv - information of a TEE, stored by the uclass
diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c
index fad22be8c9..35271b20c8 100644
--- a/drivers/timer/dw-apb-timer.c
+++ b/drivers/timer/dw-apb-timer.c
@@ -8,8 +8,10 @@
 #include <common.h>
 #include <dm.h>
 #include <clk.h>
+#include <malloc.h>
 #include <reset.h>
 #include <timer.h>
+#include <dm/device_compat.h>
 
 #include <asm/io.h>
 #include <asm/arch/timer.h>
diff --git a/drivers/timer/ostm_timer.c b/drivers/timer/ostm_timer.c
index f0e25093ca..48a5055b05 100644
--- a/drivers/timer/ostm_timer.c
+++ b/drivers/timer/ostm_timer.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <dm.h>
 #include <clk.h>
diff --git a/drivers/timer/stm32_timer.c b/drivers/timer/stm32_timer.c
index 76315100e2..76d99a2b86 100644
--- a/drivers/timer/stm32_timer.c
+++ b/drivers/timer/stm32_timer.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <timer.h>
+#include <dm/device_compat.h>
 
 #include <asm/io.h>
 
diff --git a/drivers/ufs/cdns-platform.c b/drivers/ufs/cdns-platform.c
index 5bd0c1e0c7..41ee6a60c9 100644
--- a/drivers/ufs/cdns-platform.c
+++ b/drivers/ufs/cdns-platform.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <ufs.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #include "ufs.h"
diff --git a/drivers/ufs/ti-j721e-ufs.c b/drivers/ufs/ti-j721e-ufs.c
index 6e4d0cd3ac..4990fba6eb 100644
--- a/drivers/ufs/ti-j721e-ufs.c
+++ b/drivers/ufs/ti-j721e-ufs.c
@@ -7,6 +7,7 @@
 #include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 
 #define UFS_SS_CTRL             0x4
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index 512c63a8f2..c9346c2edc 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -11,6 +11,7 @@
 #include <charset.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c
index 2fa0104f1b..652cd5cb17 100644
--- a/drivers/usb/cdns3/cdns3-ti.c
+++ b/drivers/usb/cdns3/cdns3-ti.c
@@ -9,6 +9,7 @@
 #include <asm-generic/io.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/io.h>
 #include <linux/usb/otg.h>
 #include <malloc.h>
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 6f5e5af47d..f947e6983c 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/lists.h>
 #include <linux/kernel.h>
diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c
index 13eb4899d4..47874fec29 100644
--- a/drivers/usb/cdns3/drd.c
+++ b/drivers/usb/cdns3/drd.c
@@ -11,6 +11,7 @@
  *
  */
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/delay.h>
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
index f35a924839..1957a3b91d 100644
--- a/drivers/usb/cdns3/ep0.c
+++ b/drivers/usb/cdns3/ep0.c
@@ -11,6 +11,7 @@
  */
 
 #include <cpu_func.h>
+#include <dm/device_compat.h>
 #include <linux/usb/composite.h>
 #include <linux/iopoll.h>
 
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index e095760099..22e90a5717 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -57,6 +57,7 @@
  */
 
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/usb/gadget.h>
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index cbf21d31dd..c5066529b7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -18,6 +18,7 @@
 #include <malloc.h>
 #include <dwc3-uboot.h>
 #include <asm/dma-mapping.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/err.h>
 #include <linux/ioport.h>
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 7ffec12fc5..9596bf144c 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -18,6 +18,7 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <dwc3-omap-uboot.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/usb/dwc3-omap.h>
 #include <linux/ioport.h>
diff --git a/drivers/usb/dwc3/dwc3-uniphier.c b/drivers/usb/dwc3/dwc3-uniphier.c
index 6e9c52189d..88317b19ac 100644
--- a/drivers/usb/dwc3/dwc3-uniphier.c
+++ b/drivers/usb/dwc3/dwc3-uniphier.c
@@ -7,6 +7,7 @@
  */
 
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/bitops.h>
 #include <linux/errno.h>
 #include <linux/io.h>
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 0c8c11d743..4af58941d8 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -14,6 +14,7 @@
  */
 #include <common.h>
 #include <cpu_func.h>
+#include <dm/device_compat.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 677607ab32..1502d67362 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -17,6 +17,7 @@
 #include <cpu_func.h>
 #include <malloc.h>
 #include <asm/dma-mapping.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/bug.h>
 #include <linux/list.h>
diff --git a/drivers/usb/dwc3/ti_usb_phy.c b/drivers/usb/dwc3/ti_usb_phy.c
index a90868216a..6b0166a1e0 100644
--- a/drivers/usb/dwc3/ti_usb_phy.c
+++ b/drivers/usb/dwc3/ti_usb_phy.c
@@ -19,6 +19,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <ti-usb-phy-uboot.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/ioport.h>
 #include <asm/io.h>
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 229a61affd..3778cac0bc 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -23,6 +23,7 @@
 #include <generic-phy.h>
 #include <malloc.h>
 #include <reset.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 
 #include <linux/errno.h>
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 4bbd030aad..f40779b13a 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -269,6 +269,7 @@ struct device_attribute { int i; };
 #define ETOOSMALL	525
 
 #include <usb_mass_storage.h>
+#include <dm/device_compat.h>
 
 /*-------------------------------------------------------------------------*/
 
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index 52384b9afb..a33ab5c95d 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -13,6 +13,7 @@
  *		       usb_
  */
 
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/compat.h>
 #include <malloc.h>
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index b9c56f763b..e4efaf1e59 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -15,6 +15,7 @@
 #include <usbroothubdes.h>
 #include <wait_bit.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 #include <reset.h>
 
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 6900848df1..67eec0e0bb 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <usb.h>
 #include <asm/io.h>
 #include <asm/arch/clk.h>
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 80ac876d89..0643681846 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <clk.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index ef20c3c982..1cc02052f5 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -17,6 +17,7 @@
 #include <malloc.h>
 #include <memalign.h>
 #include <watchdog.h>
+#include <dm/device_compat.h>
 #include <linux/compiler.h>
 
 #include "ehci.h"
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 29a702052e..692018243c 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -4,9 +4,11 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 7b6ec51704..04d5fdb2a8 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <dm/ofnode.h>
 #include <generic-phy.h>
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index a37696d83f..8fc9d211db 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <usb.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 #include <power/regulator.h>
 
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index c4d8811343..d86584b847 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -9,8 +9,10 @@
 #include <clk.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <usb.h>
 #include <wait_bit.h>
+#include <dm/device_compat.h>
 
 #include <usb/xhci.h>
 #include "xhci-rcar-r8a779x_usb3_v3.h"
diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c
index 58cde22615..6e5be90fe5 100644
--- a/drivers/usb/musb-new/am35x.c
+++ b/drivers/usb/musb-new/am35x.c
@@ -12,6 +12,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/init.h>
 #include <linux/module.h>
diff --git a/drivers/usb/musb-new/da8xx.c b/drivers/usb/musb-new/da8xx.c
index 899b30db68..2ddcf33b5f 100644
--- a/drivers/usb/musb-new/da8xx.c
+++ b/drivers/usb/musb-new/da8xx.c
@@ -16,6 +16,7 @@
 #include <common.h>
 #include <dm.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/da8xx-usb.h>
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index cc6e0a71c9..f678aa4826 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -65,6 +65,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c
index d342eeba80..eb590885bc 100644
--- a/drivers/usb/musb-new/musb_dsps.c
+++ b/drivers/usb/musb-new/musb_dsps.c
@@ -15,6 +15,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/init.h>
 #include <linux/io.h>
diff --git a/drivers/usb/musb-new/musb_gadget.c b/drivers/usb/musb-new/musb_gadget.c
index 74b645715d..35d2123ddd 100644
--- a/drivers/usb/musb-new/musb_gadget.c
+++ b/drivers/usb/musb-new/musb_gadget.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
diff --git a/drivers/usb/musb-new/musb_gadget_ep0.c b/drivers/usb/musb-new/musb_gadget_ep0.c
index 3ef8fe1373..79e8222e3b 100644
--- a/drivers/usb/musb-new/musb_gadget_ep0.c
+++ b/drivers/usb/musb-new/musb_gadget_ep0.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/timer.h>
diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c
index 55ad8ead70..b98f0ed40e 100644
--- a/drivers/usb/musb-new/musb_host.c
+++ b/drivers/usb/musb-new/musb_host.c
@@ -9,6 +9,7 @@
  */
 
 #ifndef __UBOOT__
+#include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index f4d0e1fdc2..72f14b9343 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -1,5 +1,6 @@
 #include <common.h>
 #include <console.h>
+#include <malloc.h>
 #include <watchdog.h>
 #include <linux/err.h>
 #include <linux/errno.h>
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 8a45b05613..0d34dcfc5d 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <serial.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <linux/err.h>
 #include <linux/usb/otg.h>
diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c
index 3a19900e21..c7867fef8a 100644
--- a/drivers/usb/musb-new/pic32.c
+++ b/drivers/usb/musb-new/pic32.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <dm/device_compat.h>
 #include <linux/usb/musb.h>
 #include "linux-compat.h"
 #include "musb_core.h"
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 45eecfeee6..98bf736978 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -19,12 +19,14 @@
 #include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
+#include <malloc.h>
 #include <phy-sun4i-usb.h>
 #include <reset.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
 #include <asm-generic/gpio.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <linux/usb/musb.h>
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 20ca2731b4..00759f3e83 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -9,6 +9,7 @@
 #include <command.h>
 #include <console.h>
 #include <dm.h>
+#include <malloc.h>
 #include <linux/usb/otg.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
diff --git a/drivers/usb/phy/omap_usb_phy.c b/drivers/usb/phy/omap_usb_phy.c
index 897e6f19f7..9209942430 100644
--- a/drivers/usb/phy/omap_usb_phy.c
+++ b/drivers/usb/phy/omap_usb_phy.c
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <usb.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <asm/omap_common.h>
 #include <asm/arch/cpu.h>
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 734bc12c7b..62acccedf3 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <cpu_func.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 0a725c5c15..6d7661db89 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <video.h>
 #include <video_console.h>
 
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 285633b14d..5fb68865ef 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -13,6 +13,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <video_fb.h>
 #include <linux/list.h>
diff --git a/drivers/video/dw_mipi_dsi.c b/drivers/video/dw_mipi_dsi.c
index 83d7c7b2c0..5dd75e7ec8 100644
--- a/drivers/video/dw_mipi_dsi.c
+++ b/drivers/video/dw_mipi_dsi.c
@@ -19,6 +19,7 @@
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <linux/iopoll.h>
 #include <video_bridge.h>
 
diff --git a/drivers/video/hitachi_tx18d42vm_lcd.c b/drivers/video/hitachi_tx18d42vm_lcd.c
index 1629f558d0..a57abd23f7 100644
--- a/drivers/video/hitachi_tx18d42vm_lcd.c
+++ b/drivers/video/hitachi_tx18d42vm_lcd.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 
 #include <asm/gpio.h>
 #include <errno.h>
diff --git a/drivers/video/mali_dp.c b/drivers/video/mali_dp.c
index 71151a87aa..87a75a9ca2 100644
--- a/drivers/video/mali_dp.c
+++ b/drivers/video/mali_dp.c
@@ -6,6 +6,7 @@
  */
 #define DEBUG
 #include <common.h>
+#include <malloc.h>
 #include <video.h>
 #include <dm.h>
 #ifdef CONFIG_DISPLAY
@@ -16,6 +17,7 @@
 #include <os.h>
 #include <fdt_support.h>
 #include <clk.h>
+#include <dm/device_compat.h>
 #include <linux/sizes.h>
 
 #define MALIDP_CORE_ID		0x0018
diff --git a/drivers/video/mvebu_lcd.c b/drivers/video/mvebu_lcd.c
index dc6254514a..3ff5b28ae2 100644
--- a/drivers/video/mvebu_lcd.c
+++ b/drivers/video/mvebu_lcd.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <video.h>
+#include <dm/device_compat.h>
 #include <linux/mbus.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index c52981053e..6f80fbaaf3 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <env.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <malloc.h>
 #include <video.h>
diff --git a/drivers/video/orisetech_otm8009a.c b/drivers/video/orisetech_otm8009a.c
index 89d9cfdbb3..650ed07239 100644
--- a/drivers/video/orisetech_otm8009a.c
+++ b/drivers/video/orisetech_otm8009a.c
@@ -13,6 +13,7 @@
 #include <mipi_dsi.h>
 #include <panel.h>
 #include <asm/gpio.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 
 #define OTM8009A_BACKLIGHT_DEFAULT	240
diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c
index ad20bf2441..742579aba7 100644
--- a/drivers/video/pwm_backlight.c
+++ b/drivers/video/pwm_backlight.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <backlight.h>
+#include <malloc.h>
 #include <pwm.h>
 #include <asm/gpio.h>
 #include <power/regulator.h>
diff --git a/drivers/video/raydium-rm68200.c b/drivers/video/raydium-rm68200.c
index 91555e26ed..853dbc52d6 100644
--- a/drivers/video/raydium-rm68200.c
+++ b/drivers/video/raydium-rm68200.c
@@ -13,6 +13,7 @@
 #include <mipi_dsi.h>
 #include <panel.h>
 #include <asm/gpio.h>
+#include <dm/device_compat.h>
 #include <power/regulator.h>
 
 /*** Manufacturer Command Set ***/
diff --git a/drivers/video/rockchip/rk3288_hdmi.c b/drivers/video/rockchip/rk3288_hdmi.c
index 3d25ce924c..51eb41540b 100644
--- a/drivers/video/rockchip/rk3288_hdmi.c
+++ b/drivers/video/rockchip/rk3288_hdmi.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <dw_hdmi.h>
 #include <edid.h>
+#include <malloc.h>
 #include <regmap.h>
 #include <syscon.h>
 #include <asm/gpio.h>
diff --git a/drivers/video/rockchip/rk_edp.c b/drivers/video/rockchip/rk_edp.c
index 4330725a25..8703df0ec0 100644
--- a/drivers/video/rockchip/rk_edp.c
+++ b/drivers/video/rockchip/rk_edp.c
@@ -9,6 +9,7 @@
 #include <display.h>
 #include <dm.h>
 #include <edid.h>
+#include <malloc.h>
 #include <panel.h>
 #include <regmap.h>
 #include <syscon.h>
diff --git a/drivers/video/sandbox_osd.c b/drivers/video/sandbox_osd.c
index dd84489add..7e722326b3 100644
--- a/drivers/video/sandbox_osd.c
+++ b/drivers/video/sandbox_osd.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <display.h>
 #include <dm.h>
+#include <malloc.h>
 #include <video_osd.h>
 
 #include "sandbox_osd.h"
diff --git a/drivers/video/scf0403_lcd.c b/drivers/video/scf0403_lcd.c
index 58564e8cfe..60075a6cf3 100644
--- a/drivers/video/scf0403_lcd.c
+++ b/drivers/video/scf0403_lcd.c
@@ -14,6 +14,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <asm/gpio.h>
 #include <spi.h>
 
diff --git a/drivers/video/ssd2828.c b/drivers/video/ssd2828.c
index 4d40dca0c8..83566bc6d6 100644
--- a/drivers/video/ssd2828.c
+++ b/drivers/video/ssd2828.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <malloc.h>
 #include <mipi_display.h>
 #include <asm/arch/gpio.h>
 #include <asm/gpio.h>
diff --git a/drivers/video/stm32/stm32_dsi.c b/drivers/video/stm32/stm32_dsi.c
index 12895a8f5d..ded03b109c 100644
--- a/drivers/video/stm32/stm32_dsi.c
+++ b/drivers/video/stm32/stm32_dsi.c
@@ -20,6 +20,7 @@
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <linux/iopoll.h>
 #include <power/regulator.h>
diff --git a/drivers/video/stm32/stm32_ltdc.c b/drivers/video/stm32/stm32_ltdc.c
index 59ff692b0b..be7e9bff01 100644
--- a/drivers/video/stm32/stm32_ltdc.c
+++ b/drivers/video/stm32/stm32_ltdc.c
@@ -16,6 +16,7 @@
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 
 struct stm32_ltdc_priv {
 	void __iomem *regs;
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 12057c8a5b..3d658e61d7 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <stdio_dev.h>
 #include <video.h>
diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index 436faa46ee..23f281cd6e 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -17,6 +17,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <virtio_types.h>
 #include <virtio.h>
 #include <dm/lists.h>
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 0eeb3501c2..45c48a927a 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -12,6 +12,7 @@
 #include <virtio_types.h>
 #include <virtio.h>
 #include <virtio_ring.h>
+#include <linux/compat.h>
 
 int virtqueue_add(struct virtqueue *vq, struct virtio_sg *sgs[],
 		  unsigned int out_sgs, unsigned int in_sgs)
diff --git a/drivers/w1-eeprom/ds2502.c b/drivers/w1-eeprom/ds2502.c
index 76ca460ed7..19ee4b17ea 100644
--- a/drivers/w1-eeprom/ds2502.c
+++ b/drivers/w1-eeprom/ds2502.c
@@ -22,6 +22,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <w1-eeprom.h>
 #include <w1.h>
diff --git a/drivers/w1/mxc_w1.c b/drivers/w1/mxc_w1.c
index 9279ba32b8..08715c6a66 100644
--- a/drivers/w1/mxc_w1.c
+++ b/drivers/w1/mxc_w1.c
@@ -20,6 +20,7 @@
 #include <asm/arch/clock.h>
 #include <common.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <linux/io.h>
 #include <w1.h>
 
diff --git a/drivers/watchdog/armada-37xx-wdt.c b/drivers/watchdog/armada-37xx-wdt.c
index 91cd8a6e6a..5da8e56505 100644
--- a/drivers/watchdog/armada-37xx-wdt.c
+++ b/drivers/watchdog/armada-37xx-wdt.c
@@ -11,6 +11,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
+#include <dm/device_compat.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/watchdog/cdns_wdt.c b/drivers/watchdog/cdns_wdt.c
index 13952e1e97..775f06a6e1 100644
--- a/drivers/watchdog/cdns_wdt.c
+++ b/drivers/watchdog/cdns_wdt.c
@@ -11,6 +11,7 @@
 #include <wdt.h>
 #include <clk.h>
 #include <div64.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/io.h>
 
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 3368bd8c00..67aeba1339 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -22,6 +22,7 @@
 
 
 #include <common.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <linux/stat.h>
 #include <div64.h>
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 37b31d9f0f..1c616a26a2 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -25,6 +25,7 @@
 #include <ext4fs.h>
 #include "ext4_common.h"
 #include <div64.h>
+#include <malloc.h>
 
 int ext4fs_symlinknest;
 struct ext_filesystem ext_fs;
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 729cf39630..320a8a7a87 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -9,6 +9,7 @@
 #include <command.h>
 #include <config.h>
 #include <fat.h>
+#include <malloc.h>
 #include <asm/byteorder.h>
 #include <part.h>
 #include <linux/ctype.h>
diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c
index 1e253611c3..af47224b6c 100644
--- a/fs/sandbox/sandboxfs.c
+++ b/fs/sandbox/sandboxfs.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <fs.h>
+#include <malloc.h>
 #include <os.h>
 
 int sandbox_fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index 5473d33997..a7c45dd5ec 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -17,6 +17,7 @@
  */
 
 #ifdef __UBOOT__
+#include <malloc.h>
 #include <linux/err.h>
 #endif
 #include "ubifs.h"
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 388451512a..e097d28444 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <env.h>
 #include <gzip.h>
+#include <malloc.h>
 #include <memalign.h>
 #include "ubifs.h"
 #include <dm/devres.h>
diff --git a/fs/yaffs2/yaffs_nandif.c b/fs/yaffs2/yaffs_nandif.c
index 79b00ab3b7..ee5a172060 100644
--- a/fs/yaffs2/yaffs_nandif.c
+++ b/fs/yaffs2/yaffs_nandif.c
@@ -13,6 +13,7 @@
 
 #include "yportenv.h"
 #include "yaffs_guts.h"
+#include <malloc.h>
 
 
 #include "yaffs_nandif.h"
diff --git a/fs/yaffs2/yaffs_uboot_glue.c b/fs/yaffs2/yaffs_uboot_glue.c
index 2a70e4a543..7a15a02974 100644
--- a/fs/yaffs2/yaffs_uboot_glue.c
+++ b/fs/yaffs2/yaffs_uboot_glue.c
@@ -21,6 +21,7 @@
 
 #include <common.h>
 #include <div64.h>
+#include <malloc.h>
 
 #include <config.h>
 #include "nand.h"
diff --git a/include/dm/device.h b/include/dm/device.h
index a93fa22d5d..4c79832597 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -720,75 +720,4 @@ static inline bool device_is_on_pci_bus(struct udevice *dev)
  */
 int dm_scan_fdt_dev(struct udevice *dev);
 
-/*
- * REVISIT:
- * remove the following after resolving conflicts with <linux/compat.h>
- */
-#ifdef dev_dbg
-#undef dev_dbg
-#endif
-#ifdef dev_vdbg
-#undef dev_vdbg
-#endif
-#ifdef dev_info
-#undef dev_info
-#endif
-#ifdef dev_err
-#undef dev_err
-#endif
-#ifdef dev_warn
-#undef dev_warn
-#endif
-
-/*
- * REVISIT:
- * print device name like Linux
- */
-#define dev_printk(dev, fmt, ...)				\
-({								\
-	printk(fmt, ##__VA_ARGS__);				\
-})
-
-#define __dev_printk(level, dev, fmt, ...)			\
-({								\
-	if (level < CONFIG_VAL(LOGLEVEL))			\
-		dev_printk(dev, fmt, ##__VA_ARGS__);		\
-})
-
-#define dev_emerg(dev, fmt, ...) \
-	__dev_printk(0, dev, fmt, ##__VA_ARGS__)
-#define dev_alert(dev, fmt, ...) \
-	__dev_printk(1, dev, fmt, ##__VA_ARGS__)
-#define dev_crit(dev, fmt, ...) \
-	__dev_printk(2, dev, fmt, ##__VA_ARGS__)
-#define dev_err(dev, fmt, ...) \
-	__dev_printk(3, dev, fmt, ##__VA_ARGS__)
-#define dev_warn(dev, fmt, ...) \
-	__dev_printk(4, dev, fmt, ##__VA_ARGS__)
-#define dev_notice(dev, fmt, ...) \
-	__dev_printk(5, dev, fmt, ##__VA_ARGS__)
-#define dev_info(dev, fmt, ...) \
-	__dev_printk(6, dev, fmt, ##__VA_ARGS__)
-
-#ifdef DEBUG
-#define dev_dbg(dev, fmt, ...) \
-	__dev_printk(7, dev, fmt, ##__VA_ARGS__)
-#else
-#define dev_dbg(dev, fmt, ...)					\
-({								\
-	if (0)							\
-		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
-})
-#endif
-
-#ifdef VERBOSE_DEBUG
-#define dev_vdbg	dev_dbg
-#else
-#define dev_vdbg(dev, fmt, ...)					\
-({								\
-	if (0)							\
-		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
-})
-#endif
-
 #endif
diff --git a/include/dm/device_compat.h b/include/dm/device_compat.h
new file mode 100644
index 0000000000..3d8cd09f4c
--- /dev/null
+++ b/include/dm/device_compat.h
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * (C) Copyright 2012
+ * Pavel Herrmann <morpheus.ibis@gmail.com>
+ * Marek Vasut <marex@denx.de>
+ */
+
+#ifndef _DM_DEVICE_COMPAT_H
+#define _DM_DEVICE_COMPAT_H
+
+#include <linux/compat.h>
+
+/*
+ * REVISIT:
+ * remove the following after resolving conflicts with <linux/compat.h>
+ */
+#ifdef dev_dbg
+#undef dev_dbg
+#endif
+#ifdef dev_vdbg
+#undef dev_vdbg
+#endif
+#ifdef dev_info
+#undef dev_info
+#endif
+#ifdef dev_err
+#undef dev_err
+#endif
+#ifdef dev_warn
+#undef dev_warn
+#endif
+
+/*
+ * REVISIT:
+ * print device name like Linux
+ */
+#define dev_printk(dev, fmt, ...)				\
+({								\
+	printk(fmt, ##__VA_ARGS__);				\
+})
+
+#define __dev_printk(level, dev, fmt, ...)			\
+({								\
+	if (level < CONFIG_VAL(LOGLEVEL))			\
+		dev_printk(dev, fmt, ##__VA_ARGS__);		\
+})
+
+#define dev_emerg(dev, fmt, ...) \
+	__dev_printk(0, dev, fmt, ##__VA_ARGS__)
+#define dev_alert(dev, fmt, ...) \
+	__dev_printk(1, dev, fmt, ##__VA_ARGS__)
+#define dev_crit(dev, fmt, ...) \
+	__dev_printk(2, dev, fmt, ##__VA_ARGS__)
+#define dev_err(dev, fmt, ...) \
+	__dev_printk(3, dev, fmt, ##__VA_ARGS__)
+#define dev_warn(dev, fmt, ...) \
+	__dev_printk(4, dev, fmt, ##__VA_ARGS__)
+#define dev_notice(dev, fmt, ...) \
+	__dev_printk(5, dev, fmt, ##__VA_ARGS__)
+#define dev_info(dev, fmt, ...) \
+	__dev_printk(6, dev, fmt, ##__VA_ARGS__)
+
+#ifdef DEBUG
+#define dev_dbg(dev, fmt, ...) \
+	__dev_printk(7, dev, fmt, ##__VA_ARGS__)
+#else
+#define dev_dbg(dev, fmt, ...)					\
+({								\
+	if (0)							\
+		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
+})
+#endif
+
+#ifdef VERBOSE_DEBUG
+#define dev_vdbg	dev_dbg
+#else
+#define dev_vdbg(dev, fmt, ...)					\
+({								\
+	if (0)							\
+		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
+})
+#endif
+
+#endif
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 0ef6e685ad..8a20743ad8 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -13,6 +13,7 @@
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <clk-uclass.h>
+#include <linux/err.h>
 
 static inline void clk_dm(ulong id, struct clk *clk)
 {
diff --git a/lib/bch.c b/lib/bch.c
index 86709cc875..8945d8d4cf 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -55,6 +55,7 @@
 
 #ifndef USE_HOSTCC
 #include <common.h>
+#include <malloc.h>
 #include <ubi_uboot.h>
 #include <dm/devres.h>
 
diff --git a/lib/binman.c b/lib/binman.c
index 1774bdf2e5..6cf6dcfdad 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <binman.h>
 #include <dm.h>
+#include <malloc.h>
 
 struct binman_info {
 	ofnode image;
diff --git a/lib/bzip2/bzlib.c b/lib/bzip2/bzlib.c
index 9262e4055e..377b269b06 100644
--- a/lib/bzip2/bzlib.c
+++ b/lib/bzip2/bzlib.c
@@ -1,5 +1,6 @@
 #include <config.h>
 #include <common.h>
+#include <malloc.h>
 #include <watchdog.h>
 
 /*
diff --git a/lib/crypto/rsa_helper.c b/lib/crypto/rsa_helper.c
index aca627a4a6..cc0c0d6637 100644
--- a/lib/crypto/rsa_helper.c
+++ b/lib/crypto/rsa_helper.c
@@ -6,6 +6,7 @@
  * Authors: Tadeusz Struk <tadeusz.struk@intel.com>
  */
 #ifndef __UBOOT__
+#include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/export.h>
 #endif
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index 7cba57b131..0c16a5fdd3 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <debug_uart.h>
 #include <errno.h>
+#include <malloc.h>
 #include <linux/err.h>
 #include <linux/types.h>
 #include <efi.h>
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index af5a878fc3..7c64077d42 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -13,6 +13,7 @@
 #include <debug_uart.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <linux/err.h>
 #include <linux/types.h>
 #include <efi.h>
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 6dd93ff435..7d650d512e 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -14,6 +14,7 @@
 #include <efi.h>
 #include <efi_api.h>
 #include <errno.h>
+#include <malloc.h>
 #include <ns16550.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index cf02341931..33e66fcad2 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -29,6 +29,7 @@
  */
 
 #include <efi_driver.h>
+#include <malloc.h>
 #include <dm/device-internal.h>
 #include <dm/root.h>
 
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index 25b27ece6d..f8badadf66 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -18,6 +18,7 @@
  */
 
 #include <efi_driver.h>
+#include <malloc.h>
 
 /**
  * check_node_type() - check node type
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 8494044799..ac0dec1146 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <charset.h>
+#include <malloc.h>
 #include <time.h>
 #include <dm/device.h>
 #include <efi_loader.h>
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index df0485cdad..4b3c843b2c 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -11,6 +11,7 @@
 #include <dm.h>
 #include <elf.h>
 #include <efi_loader.h>
+#include <malloc.h>
 #include <rtc.h>
 #include <u-boot/crc.h>
 
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 17051d409c..f329bae194 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <hang.h>
 #include <init.h>
+#include <malloc.h>
 #include <dm/of_extra.h>
 #include <env.h>
 #include <errno.h>
diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c
index 684c512bb9..dd859d3467 100644
--- a/lib/libavb/avb_cmdline.c
+++ b/lib/libavb/avb_cmdline.c
@@ -7,6 +7,7 @@
 #include "avb_sha.h"
 #include "avb_util.h"
 #include "avb_version.h"
+#include <malloc.h>
 
 #define NUM_GUIDS 3
 
diff --git a/lib/libavb/avb_descriptor.c b/lib/libavb/avb_descriptor.c
index 9f03b9777a..86b8d1b994 100644
--- a/lib/libavb/avb_descriptor.c
+++ b/lib/libavb/avb_descriptor.c
@@ -6,6 +6,7 @@
 #include "avb_descriptor.h"
 #include "avb_util.h"
 #include "avb_vbmeta_image.h"
+#include <malloc.h>
 
 bool avb_descriptor_validate_and_byteswap(const AvbDescriptor* src,
                                           AvbDescriptor* dest) {
diff --git a/lib/libavb/avb_rsa.c b/lib/libavb/avb_rsa.c
index bbf15626b8..d7bf8905be 100644
--- a/lib/libavb/avb_rsa.c
+++ b/lib/libavb/avb_rsa.c
@@ -12,6 +12,7 @@
 #include "avb_sha.h"
 #include "avb_util.h"
 #include "avb_vbmeta_image.h"
+#include <malloc.h>
 
 typedef struct IAvbKey {
   unsigned int len; /* Length of n[] in number of uint32_t */
diff --git a/lib/libavb/avb_slot_verify.c b/lib/libavb/avb_slot_verify.c
index c0defdf9c9..58baf522fc 100644
--- a/lib/libavb/avb_slot_verify.c
+++ b/lib/libavb/avb_slot_verify.c
@@ -14,6 +14,7 @@
 #include "avb_util.h"
 #include "avb_vbmeta_image.h"
 #include "avb_version.h"
+#include <malloc.h>
 
 /* Maximum number of partitions that can be loaded with avb_slot_verify(). */
 #define MAX_NUMBER_OF_LOADED_PARTITIONS 32
diff --git a/lib/libavb/avb_sysdeps_posix.c b/lib/libavb/avb_sysdeps_posix.c
index 0bb0cc1498..6ffdb0b7eb 100644
--- a/lib/libavb/avb_sysdeps_posix.c
+++ b/lib/libavb/avb_sysdeps_posix.c
@@ -4,6 +4,7 @@
  */
 
 #include <hang.h>
+#include <malloc.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
diff --git a/lib/libavb/avb_util.c b/lib/libavb/avb_util.c
index 405d625351..94773b77e7 100644
--- a/lib/libavb/avb_util.c
+++ b/lib/libavb/avb_util.c
@@ -4,6 +4,7 @@
  */
 
 #include "avb_util.h"
+#include <malloc.h>
 
 #include <stdarg.h>
 
diff --git a/lib/linux_compat.c b/lib/linux_compat.c
index 3f440deaa0..89a6fd6ec9 100644
--- a/lib/linux_compat.c
+++ b/lib/linux_compat.c
@@ -1,5 +1,6 @@
 
 #include <common.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <linux/compat.h>
 
diff --git a/lib/lmb.c b/lib/lmb.c
index b3b84e4d37..07b9308adf 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <lmb.h>
+#include <malloc.h>
 
 #define LMB_ALLOC_ANYWHERE	0
 
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 5b5905aeb5..6400ef63d6 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -4,6 +4,7 @@
  */
 
 #include "mkimage.h"
+#include <malloc.h>
 #include <stdio.h>
 #include <string.h>
 #include <image.h>
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 82dc513260..326a5e4ea9 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -6,6 +6,7 @@
 #ifndef USE_HOSTCC
 #include <common.h>
 #include <fdtdec.h>
+#include <malloc.h>
 #include <asm/types.h>
 #include <asm/byteorder.h>
 #include <linux/errno.h>
diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
index ac5ab528bb..ae3be3f02a 100644
--- a/lib/zstd/decompress.c
+++ b/lib/zstd/decompress.c
@@ -23,6 +23,7 @@
 #include "huf.h"
 #include "mem.h" /* low level memory routines */
 #include "zstd_internal.h"
+#include <malloc.h>
 #include <linux/kernel.h>
 #include <linux/compat.h>
 #include <linux/string.h> /* memcpy, memmove, memset */
diff --git a/lib/zstd/zstd_common.c b/lib/zstd/zstd_common.c
index 9a217e1573..6b2c79eeb6 100644
--- a/lib/zstd/zstd_common.c
+++ b/lib/zstd/zstd_common.c
@@ -9,6 +9,7 @@
 ***************************************/
 #include "error_private.h"
 #include "zstd_internal.h" /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode, ZSTD_getErrorString, ZSTD_versionNumber */
+#include <malloc.h>
 #include <linux/kernel.h>
 
 /*=**************************************************************
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index f75e4df626..8e7872155a 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -6,9 +6,12 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/uclass-internal.h>
+#include <linux/compat.h>
 
 /* DT node properties for MAC-PHY interface */
 #define PHY_MODE_STR_CNT	2
diff --git a/post/post.c b/post/post.c
index f27138ddaa..696a60f70a 100644
--- a/post/post.c
+++ b/post/post.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <env.h>
+#include <malloc.h>
 #include <stdio_dev.h>
 #include <time.h>
 #include <watchdog.h>
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 31335a543f..003b78934f 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <malloc.h>
 #include <asm/clk.h>
 #include <dm/test.h>
 #include <dm/device-internal.h>
diff --git a/test/dm/dma.c b/test/dm/dma.c
index b56d17731d..12cba57a56 100644
--- a/test/dm/dma.c
+++ b/test/dm/dma.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <dma.h>
 #include <test/ut.h>
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index bb4b20cea9..349123a657 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/root.h>
 #include <dm/test.h>
 #include <dm/util.h>
diff --git a/test/dm/mailbox.c b/test/dm/mailbox.c
index 4562d2ac4f..e6c521b8b5 100644
--- a/test/dm/mailbox.c
+++ b/test/dm/mailbox.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <asm/mbox.h>
 #include <test/ut.h>
diff --git a/test/dm/power-domain.c b/test/dm/power-domain.c
index 48318218a9..8baf5d09d1 100644
--- a/test/dm/power-domain.c
+++ b/test/dm/power-domain.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <asm/power-domain.h>
 #include <test/ut.h>
diff --git a/test/dm/reset.c b/test/dm/reset.c
index c61daed490..8370820428 100644
--- a/test/dm/reset.c
+++ b/test/dm/reset.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <reset.h>
 #include <dm/test.h>
 #include <asm/reset.h>
diff --git a/test/dm/spmi.c b/test/dm/spmi.c
index e6a910859e..668b7e133f 100644
--- a/test/dm/spmi.c
+++ b/test/dm/spmi.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/device.h>
 #include <dm/root.h>
 #include <dm/test.h>
diff --git a/test/dm/tee.c b/test/dm/tee.c
index 22f05a4219..d40f13d291 100644
--- a/test/dm/tee.c
+++ b/test/dm/tee.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <sandboxtee.h>
 #include <tee.h>
diff --git a/test/dm/video.c b/test/dm/video.c
index 3151ebb73f..f72979fac4 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <bzlib.h>
 #include <dm.h>
+#include <malloc.h>
 #include <mapmem.h>
 #include <os.h>
 #include <video.h>
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index ec68227bb6..1336b54b11 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <lmb.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <test/ut.h>
 
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index 47532a64df..4d99c20bc0 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -9,6 +9,7 @@
 #include <charset.h>
 #include <command.h>
 #include <errno.h>
+#include <malloc.h>
 #include <test/test.h>
 #include <test/suites.h>
 #include <test/ut.h>
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (29 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-03 14:36 ` [PATCH v2 32/32] sandbox: Complete migration away from os_malloc() Simon Glass
                   ` (8 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Most files don't need this header and it pulls in quite of lots of stuff,
malloc() in particular. Drop it.

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

Changes in v2: None

 board/hisilicon/poplar/poplar.c | 2 +-
 drivers/ram/imxrt_sdram.c       | 1 +
 include/dm/device.h             | 1 -
 include/linux/compat.h          | 3 +++
 include/phy.h                   | 1 +
 5 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/board/hisilicon/poplar/poplar.c b/board/hisilicon/poplar/poplar.c
index 36999bdcea..4937dc374c 100644
--- a/board/hisilicon/poplar/poplar.c
+++ b/board/hisilicon/poplar/poplar.c
@@ -4,9 +4,9 @@
  * Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
  */
 
+#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
-#include <common.h>
 #include <init.h>
 #include <asm/io.h>
 #include <dm/platform_data/serial_pl01x.h>
diff --git a/drivers/ram/imxrt_sdram.c b/drivers/ram/imxrt_sdram.c
index af7400be82..ac15e94f00 100644
--- a/drivers/ram/imxrt_sdram.c
+++ b/drivers/ram/imxrt_sdram.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <ram.h>
 #include <asm/io.h>
+#include <linux/err.h>
 
 /* SDRAM Command Code */
 #define SD_CC_ARD		0x0     /* Master Bus (AXI) command - Read */
diff --git a/include/dm/device.h b/include/dm/device.h
index 4c79832597..cb1cd27738 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -14,7 +14,6 @@
 #include <dm/uclass-id.h>
 #include <fdtdec.h>
 #include <linker_lists.h>
-#include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/printk.h>
diff --git a/include/linux/compat.h b/include/linux/compat.h
index d0f51baab4..171188a76f 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -123,7 +123,10 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep)
 
 #define KERNEL_VERSION(a,b,c)	(((a) << 16) + ((b) << 8) + (c))
 
+/* This is also defined in ARMv8's mmu.h */
+#ifndef PAGE_SIZE
 #define PAGE_SIZE	4096
+#endif
 
 /* drivers/char/random.c */
 #define get_random_bytes(...)
diff --git a/include/phy.h b/include/phy.h
index 6ace9b3a0c..42cfc59ec0 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -10,6 +10,7 @@
 #define _PHY_H
 
 #include <dm.h>
+#include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 32/32] sandbox: Complete migration away from os_malloc()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (30 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h Simon Glass
@ 2020-02-03 14:36 ` Simon Glass
  2020-02-06  2:31 ` sjg at google.com
                   ` (7 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: Simon Glass @ 2020-02-03 14:36 UTC (permalink / raw)
  To: u-boot

Now that we can use direct access to the system malloc() in sandbox, drop
the remaining uses of os_malloc().

The only one remaining now is for the RAM buffer, which we do want to be
at a known address, so this is intended.

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

Changes in v2:
- Fix 'adress' typo

 drivers/misc/cros_ec_sandbox.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 4fcb2d96f5..9dd6a18b2b 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -11,10 +11,10 @@
 #include <ec_commands.h>
 #include <errno.h>
 #include <hash.h>
-#include <malloc.h>
 #include <os.h>
 #include <u-boot/sha256.h>
 #include <spi.h>
+#include <asm/malloc.h>
 #include <asm/state.h>
 #include <asm/sdl.h>
 #include <linux/input.h>
@@ -115,7 +115,7 @@ static int cros_ec_read_state(const void *blob, int node)
 	prop = fdt_getprop(blob, node, "flash-data", &len);
 	if (prop) {
 		ec->flash_data_len = len;
-		ec->flash_data = os_malloc(len);
+		ec->flash_data = malloc(len);
 		if (!ec->flash_data)
 			return -ENOMEM;
 		memcpy(ec->flash_data, prop, len);
@@ -545,14 +545,14 @@ int cros_ec_probe(struct udevice *dev)
 	    ec->flash_data_len != ec->ec_config.flash.length) {
 		printf("EC data length is %x, expected %x, discarding data\n",
 		       ec->flash_data_len, ec->ec_config.flash.length);
-		os_free(ec->flash_data);
+		free(ec->flash_data);
 		ec->flash_data = NULL;
 	}
 
 	/* Otherwise allocate the memory */
 	if (!ec->flash_data) {
 		ec->flash_data_len = ec->ec_config.flash.length;
-		ec->flash_data = os_malloc(ec->flash_data_len);
+		ec->flash_data = malloc(ec->flash_data_len);
 		if (!ec->flash_data)
 			return -ENOMEM;
 	}
-- 
2.25.0.341.g760bfbb309-goog

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

* [PATCH v2 32/32] sandbox: Complete migration away from os_malloc()
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (31 preceding siblings ...)
  2020-02-03 14:36 ` [PATCH v2 32/32] sandbox: Complete migration away from os_malloc() Simon Glass
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h sjg at google.com
                   ` (6 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

Now that we can use direct access to the system malloc() in sandbox, drop
the remaining uses of os_malloc().

The only one remaining now is for the RAM buffer, which we do want to be
at a known address, so this is intended.

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

Changes in v2:
- Fix 'adress' typo

 drivers/misc/cros_ec_sandbox.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (32 preceding siblings ...)
  2020-02-06  2:31 ` sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features sjg at google.com
                   ` (5 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

Most files don't need this header and it pulls in quite of lots of stuff,
malloc() in particular. Drop it.

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

Changes in v2: None

 board/hisilicon/poplar/poplar.c | 2 +-
 drivers/ram/imxrt_sdram.c       | 1 +
 include/dm/device.h             | 1 -
 include/linux/compat.h          | 3 +++
 include/phy.h                   | 1 +
 5 files changed, 6 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (33 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header sjg at google.com
                   ` (4 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

At present dm/device.h includes the linux-compatible features. This
requires including linux/compat.h which in turn includes a lot of headers.
One of these is malloc.h which we thus end up including in every file in
U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
which needs to use the system malloc() in some files.

Move the compatibility features into a separate header file.

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

Changes in v2: None

 arch/arm/mach-imx/cmd_nandbcb.c               |  1 +
 arch/arm/mach-imx/imx8/image.c                |  1 +
 arch/arm/mach-mvebu/mbus.c                    |  1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c        |  1 +
 arch/arm/mach-rockchip/rk3308/rk3308.c        |  1 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |  1 +
 arch/arm/mach-socfpga/clock_manager_arria10.c |  1 +
 arch/arm/mach-stm32mp/pwr_regulator.c         |  1 +
 arch/arm/mach-tegra/cboot.c                   |  1 +
 arch/arm/mach-zynq/clk.c                      |  1 +
 arch/arm/mach-zynq/timer.c                    |  1 +
 arch/mips/mach-mtmips/cpu.c                   |  1 +
 arch/mips/mach-pic32/cpu.c                    |  1 +
 arch/sandbox/cpu/cpu.c                        |  1 +
 arch/x86/cpu/apollolake/fsp_s.c               |  1 +
 arch/x86/cpu/apollolake/itss.c                |  1 +
 arch/x86/cpu/apollolake/spl.c                 |  1 +
 arch/x86/cpu/apollolake/uart.c                |  1 +
 arch/x86/cpu/qemu/e820.c                      |  1 +
 arch/x86/cpu/qfw_cpu.c                        |  1 +
 arch/x86/lib/coreboot_table.c                 |  1 +
 arch/x86/lib/fsp1/fsp_common.c                |  1 +
 arch/x86/lib/mrccache.c                       |  1 +
 arch/x86/lib/tables.c                         |  1 +
 board/compulab/common/common.c                |  1 +
 board/corscience/tricorder/tricorder.c        |  1 +
 board/gardena/smart-gateway-mt7688/board.c    |  1 +
 board/ge/common/vpd_reader.c                  |  1 +
 board/isee/igep003x/board.c                   |  1 +
 board/isee/igep00x0/igep00x0.c                |  1 +
 board/menlo/m53menlo/m53menlo.c               |  1 +
 board/microchip/pic32mzda/pic32mzda.c         |  1 +
 board/overo/overo.c                           |  1 +
 board/siemens/common/board.c                  |  1 +
 board/siemens/pxm2/board.c                    |  1 +
 board/siemens/rut/board.c                     |  1 +
 board/st/stm32mp1/stm32mp1.c                  |  1 +
 board/synopsys/hsdk/clk-lib.c                 |  1 +
 board/technexion/tao3530/tao3530.c            |  1 +
 board/ti/am335x/board.c                       |  1 +
 board/ti/am57xx/board.c                       |  1 +
 board/timll/devkit8000/devkit8000.c           |  1 +
 cmd/bootefi.c                                 |  1 +
 cmd/gpio.c                                    |  1 +
 cmd/host.c                                    |  1 +
 cmd/rng.c                                     |  1 +
 cmd/tpm-common.c                              |  1 +
 cmd/ubi.c                                     |  1 +
 cmd/usb_mass_storage.c                        |  1 +
 cmd/ximg.c                                    |  1 +
 common/android_ab.c                           |  1 +
 common/autoboot.c                             |  1 +
 common/image-fdt.c                            |  1 +
 common/image.c                                |  1 +
 common/usb.c                                  |  1 +
 common/usb_hub.c                              |  1 +
 drivers/adc/stm32-adc-core.c                  |  1 +
 drivers/adc/stm32-adc.c                       |  1 +
 drivers/axi/sandbox_store.c                   |  1 +
 drivers/block/blk-uclass.c                    |  1 +
 drivers/block/sandbox.c                       |  1 +
 drivers/clk/altera/clk-arria10.c              |  2 +
 drivers/clk/at91/clk-generated.c              |  1 +
 drivers/clk/at91/clk-h32mx.c                  |  1 +
 drivers/clk/at91/clk-peripheral.c             |  1 +
 drivers/clk/clk-cdce9xx.c                     |  1 +
 drivers/clk/clk-ti-sci.c                      |  2 +
 drivers/clk/clk-uclass.c                      |  1 +
 drivers/clk/clk_sandbox.c                     |  1 +
 drivers/clk/clk_sandbox_ccf.c                 |  1 +
 drivers/clk/clk_sandbox_test.c                |  2 +
 drivers/clk/clk_versal.c                      |  1 +
 drivers/clk/clk_vexpress_osc.c                |  1 +
 drivers/clk/clk_zynq.c                        |  1 +
 drivers/clk/clk_zynqmp.c                      |  2 +
 drivers/clk/imx/clk-imx8.c                    |  1 +
 drivers/clk/mvebu/armada-37xx-periph.c        |  1 +
 drivers/clk/mvebu/armada-37xx-tbg.c           |  1 +
 drivers/clk/rockchip/clk_px30.c               |  1 +
 drivers/clk/rockchip/clk_rk3036.c             |  1 +
 drivers/clk/rockchip/clk_rk3128.c             |  1 +
 drivers/clk/rockchip/clk_rk3188.c             |  1 +
 drivers/clk/rockchip/clk_rk322x.c             |  1 +
 drivers/clk/rockchip/clk_rk3288.c             |  1 +
 drivers/clk/rockchip/clk_rk3308.c             |  1 +
 drivers/clk/rockchip/clk_rk3328.c             |  1 +
 drivers/clk/rockchip/clk_rk3368.c             |  1 +
 drivers/clk/rockchip/clk_rk3399.c             |  1 +
 drivers/clk/rockchip/clk_rv1108.c             |  1 +
 drivers/clk/tegra/tegra-car-clk.c             |  1 +
 drivers/clk/uniphier/clk-uniphier-core.c      |  1 +
 drivers/core/devres.c                         |  1 +
 drivers/core/of_access.c                      |  1 +
 drivers/core/ofnode.c                         |  1 +
 drivers/core/syscon-uclass.c                  |  1 +
 drivers/ddr/altera/sdram_gen5.c               |  1 +
 drivers/ddr/altera/sdram_soc64.c              |  1 +
 drivers/dma/bcm6348-iudma.c                   |  1 +
 drivers/dma/dma-uclass.c                      |  1 +
 drivers/dma/sandbox-dma-test.c                |  1 +
 drivers/dma/ti/k3-udma.c                      |  1 +
 drivers/firmware/ti_sci.c                     |  2 +
 drivers/fpga/fpga.c                           |  1 +
 drivers/gpio/74x164_gpio.c                    |  1 +
 drivers/gpio/adi_gpio2.c                      |  1 +
 drivers/gpio/at91_gpio.c                      |  1 +
 drivers/gpio/atmel_pio4.c                     |  1 +
 drivers/gpio/da8xx_gpio.c                     |  1 +
 drivers/gpio/dwapb_gpio.c                     |  1 +
 drivers/gpio/gpio-rcar.c                      |  2 +
 drivers/gpio/kona_gpio.c                      |  1 +
 drivers/gpio/mpc83xx_gpio.c                   |  1 +
 drivers/gpio/mscc_sgpio.c                     |  1 +
 drivers/gpio/mvgpio.c                         |  1 +
 drivers/gpio/mxs_gpio.c                       |  1 +
 drivers/gpio/pca953x_gpio.c                   |  1 +
 drivers/gpio/pca9698.c                        |  1 +
 drivers/gpio/sh_pfc.c                         |  1 +
 drivers/gpio/spear_gpio.c                     |  1 +
 drivers/gpio/stm32_gpio.c                     |  1 +
 drivers/hwspinlock/hwspinlock-uclass.c        |  2 +
 drivers/hwspinlock/stm32_hwspinlock.c         |  1 +
 drivers/i2c/at91_i2c.c                        |  1 +
 drivers/i2c/designware_i2c.c                  |  2 +
 drivers/i2c/i2c-uniphier-f.c                  |  1 +
 drivers/i2c/i2c-uniphier.c                    |  1 +
 drivers/i2c/imx_lpi2c.c                       |  1 +
 drivers/i2c/muxes/i2c-arb-gpio-challenge.c    |  1 +
 drivers/i2c/muxes/i2c-mux-gpio.c              |  1 +
 drivers/i2c/muxes/i2c-mux-uclass.c            |  1 +
 drivers/i2c/muxes/pca954x.c                   |  1 +
 drivers/i2c/mxc_i2c.c                         |  1 +
 drivers/i2c/rcar_i2c.c                        |  1 +
 drivers/i2c/stm32f7_i2c.c                     |  1 +
 drivers/i2c/xilinx_xiic.c                     |  1 +
 drivers/led/led_gpio.c                        |  1 +
 drivers/mailbox/k3-sec-proxy.c                |  2 +
 drivers/mailbox/mailbox-uclass.c              |  1 +
 drivers/mailbox/sandbox-mbox-test.c           |  1 +
 drivers/mailbox/sandbox-mbox.c                |  1 +
 drivers/mailbox/stm32-ipcc.c                  |  2 +
 drivers/mailbox/tegra-hsp.c                   |  1 +
 drivers/mailbox/zynqmp-ipi.c                  |  1 +
 drivers/misc/imx8/scu_api.c                   |  1 +
 drivers/misc/k3_avs.c                         |  1 +
 drivers/misc/p2sb-uclass.c                    |  1 +
 drivers/misc/stm32_rcc.c                      |  1 +
 drivers/misc/tegra186_bpmp.c                  |  1 +
 drivers/misc/vexpress_config.c                |  1 +
 drivers/mmc/am654_sdhci.c                     |  1 +
 drivers/mmc/arm_pl180_mmci.c                  |  1 +
 drivers/mmc/bcm2835_sdhost.c                  |  1 +
 drivers/mmc/fsl_esdhc.c                       |  1 +
 drivers/mmc/fsl_esdhc_imx.c                   |  1 +
 drivers/mmc/jz_mmc.c                          |  1 +
 drivers/mmc/mmc-uclass.c                      |  2 +
 drivers/mmc/msm_sdhci.c                       |  1 +
 drivers/mmc/mtk-sd.c                          |  1 +
 drivers/mmc/renesas-sdhi.c                    |  2 +
 drivers/mmc/sdhci-cadence.c                   |  1 +
 drivers/mmc/sh_mmcif.c                        |  1 +
 drivers/mmc/sh_sdhi.c                         |  1 +
 drivers/mmc/snps_dw_mmc.c                     |  1 +
 drivers/mmc/socfpga_dw_mmc.c                  |  1 +
 drivers/mmc/stm32_sdmmc2.c                    |  1 +
 drivers/mmc/tmio-common.c                     |  1 +
 drivers/mmc/uniphier-sd.c                     |  2 +
 drivers/mmc/zynq_sdhci.c                      |  1 +
 drivers/mtd/hbmc-am654.c                      |  1 +
 drivers/mtd/mtd_uboot.c                       |  1 +
 drivers/mtd/nand/core.c                       |  1 +
 drivers/mtd/nand/raw/atmel_nand.c             |  1 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      |  1 +
 .../mtd/nand/raw/brcmnand/brcmnand_compat.c   |  3 +-
 drivers/mtd/nand/raw/denali.c                 |  2 +
 drivers/mtd/nand/raw/denali_dt.c              |  1 +
 drivers/mtd/nand/raw/pxa3xx_nand.c            |  1 +
 drivers/mtd/nand/raw/sunxi_nand.c             |  2 +
 drivers/mtd/nand/raw/tegra_nand.c             |  1 +
 drivers/mtd/nand/raw/vf610_nfc.c              |  1 +
 drivers/mtd/nand/spi/core.c                   |  1 +
 drivers/mtd/nand/spi/gigadevice.c             |  1 +
 drivers/mtd/nand/spi/macronix.c               |  1 +
 drivers/mtd/nand/spi/micron.c                 |  1 +
 drivers/mtd/nand/spi/winbond.c                |  1 +
 drivers/mtd/renesas_rpc_hf.c                  |  2 +
 drivers/mtd/spi/sf-uclass.c                   |  1 +
 drivers/mtd/spi/spi-nor-core.c                |  1 +
 drivers/mtd/spi/spi-nor-tiny.c                |  1 +
 drivers/mtd/ubi/debug.c                       |  1 +
 drivers/mtd/ubi/misc.c                        |  1 +
 drivers/mtd/ubi/upd.c                         |  1 +
 drivers/net/bcm6348-eth.c                     |  1 +
 drivers/net/bcm6368-eth.c                     |  2 +
 drivers/net/designware.c                      |  1 +
 drivers/net/dwc_eth_qos.c                     |  1 +
 drivers/net/dwmac_socfpga.c                   |  1 +
 drivers/net/e1000.c                           |  1 +
 drivers/net/e1000_spi.c                       |  1 +
 drivers/net/fsl-mc/dpio/qbman_portal.c        |  1 +
 drivers/net/fsl-mc/mc.c                       |  1 +
 drivers/net/fsl_enetc.c                       |  1 +
 drivers/net/ftgmac100.c                       |  2 +
 drivers/net/higmacv300.c                      |  1 +
 drivers/net/mscc_eswitch/jr2_switch.c         |  1 +
 drivers/net/mscc_eswitch/luton_switch.c       |  1 +
 drivers/net/mscc_eswitch/ocelot_switch.c      |  1 +
 drivers/net/mscc_eswitch/serval_switch.c      |  1 +
 drivers/net/mscc_eswitch/servalt_switch.c     |  1 +
 drivers/net/mtk_eth.c                         |  1 +
 drivers/net/mvneta.c                          |  1 +
 drivers/net/mvpp2.c                           |  1 +
 drivers/net/pch_gbe.c                         |  1 +
 drivers/net/pfe_eth/pfe_driver.c              |  1 +
 drivers/net/pfe_eth/pfe_eth.c                 |  1 +
 drivers/net/pfe_eth/pfe_firmware.c            |  1 +
 drivers/net/pfe_eth/pfe_mdio.c                |  1 +
 drivers/net/phy/fixed.c                       |  1 +
 drivers/net/pic32_eth.c                       |  1 +
 drivers/net/sandbox-raw-bus.c                 |  1 +
 drivers/net/sni_ave.c                         |  8 +-
 drivers/net/sun8i_emac.c                      |  1 +
 drivers/net/sunxi_emac.c                      |  1 +
 drivers/net/ti/am65-cpsw-nuss.c               |  2 +
 drivers/net/ti/cpsw-common.c                  |  1 +
 drivers/net/ti/cpsw.c                         |  1 +
 drivers/net/ti/cpsw_mdio.c                    |  1 +
 drivers/net/zynq_gem.c                        |  1 +
 drivers/nvme/nvme.c                           |  2 +
 drivers/pci/pci-aardvark.c                    |  1 +
 drivers/pci/pci-uclass.c                      |  1 +
 drivers/pci/pci_mvebu.c                       |  1 +
 drivers/pci/pcie_dw_ti.c                      |  1 +
 drivers/pci/pcie_fsl.c                        |  1 +
 drivers/pci/pcie_imx.c                        |  1 +
 drivers/pci/pcie_intel_fpga.c                 |  1 +
 drivers/pci/pcie_mediatek.c                   |  1 +
 drivers/phy/allwinner/phy-sun4i-usb.c         |  1 +
 drivers/phy/bcm6318-usbh-phy.c                |  1 +
 drivers/phy/bcm6348-usbh-phy.c                |  1 +
 drivers/phy/bcm6358-usbh-phy.c                |  1 +
 drivers/phy/bcm6368-usbh-phy.c                |  1 +
 drivers/phy/marvell/comphy_core.c             |  1 +
 drivers/phy/meson-g12a-usb2.c                 |  1 +
 drivers/phy/meson-g12a-usb3-pcie.c            |  1 +
 drivers/phy/meson-gxl-usb2.c                  |  1 +
 drivers/phy/meson-gxl-usb3.c                  |  1 +
 drivers/phy/phy-mtk-tphy.c                    |  2 +
 drivers/phy/phy-rcar-gen2.c                   |  2 +
 drivers/phy/phy-rcar-gen3.c                   |  1 +
 drivers/phy/phy-stm32-usbphyc.c               |  1 +
 drivers/phy/phy-ti-am654.c                    |  1 +
 drivers/pinctrl/broadcom/pinctrl-bcm6838.c    |  1 +
 drivers/pinctrl/intel/pinctrl.c               |  1 +
 drivers/pinctrl/meson/pinctrl-meson.c         |  2 +
 drivers/pinctrl/mscc/mscc-common.c            |  1 +
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  1 +
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c   |  2 +
 drivers/pinctrl/nxp/pinctrl-imx.c             |  2 +
 drivers/pinctrl/nxp/pinctrl-mxs.c             |  1 +
 drivers/pinctrl/pinctrl-generic.c             |  1 +
 drivers/pinctrl/pinctrl-single.c              |  1 +
 drivers/pinctrl/pinctrl-stmfx.c               |  1 +
 drivers/pinctrl/pinctrl-uclass.c              |  2 +
 drivers/pinctrl/pinctrl_stm32.c               |  2 +
 drivers/pinctrl/renesas/pfc.c                 |  1 +
 .../pinctrl/uniphier/pinctrl-uniphier-core.c  |  1 +
 drivers/power/domain/bcm6328-power-domain.c   |  1 +
 .../power/domain/imx8-power-domain-legacy.c   |  1 +
 drivers/power/domain/imx8-power-domain.c      |  1 +
 drivers/power/domain/imx8m-power-domain.c     |  1 +
 drivers/power/domain/meson-ee-pwrc.c          |  1 +
 drivers/power/domain/meson-gx-pwrc-vpu.c      |  1 +
 drivers/power/domain/mtk-power-domain.c       |  1 +
 drivers/power/domain/power-domain-uclass.c    |  1 +
 .../power/domain/sandbox-power-domain-test.c  |  1 +
 drivers/power/domain/sandbox-power-domain.c   |  1 +
 drivers/power/domain/tegra186-power-domain.c  |  1 +
 drivers/power/domain/ti-sci-power-domain.c    |  2 +
 drivers/power/pmic/fan53555.c                 |  1 +
 drivers/power/pmic/i2c_pmic_emul.c            |  1 +
 drivers/power/pmic/stpmic1.c                  |  1 +
 drivers/power/regulator/pwm_regulator.c       |  1 +
 drivers/power/regulator/stm32-vrefbuf.c       |  1 +
 drivers/power/regulator/tps62360_regulator.c  |  1 +
 drivers/ram/k3-am654-ddrss.c                  |  1 +
 drivers/ram/k3-j721e/k3-j721e-ddrss.c         |  1 +
 drivers/ram/stm32_sdram.c                     |  1 +
 drivers/remoteproc/k3_system_controller.c     |  1 +
 drivers/remoteproc/rproc-elf-loader.c         |  3 +-
 drivers/remoteproc/stm32_copro.c              |  1 +
 drivers/remoteproc/ti_k3_arm64_rproc.c        |  1 +
 drivers/remoteproc/ti_k3_dsp_rproc.c          |  2 +
 drivers/remoteproc/ti_k3_r5f_rproc.c          |  2 +
 drivers/reset/reset-bcm6345.c                 |  1 +
 drivers/reset/reset-hisilicon.c               |  1 +
 drivers/reset/reset-imx7.c                    |  1 +
 drivers/reset/reset-mediatek.c                |  1 +
 drivers/reset/reset-meson.c                   |  1 +
 drivers/reset/reset-mtmips.c                  |  1 +
 drivers/reset/reset-rockchip.c                |  1 +
 drivers/reset/reset-socfpga.c                 |  1 +
 drivers/reset/reset-sunxi.c                   |  1 +
 drivers/reset/reset-ti-sci.c                  |  2 +
 drivers/reset/reset-uclass.c                  |  1 +
 drivers/reset/reset-uniphier.c                |  2 +
 drivers/reset/sandbox-reset-test.c            |  1 +
 drivers/reset/sandbox-reset.c                 |  1 +
 drivers/reset/sti-reset.c                     |  1 +
 drivers/reset/stm32-reset.c                   |  1 +
 drivers/reset/tegra-car-reset.c               |  1 +
 drivers/reset/tegra186-reset.c                |  1 +
 drivers/rtc/ds3232.c                          |  1 +
 drivers/rtc/rv3029.c                          |  1 +
 drivers/rtc/stm32_rtc.c                       |  2 +
 drivers/serial/atmel_usart.c                  |  1 +
 drivers/serial/serial-uclass.c                |  1 +
 drivers/serial/serial_bcm6345.c               |  1 +
 drivers/serial/serial_lpuart.c                |  1 +
 drivers/serial/serial_msm.c                   |  1 +
 drivers/serial/serial_pic32.c                 |  1 +
 drivers/serial/serial_stm32.c                 |  1 +
 drivers/serial/serial_zynq.c                  |  1 +
 drivers/smem/msm_smem.c                       |  1 +
 drivers/soc/ti/k3-navss-ringacc.c             |  1 +
 drivers/sound/sound-uclass.c                  |  1 +
 drivers/spi/atmel-quadspi.c                   |  2 +
 drivers/spi/bcm63xx_hsspi.c                   |  1 +
 drivers/spi/bcm63xx_spi.c                     |  1 +
 drivers/spi/cadence_qspi.c                    |  1 +
 drivers/spi/designware_spi.c                  |  1 +
 drivers/spi/mvebu_a3700_spi.c                 |  1 +
 drivers/spi/mxc_spi.c                         |  1 +
 drivers/spi/spi-mem-nodm.c                    |  1 +
 drivers/spi/spi-mem.c                         |  1 +
 drivers/spi/spi-sunxi.c                       |  1 +
 drivers/spi/stm32_qspi.c                      |  1 +
 drivers/spi/stm32_spi.c                       |  2 +
 drivers/spi/uniphier_spi.c                    |  1 +
 drivers/spi/zynqmp_gqspi.c                    |  1 +
 drivers/spmi/spmi-msm.c                       |  1 +
 drivers/sysreset/sysreset-ti-sci.c            |  1 +
 drivers/tee/optee/core.c                      |  1 +
 drivers/tee/optee/rpmb.c                      |  1 +
 drivers/tee/optee/supplicant.c                |  1 +
 drivers/tee/tee-uclass.c                      |  3 +-
 drivers/timer/dw-apb-timer.c                  |  2 +
 drivers/timer/ostm_timer.c                    |  1 +
 drivers/timer/stm32_timer.c                   |  1 +
 drivers/ufs/cdns-platform.c                   |  1 +
 drivers/ufs/ti-j721e-ufs.c                    |  1 +
 drivers/ufs/ufs.c                             |  1 +
 drivers/usb/cdns3/cdns3-ti.c                  |  1 +
 drivers/usb/cdns3/core.c                      |  1 +
 drivers/usb/cdns3/drd.c                       |  1 +
 drivers/usb/cdns3/ep0.c                       |  1 +
 drivers/usb/cdns3/gadget.c                    |  1 +
 drivers/usb/dwc3/core.c                       |  1 +
 drivers/usb/dwc3/dwc3-omap.c                  |  1 +
 drivers/usb/dwc3/dwc3-uniphier.c              |  1 +
 drivers/usb/dwc3/ep0.c                        |  1 +
 drivers/usb/dwc3/gadget.c                     |  1 +
 drivers/usb/dwc3/ti_usb_phy.c                 |  1 +
 drivers/usb/gadget/dwc2_udc_otg.c             |  1 +
 drivers/usb/gadget/storage_common.c           |  1 +
 drivers/usb/gadget/udc/udc-core.c             |  1 +
 drivers/usb/host/dwc2.c                       |  1 +
 drivers/usb/host/ehci-atmel.c                 |  1 +
 drivers/usb/host/ehci-generic.c               |  1 +
 drivers/usb/host/ehci-hcd.c                   |  1 +
 drivers/usb/host/ohci-da8xx.c                 |  2 +
 drivers/usb/host/ohci-generic.c               |  1 +
 drivers/usb/host/r8a66597-hcd.c               |  1 +
 drivers/usb/host/xhci-rcar.c                  |  2 +
 drivers/usb/musb-new/am35x.c                  |  1 +
 drivers/usb/musb-new/da8xx.c                  |  1 +
 drivers/usb/musb-new/musb_core.c              |  1 +
 drivers/usb/musb-new/musb_dsps.c              |  1 +
 drivers/usb/musb-new/musb_gadget.c            |  1 +
 drivers/usb/musb-new/musb_gadget_ep0.c        |  1 +
 drivers/usb/musb-new/musb_host.c              |  1 +
 drivers/usb/musb-new/musb_uboot.c             |  1 +
 drivers/usb/musb-new/omap2430.c               |  1 +
 drivers/usb/musb-new/pic32.c                  |  1 +
 drivers/usb/musb-new/sunxi.c                  |  2 +
 drivers/usb/musb-new/ti-musb.c                |  1 +
 drivers/usb/phy/omap_usb_phy.c                |  1 +
 drivers/video/atmel_hlcdfb.c                  |  1 +
 drivers/video/console_truetype.c              |  1 +
 drivers/video/da8xx-fb.c                      |  1 +
 drivers/video/dw_mipi_dsi.c                   |  1 +
 drivers/video/hitachi_tx18d42vm_lcd.c         |  1 +
 drivers/video/mali_dp.c                       |  2 +
 drivers/video/mvebu_lcd.c                     |  1 +
 drivers/video/mxsfb.c                         |  1 +
 drivers/video/orisetech_otm8009a.c            |  1 +
 drivers/video/pwm_backlight.c                 |  1 +
 drivers/video/raydium-rm68200.c               |  1 +
 drivers/video/rockchip/rk3288_hdmi.c          |  1 +
 drivers/video/rockchip/rk_edp.c               |  1 +
 drivers/video/sandbox_osd.c                   |  1 +
 drivers/video/scf0403_lcd.c                   |  1 +
 drivers/video/ssd2828.c                       |  1 +
 drivers/video/stm32/stm32_dsi.c               |  1 +
 drivers/video/stm32/stm32_ltdc.c              |  1 +
 drivers/video/video-uclass.c                  |  1 +
 drivers/virtio/virtio-uclass.c                |  1 +
 drivers/virtio/virtio_ring.c                  |  1 +
 drivers/w1-eeprom/ds2502.c                    |  1 +
 drivers/w1/mxc_w1.c                           |  1 +
 drivers/watchdog/armada-37xx-wdt.c            |  1 +
 drivers/watchdog/cdns_wdt.c                   |  1 +
 fs/ext4/ext4_write.c                          |  1 +
 fs/ext4/ext4fs.c                              |  1 +
 fs/fat/fat_write.c                            |  1 +
 fs/sandbox/sandboxfs.c                        |  1 +
 fs/ubifs/lprops.c                             |  1 +
 fs/ubifs/ubifs.c                              |  1 +
 fs/yaffs2/yaffs_nandif.c                      |  1 +
 fs/yaffs2/yaffs_uboot_glue.c                  |  1 +
 include/dm/device.h                           | 71 ---------------
 include/dm/device_compat.h                    | 86 +++++++++++++++++++
 include/linux/clk-provider.h                  |  1 +
 lib/bch.c                                     |  1 +
 lib/binman.c                                  |  1 +
 lib/bzip2/bzlib.c                             |  1 +
 lib/crypto/rsa_helper.c                       |  1 +
 lib/efi/efi.c                                 |  1 +
 lib/efi/efi_app.c                             |  1 +
 lib/efi/efi_stub.c                            |  1 +
 lib/efi_driver/efi_block_device.c             |  1 +
 lib/efi_driver/efi_uclass.c                   |  1 +
 lib/efi_loader/efi_console.c                  |  1 +
 lib/efi_loader/efi_runtime.c                  |  1 +
 lib/fdtdec.c                                  |  1 +
 lib/libavb/avb_cmdline.c                      |  1 +
 lib/libavb/avb_descriptor.c                   |  1 +
 lib/libavb/avb_rsa.c                          |  1 +
 lib/libavb/avb_slot_verify.c                  |  1 +
 lib/libavb/avb_sysdeps_posix.c                |  1 +
 lib/libavb/avb_util.c                         |  1 +
 lib/linux_compat.c                            |  1 +
 lib/lmb.c                                     |  1 +
 lib/rsa/rsa-sign.c                            |  1 +
 lib/rsa/rsa-verify.c                          |  1 +
 lib/zstd/decompress.c                         |  1 +
 lib/zstd/zstd_common.c                        |  1 +
 net/mdio-uclass.c                             |  3 +
 post/post.c                                   |  1 +
 test/dm/clk.c                                 |  1 +
 test/dm/dma.c                                 |  1 +
 test/dm/gpio.c                                |  1 +
 test/dm/mailbox.c                             |  1 +
 test/dm/power-domain.c                        |  1 +
 test/dm/reset.c                               |  1 +
 test/dm/spmi.c                                |  1 +
 test/dm/tee.c                                 |  1 +
 test/dm/video.c                               |  1 +
 test/lib/lmb.c                                |  1 +
 test/unicode_ut.c                             |  1 +
 460 files changed, 593 insertions(+), 77 deletions(-)
 create mode 100644 include/dm/device_compat.h

Applied to u-boot-dm, thanks!

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

* [PATCH v2 29/32] dm: core: Require users of devres to include the header
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (34 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth sjg at google.com
                   ` (3 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

At present devres.h is included in all files that include dm.h but few
make use of it. Also this pulls in linux/compat which adds several more
headers. Drop the automatic inclusion and require files to include devres
themselves. This provides a good indication of which files use devres.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 arch/arm/mach-aspeed/ast2500/clk_ast2500.c      | 1 +
 arch/arm/mach-imx/cmd_nandbcb.c                 | 1 +
 arch/arm/mach-meson/board-info.c                | 1 +
 arch/arm/mach-meson/sm.c                        | 1 +
 arch/arm/mach-rockchip/px30/clk_px30.c          | 1 +
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c      | 1 +
 arch/arm/mach-rockchip/rk3128/clk_rk3128.c      | 1 +
 arch/arm/mach-rockchip/rk3188/clk_rk3188.c      | 1 +
 arch/arm/mach-rockchip/rk3188/rk3188.c          | 1 +
 arch/arm/mach-rockchip/rk322x/clk_rk322x.c      | 1 +
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c      | 1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c          | 1 +
 arch/arm/mach-rockchip/rk3308/clk_rk3308.c      | 1 +
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c      | 1 +
 arch/arm/mach-rockchip/rk3368/clk_rk3368.c      | 1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c      | 1 +
 arch/arm/mach-rockchip/rv1108/clk_rv1108.c      | 1 +
 arch/arm/mach-stm32mp/pwr_regulator.c           | 1 +
 arch/riscv/lib/andes_plic.c                     | 1 +
 arch/riscv/lib/andes_plmt.c                     | 1 +
 arch/riscv/lib/sifive_clint.c                   | 1 +
 board/google/veyron/veyron.c                    | 1 +
 board/st/stm32mp1/stm32mp1.c                    | 1 +
 cmd/gpio.c                                      | 1 +
 cmd/gpt.c                                       | 1 +
 cmd/mtd.c                                       | 2 ++
 cmd/ubi.c                                       | 1 +
 drivers/adc/rockchip-saradc.c                   | 1 +
 drivers/block/blk-uclass.c                      | 1 +
 drivers/clk/altera/clk-arria10.c                | 1 +
 drivers/clk/aspeed/clk_ast2500.c                | 1 +
 drivers/clk/at91/clk-generated.c                | 1 +
 drivers/clk/at91/clk-usb.c                      | 1 +
 drivers/clk/clk-composite.c                     | 2 ++
 drivers/clk/clk-divider.c                       | 2 ++
 drivers/clk/clk-fixed-factor.c                  | 2 ++
 drivers/clk/clk-gate.c                          | 2 ++
 drivers/clk/clk-mux.c                           | 2 ++
 drivers/clk/clk-ti-sci.c                        | 1 +
 drivers/clk/clk-uclass.c                        | 4 +++-
 drivers/clk/clk_fixed_factor.c                  | 1 +
 drivers/clk/clk_sandbox_ccf.c                   | 2 ++
 drivers/clk/clk_sandbox_test.c                  | 1 +
 drivers/clk/clk_versal.c                        | 1 +
 drivers/clk/clk_zynqmp.c                        | 1 +
 drivers/clk/imx/clk-composite-8m.c              | 2 ++
 drivers/clk/imx/clk-gate2.c                     | 2 ++
 drivers/clk/imx/clk-pfd.c                       | 2 ++
 drivers/clk/imx/clk-pll14xx.c                   | 2 ++
 drivers/clk/imx/clk-pllv3.c                     | 2 ++
 drivers/clk/meson/axg.c                         | 1 +
 drivers/clk/meson/g12a.c                        | 1 +
 drivers/clk/meson/gxbb.c                        | 1 +
 drivers/clk/rockchip/clk_rk3188.c               | 1 +
 drivers/clk/rockchip/clk_rk3288.c               | 1 +
 drivers/clk/sifive/fu540-prci.c                 | 1 +
 drivers/core/devres.c                           | 1 +
 drivers/dfu/dfu_mtd.c                           | 1 +
 drivers/dma/ti/k3-udma.c                        | 3 ++-
 drivers/firmware/ti_sci.c                       | 1 +
 drivers/gpio/dwapb_gpio.c                       | 1 +
 drivers/gpio/mscc_sgpio.c                       | 1 +
 drivers/i2c/ast_i2c.c                           | 1 +
 drivers/i2c/designware_i2c.c                    | 1 +
 drivers/i2c/meson_i2c.c                         | 1 +
 drivers/i2c/muxes/i2c-mux-gpio.c                | 1 +
 drivers/i2c/tegra_i2c.c                         | 1 +
 drivers/misc/microchip_flexcom.c                | 1 +
 drivers/misc/tegra186_bpmp.c                    | 1 +
 drivers/mmc/am654_sdhci.c                       | 1 +
 drivers/mmc/aspeed_sdhci.c                      | 1 +
 drivers/mmc/fsl_esdhc_imx.c                     | 1 +
 drivers/mmc/omap_hsmmc.c                        | 2 ++
 drivers/mmc/rockchip_sdhci.c                    | 1 +
 drivers/mmc/tegra_mmc.c                         | 1 +
 drivers/mmc/zynq_sdhci.c                        | 1 +
 drivers/mtd/mtd_uboot.c                         | 1 +
 drivers/mtd/mtdconcat.c                         | 1 +
 drivers/mtd/mtdcore.c                           | 1 +
 drivers/mtd/mtdpart.c                           | 1 +
 drivers/mtd/nand/bbt.c                          | 1 +
 drivers/mtd/nand/raw/atmel_nand.c               | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c   | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c    | 1 +
 drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c    | 1 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c        | 2 ++
 drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c | 1 +
 drivers/mtd/nand/raw/denali.c                   | 2 ++
 drivers/mtd/nand/raw/fsl_elbc_nand.c            | 1 +
 drivers/mtd/nand/raw/fsl_ifc_nand.c             | 1 +
 drivers/mtd/nand/raw/mxs_nand_spl.c             | 1 +
 drivers/mtd/nand/raw/nand_base.c                | 1 +
 drivers/mtd/nand/raw/nand_bbt.c                 | 1 +
 drivers/mtd/nand/raw/nand_bch.c                 | 1 +
 drivers/mtd/nand/raw/nand_timings.c             | 1 +
 drivers/mtd/nand/raw/nand_util.c                | 1 +
 drivers/mtd/nand/raw/pxa3xx_nand.c              | 2 ++
 drivers/mtd/nand/raw/stm32_fmc2_nand.c          | 1 +
 drivers/mtd/nand/raw/sunxi_nand.c               | 2 ++
 drivers/mtd/nand/spi/core.c                     | 1 +
 drivers/mtd/onenand/onenand_base.c              | 1 +
 drivers/mtd/spi/spi-nor-core.c                  | 1 +
 drivers/mtd/ubi/attach.c                        | 1 +
 drivers/mtd/ubi/build.c                         | 1 +
 drivers/mtd/ubi/debug.c                         | 1 +
 drivers/mtd/ubi/eba.c                           | 1 +
 drivers/mtd/ubi/fastmap.c                       | 2 ++
 drivers/mtd/ubi/io.c                            | 1 +
 drivers/mtd/ubi/kapi.c                          | 1 +
 drivers/mtd/ubi/vmt.c                           | 1 +
 drivers/mtd/ubi/vtbl.c                          | 1 +
 drivers/mtd/ubi/wl.c                            | 1 +
 drivers/net/designware.c                        | 1 +
 drivers/net/dwmac_socfpga.c                     | 1 +
 drivers/net/mvneta.c                            | 1 +
 drivers/net/mvpp2.c                             | 2 ++
 drivers/net/phy/dp83867.c                       | 1 +
 drivers/net/sni_ave.c                           | 1 +
 drivers/net/zynq_gem.c                          | 1 +
 drivers/pci/pcie_dw_ti.c                        | 1 +
 drivers/pci/pcie_mediatek.c                     | 1 +
 drivers/phy/allwinner/phy-sun4i-usb.c           | 1 +
 drivers/phy/marvell/comphy_core.c               | 1 +
 drivers/phy/omap-usb2-phy.c                     | 1 +
 drivers/phy/phy-mtk-tphy.c                      | 1 +
 drivers/phy/phy-ti-am654.c                      | 1 +
 drivers/phy/ti-pipe3-phy.c                      | 1 +
 drivers/pinctrl/intel/pinctrl.c                 | 1 +
 drivers/pinctrl/mscc/mscc-common.c              | 1 +
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c     | 1 +
 drivers/pinctrl/nxp/pinctrl-imx.c               | 1 +
 drivers/pinctrl/nxp/pinctrl-mxs.c               | 1 +
 drivers/pinctrl/pinctrl_stm32.c                 | 1 +
 drivers/pinctrl/renesas/pfc.c                   | 1 +
 drivers/power/domain/meson-ee-pwrc.c            | 1 +
 drivers/power/domain/meson-gx-pwrc-vpu.c        | 1 +
 drivers/power/domain/mtk-power-domain.c         | 1 +
 drivers/power/domain/ti-sci-power-domain.c      | 1 +
 drivers/power/regulator/pbias_regulator.c       | 1 +
 drivers/ram/rockchip/dmc-rk3368.c               | 1 +
 drivers/remoteproc/rproc-elf-loader.c           | 1 +
 drivers/remoteproc/stm32_copro.c                | 1 +
 drivers/remoteproc/ti_k3_arm64_rproc.c          | 1 +
 drivers/remoteproc/ti_k3_dsp_rproc.c            | 1 +
 drivers/remoteproc/ti_k3_r5f_rproc.c            | 1 +
 drivers/reset/reset-mediatek.c                  | 1 +
 drivers/reset/reset-ti-sci.c                    | 1 +
 drivers/reset/reset-uclass.c                    | 1 +
 drivers/serial/ns16550.c                        | 1 +
 drivers/serial/serial_mtk.c                     | 3 ++-
 drivers/serial/serial_omap.c                    | 1 +
 drivers/serial/serial_sifive.c                  | 1 +
 drivers/serial/serial_zynq.c                    | 1 +
 drivers/smem/msm_smem.c                         | 2 ++
 drivers/soc/ti/k3-navss-ringacc.c               | 2 ++
 drivers/spi/atmel-quadspi.c                     | 1 +
 drivers/spi/cadence_qspi.c                      | 1 +
 drivers/spi/spi-mem.c                           | 1 +
 drivers/spi/ti_qspi.c                           | 1 +
 drivers/spi/zynqmp_gqspi.c                      | 1 +
 drivers/sysreset/sysreset-ti-sci.c              | 1 +
 drivers/sysreset/sysreset_syscon.c              | 1 +
 drivers/tee/optee/core.c                        | 1 +
 drivers/timer/ast_timer.c                       | 1 +
 drivers/timer/cadence-ttc.c                     | 1 +
 drivers/timer/timer-uclass.c                    | 1 +
 drivers/ufs/cdns-platform.c                     | 1 +
 drivers/ufs/ti-j721e-ufs.c                      | 1 +
 drivers/ufs/ufs.c                               | 1 +
 drivers/usb/cdns3/core.c                        | 1 +
 drivers/usb/cdns3/gadget.c                      | 2 ++
 drivers/usb/cdns3/host.c                        | 1 +
 drivers/usb/dwc3/core.c                         | 2 ++
 drivers/usb/dwc3/dwc3-omap.c                    | 1 +
 drivers/usb/dwc3/gadget.c                       | 1 +
 drivers/usb/dwc3/ti_usb_phy.c                   | 1 +
 drivers/usb/gadget/at91_udc.c                   | 2 ++
 drivers/usb/gadget/composite.c                  | 1 +
 drivers/usb/gadget/dwc2_udc_otg.c               | 1 +
 drivers/usb/gadget/f_mass_storage.c             | 1 +
 drivers/usb/gadget/pxa25x_udc.c                 | 1 +
 drivers/usb/gadget/udc/udc-core.c               | 1 +
 drivers/usb/host/ehci-generic.c                 | 1 +
 drivers/usb/host/ohci-da8xx.c                   | 1 +
 drivers/usb/host/ohci-generic.c                 | 1 +
 drivers/usb/musb-new/am35x.c                    | 1 +
 drivers/usb/musb-new/musb_core.c                | 1 +
 drivers/usb/musb-new/musb_dsps.c                | 1 +
 drivers/usb/musb-new/musb_gadget.c              | 1 +
 drivers/usb/musb-new/musb_host.c                | 1 +
 drivers/usb/musb-new/musb_uboot.c               | 1 +
 drivers/usb/musb-new/omap2430.c                 | 1 +
 drivers/video/exynos/exynos_mipi_dsi.c          | 1 +
 drivers/video/mipi_dsi.c                        | 1 +
 drivers/video/rockchip/rk3288_mipi.c            | 1 +
 drivers/video/rockchip/rk3399_mipi.c            | 1 +
 drivers/video/rockchip/rk_vop.c                 | 1 +
 drivers/video/tegra124/sor.c                    | 1 +
 drivers/virtio/virtio_mmio.c                    | 1 +
 drivers/virtio/virtio_pci_legacy.c              | 1 +
 drivers/virtio/virtio_pci_modern.c              | 1 +
 drivers/virtio/virtio_sandbox.c                 | 1 +
 drivers/watchdog/ast_wdt.c                      | 1 +
 drivers/watchdog/cdns_wdt.c                     | 1 +
 drivers/watchdog/sp805_wdt.c                    | 1 +
 drivers/watchdog/xilinx_tb_wdt.c                | 1 +
 fs/ubifs/debug.c                                | 1 +
 fs/ubifs/gc.c                                   | 1 +
 fs/ubifs/io.c                                   | 1 +
 fs/ubifs/log.c                                  | 1 +
 fs/ubifs/lpt.c                                  | 1 +
 fs/ubifs/lpt_commit.c                           | 1 +
 fs/ubifs/master.c                               | 1 +
 fs/ubifs/orphan.c                               | 1 +
 fs/ubifs/recovery.c                             | 1 +
 fs/ubifs/replay.c                               | 1 +
 fs/ubifs/sb.c                                   | 1 +
 fs/ubifs/scan.c                                 | 1 +
 fs/ubifs/super.c                                | 1 +
 fs/ubifs/tnc.c                                  | 1 +
 fs/ubifs/tnc_misc.c                             | 1 +
 fs/ubifs/ubifs.c                                | 1 +
 fs/yaffs2/yaffs_allocator.c                     | 1 +
 fs/yaffs2/yaffs_checkptrw.c                     | 1 +
 fs/yaffs2/yaffs_guts.c                          | 1 +
 fs/yaffs2/yaffs_summary.c                       | 1 +
 fs/yaffs2/yaffs_yaffs1.c                        | 1 +
 fs/yaffs2/yaffs_yaffs2.c                        | 1 +
 fs/yaffs2/yaffsfs.c                             | 1 +
 include/dm/device.h                             | 2 --
 include/dm/devres.h                             | 4 ++++
 lib/bch.c                                       | 1 +
 lib/crypto/asymmetric_type.c                    | 2 ++
 lib/crypto/pkcs7_parser.c                       | 1 +
 lib/crypto/public_key.c                         | 2 ++
 lib/crypto/x509_cert_parser.c                   | 1 +
 lib/crypto/x509_public_key.c                    | 2 ++
 lib/list_sort.c                                 | 1 +
 test/dm/devres.c                                | 1 +
 test/dm/regmap.c                                | 1 +
 test/dm/syscon.c                                | 1 +
 test/dm/test-fdt.c                              | 1 +
 242 files changed, 275 insertions(+), 5 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 28/32] sandbox: Support changing the LCD colour depth
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (35 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size sjg at google.com
                   ` (2 subsequent siblings)
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

Add a new device-tree property to control the colour depth. At present we
support 16bpp and 32bpp.

While we are here, update the code to use livetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2:
- Drop the patch with the Roboto font

 arch/sandbox/dts/sandbox.dtsi                 | 1 +
 doc/device-tree-bindings/video/sandbox-fb.txt | 6 +++++-
 drivers/video/sandbox_sdl.c                   | 8 +++-----
 3 files changed, 9 insertions(+), 6 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (36 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox sjg at google.com
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

On high-DPI displays U-Boot's LCD window can look very small. Add a
-K flag to expand it to make things easier to read, while still using
the existing resolution internally.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 arch/sandbox/cpu/sdl.c           | 17 +++++++++++++++--
 arch/sandbox/cpu/start.c         | 10 ++++++++++
 arch/sandbox/include/asm/sdl.h   |  9 ++++++---
 arch/sandbox/include/asm/state.h |  1 +
 drivers/video/sandbox_sdl.c      |  5 ++++-
 5 files changed, 36 insertions(+), 6 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 26/32] sandbox: sdl: Move to use SDL2
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (37 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  2020-02-06  2:31 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox sjg at google.com
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

Sandbox currently uses SDL1.2. SDL2 has been around for quite a while and
is widely supported. It has a number of useful features. It seems
appropriate to move sandbox over.

Update the code to use SDL2 instead of SDL1.2.

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

Changes in v2: None

 .travis.yml            |   2 +-
 arch/sandbox/config.mk |   2 +-
 arch/sandbox/cpu/sdl.c | 279 +++++++++++++++++++++++------------------
 doc/arch/sandbox.rst   |   2 +-
 4 files changed, 158 insertions(+), 127 deletions(-)

Applied to u-boot-dm, thanks!

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

* [PATCH v2 25/32] gitlab: Disable SDL when building sandbox
  2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
                   ` (38 preceding siblings ...)
  2020-02-06  2:31 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 sjg at google.com
@ 2020-02-06  2:31 ` sjg at google.com
  39 siblings, 0 replies; 41+ messages in thread
From: sjg at google.com @ 2020-02-06  2:31 UTC (permalink / raw)
  To: u-boot

I am not sure how to add libsdl2-dev to the gitlab image, so disable
building sandbox with SDL for now.

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

Changes in v2: None

 .gitlab-ci.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

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

end of thread, other threads:[~2020-02-06  2:31 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 14:35 [PATCH v2 00/32] sandbox: Move to SDL2 Simon Glass
2020-02-03 14:35 ` [PATCH v2 01/32] sandbox: Sort the help options Simon Glass
2020-02-03 14:35 ` [PATCH v2 02/32] video: Support truetype fonts on a 32-bit display Simon Glass
2020-02-03 14:35 ` [PATCH v2 03/32] video: sandbox: Enable all colour depths Simon Glass
2020-02-03 14:35 ` [PATCH v2 04/32] mailbox: Rename free() to rfree() Simon Glass
2020-02-03 14:35 ` [PATCH v2 05/32] power-domain: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 06/32] reset: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 07/32] gpio: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 08/32] clk: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 09/32] dma: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 10/32] mtd: " Simon Glass
2020-02-03 14:35 ` [PATCH v2 11/32] sandbox: Rename 'free' variable Simon Glass
2020-02-03 14:35 ` [PATCH v2 12/32] sandbox: Use a prefix for all allocation functions Simon Glass
2020-02-03 14:35 ` [PATCH v2 13/32] exports: Add the malloc.h header Simon Glass
2020-02-03 14:36 ` [PATCH v2 14/32] string: Allow arch override of strndup() also Simon Glass
2020-02-03 14:36 ` [PATCH v2 15/32] sandbox: Rename strdup() functions Simon Glass
2020-02-03 14:36 ` [PATCH v2 16/32] sandbox: Drop use of special os_malloc() where possible Simon Glass
2020-02-03 14:36 ` [PATCH v2 17/32] sandbox: Drop os_realloc() Simon Glass
2020-02-03 14:36 ` [PATCH v2 18/32] sandbox: Ensure that long-options array is terminated Simon Glass
2020-02-03 14:36 ` [PATCH v2 19/32] sandbox: Add a new header for the system malloc() Simon Glass
2020-02-03 14:36 ` [PATCH v2 20/32] sound: Add a new stop_play() method Simon Glass
2020-02-03 14:36 ` [PATCH v2 21/32] sandbox: sound: Handle errors better in sound_beep() Simon Glass
2020-02-03 14:36 ` [PATCH v2 22/32] sandbox: Add comments to the sdl struct Simon Glass
2020-02-03 14:36 ` [PATCH v2 23/32] sandbox: sdl: Improve error handling Simon Glass
2020-02-03 14:36 ` [PATCH v2 24/32] sandbox: sdl: Support waiting for audio to complete Simon Glass
2020-02-03 14:36 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox Simon Glass
2020-02-03 14:36 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 Simon Glass
2020-02-03 14:36 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size Simon Glass
2020-02-03 14:36 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth Simon Glass
2020-02-03 14:36 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header Simon Glass
2020-02-03 14:36 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features Simon Glass
2020-02-03 14:36 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h Simon Glass
2020-02-03 14:36 ` [PATCH v2 32/32] sandbox: Complete migration away from os_malloc() Simon Glass
2020-02-06  2:31 ` sjg at google.com
2020-02-06  2:31 ` [PATCH v2 31/32] dm: core: Drop the inclusion of linux/compat.h in dm.h sjg at google.com
2020-02-06  2:31 ` [PATCH v2 30/32] dm: core: Create a new header file for 'compat' features sjg at google.com
2020-02-06  2:31 ` [PATCH v2 29/32] dm: core: Require users of devres to include the header sjg at google.com
2020-02-06  2:31 ` [PATCH v2 28/32] sandbox: Support changing the LCD colour depth sjg at google.com
2020-02-06  2:31 ` [PATCH v2 27/32] sandbox: sdl: Add an option to double the screen size sjg at google.com
2020-02-06  2:31 ` [PATCH v2 26/32] sandbox: sdl: Move to use SDL2 sjg at google.com
2020-02-06  2:31 ` [PATCH v2 25/32] gitlab: Disable SDL when building sandbox sjg at google.com

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.