[PATCH 30/33] dm: core: Create a new header file for 'compat' features

Simon Glass sjg at chromium.org
Sun Jan 12 20:06:21 CET 2020


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 at chromium.org>
---

 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 05ba48ab27..7b1f8c3cc8 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 0762144ecf..4906fa1598 100644
--- a/arch/arm/mach-tegra/cboot.c
+++ b/arch/arm/mach-tegra/cboot.c
@@ -7,6 +7,7 @@
 #include <env.h>
 #include <fdt_support.h>
 #include <fdtdec.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 8658abb457..666fa7bdde 100644
--- a/arch/arm/mach-zynq/timer.c
+++ b/arch/arm/mach-zynq/timer.c
@@ -31,6 +31,7 @@
 #include <common.h>
 #include <div64.h>
 #include <dm.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 7afc2c5940..8c28bbcc00 100644
--- a/arch/mips/mach-mtmips/cpu.c
+++ b/arch/mips/mach-mtmips/cpu.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.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 at 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 d57a50de11..0e17478175 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -15,6 +15,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 at 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 c755821b74..9e97fdd97e 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <env.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 22b2037a33..5c26d1d04f 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 48388488d9..3b69d5f60f 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 75d5dd944f..d44983b028 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 4612fbcdc7..d65ee963f0 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 a4f6b15e3d..4544f4c7f7 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 14dfa85942..ebb6283471 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 9020a9f202..e0890d0075 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 435f42bc0a..7488fe7e7c 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -14,6 +14,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 985a108b1c..1f321e3f58 100644
--- a/drivers/ddr/altera/sdram_soc64.c
+++ b/drivers/ddr/altera/sdram_soc64.c
@@ -18,6 +18,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 5aa7838ff5..2d020e0f8f 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 4859b3f32c..e55b9a6ecf 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 at 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 03d6ca09f7..5dedb43acf 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -8,10 +8,12 @@
 #include <common.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 ced606bf36..3fbf3d5576 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -5,6 +5,7 @@
  *   Author: Masahiro Yamada <yamada.masahiro at 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 e427415e7e..00a610598a 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -5,6 +5,7 @@
  *   Author: Masahiro Yamada <yamada.masahiro at 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 2de99d019e..7af5364d93 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 2ebae349ed..112f374a95 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 2b18735fea..9aa6dc8c02 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 b2fdeef13a..1079099dbc 100644
--- a/drivers/misc/imx8/scu_api.c
+++ b/drivers/misc/imx8/scu_api.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.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 37952d6ace..bbfe177f63 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 1e7d606cd8..15b3183afa 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 ab1ef8d77c..0acd2c4f02 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 eaa584a4df..3f458f583f 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -15,6 +15,7 @@
 #include <stdbool.h>
 #include <watchdog.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 669410d97f..36868c2d5f 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -10,6 +10,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 0bd7eb7f1f..07f5e24a63 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -7,7 +7,9 @@
 
 #include <cpu_func.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 0ce81324b9..80c741c3fd 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 f3446e71b9..6151ada26a 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 277ec68bce..e9a889103f 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 02c1ee70d9..9ac7cea51d 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 d120278ab1..9f300cc484 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 3cf6570fc2..38e743ebb0 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 f4ad4c3cc3..22f2b206f3 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 31345764a7..2455af8eb7 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 5084bff766..f73c1e463d 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 3b123f503c..1180b2b414 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 9feb0aa766..493404109b 100644
--- a/drivers/ram/k3-j721e/k3-j721e-ddrss.c
+++ b/drivers/ram/k3-j721e/k3-j721e-ddrss.c
@@ -12,6 +12,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 b2007fd31d..c7931ee44f 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 4b0a964d1b..41e2d18b9f 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 2eba1c1d18..ec8741b50c 100644
--- a/drivers/soc/ti/k3-navss-ringacc.c
+++ b/drivers/soc/ti/k3-navss-ringacc.c
@@ -11,6 +11,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 at 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 2425f5ad8e..3e50de7e0b 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -11,6 +11,7 @@
 #include <malloc.h>
 #include <reset.h>
 #include <spi.h>
+#include <dm/device_compat.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include "cadence_qspi.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 c907729b54..312fac76dd 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 0b6d9cf727..d530c9790b 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 at gmail.com>
+ * Marek Vasut <marex at 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 02ff1a311a..c5a1a77ee5 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -9,6 +9,7 @@
 #ifndef __LINUX_CLK_PROVIDER_H
 #define __LINUX_CLK_PROVIDER_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 at 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 0047998ee0..f40549be4c 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -12,6 +12,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 b14746e6b1..6ce257f448 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 61af3472e6..0e07145d92 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <boot_fit.h>
 #include <dm.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 4ccf41e428..1ad5135fae 100644
--- a/lib/libavb/avb_sysdeps_posix.c
+++ b/lib/libavb/avb_sysdeps_posix.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2016 The Android Open Source Project
  */
 
+#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.rc1.283.g88dfdc4193-goog



More information about the U-Boot mailing list