diff mbox series

[U-Boot,v2,01/24] Makefile: move MTD-related lines in coherent Makefiles

Message ID 20181128230800.13292-2-miquel.raynal@bootlin.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series MTD defconfigs/Kconfigs/Makefiles heavy cleanup | expand

Commit Message

Miquel Raynal Nov. 28, 2018, 11:07 p.m. UTC
Move MTD-related lines out of the root Makefile. Put them in their
respective directories.

Enclose some of these new lines to skip them when building the SPL
(the SPL directly points to what is needed).

CONFIG_CMD_NAND is the symbol indicating support for raw NAND
devices. This logic is broken and will be fixed afterwards. To let the
'mtd' command also use the raw NAND core, we add it in the
condition. This will be cleaned later.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 Makefile                  | 5 -----
 drivers/Makefile          | 3 ++-
 drivers/mtd/Makefile      | 6 ++++++
 drivers/mtd/nand/Makefile | 3 +++
 4 files changed, 11 insertions(+), 6 deletions(-)

Comments

Boris Brezillon Nov. 28, 2018, 11:46 p.m. UTC | #1
On Thu, 29 Nov 2018 00:07:37 +0100
Miquel Raynal <miquel.raynal@bootlin.com> wrote:


> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -6,7 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
>  obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
>  obj-$(CONFIG_$(SPL_TPL_)LED) += led/
>  obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
> -obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
> +obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/

Can't we have
					 += mtd/

instead?
Miquel Raynal Nov. 29, 2018, 7:57 a.m. UTC | #2
Hi Boris,

Boris Brezillon <boris.brezillon@bootlin.com> wrote on Thu, 29 Nov 2018
00:46:23 +0100:

> On Thu, 29 Nov 2018 00:07:37 +0100
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> 
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -6,7 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
> >  obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
> >  obj-$(CONFIG_$(SPL_TPL_)LED) += led/
> >  obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
> > -obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
> > +obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/  
> 
> Can't we have
> 					 += mtd/
> 
> instead?

As you can see, an SPL build just compiles a few files and does not
parse the whole "Makefile tree". To avoid compiling the world in the
SPL, when I later change the Makefiles to have this "tree" logic I also
enclosed some lines into a "#ifndef CONFIG_SPL_BUILD" conditional to
avoid enlarging the SPL without reason. There is probably a way to
simplify this but for now I don't want to do it :)


Thanks,
Miquèl
Miquel Raynal Nov. 29, 2018, 9:16 a.m. UTC | #3
Hi Boris,

Boris Brezillon <boris.brezillon@bootlin.com> wrote on Thu, 29 Nov 2018
00:46:23 +0100:

> On Thu, 29 Nov 2018 00:07:37 +0100
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> 
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -6,7 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
> >  obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
> >  obj-$(CONFIG_$(SPL_TPL_)LED) += led/
> >  obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
> > -obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
> > +obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/  
> 
> Can't we have
> 					 += mtd/
> 
> instead?

You are right the SPL Makefile lines needs to be improved as well. I
propose the following diff for that.


Thanks,
Miquèl

---

--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -6,12 +6,11 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
-obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/
+obj-y += mtd/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
 obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
 obj-$(CONFIG_$(SPL_TPL_)SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_$(SPL_TPL_)SPI_SUPPORT) += spi/
 obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/
 obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
@@ -33,9 +32,6 @@ obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
 obj-$(CONFIG_SPL_POWER_DOMAIN) += power/domain/
 obj-$(CONFIG_SPL_DM_RESET) += reset/
-obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
-obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
-obj-$(CONFIG_SPL_UBI) += mtd/ubispl/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 7574084f36..5e2caa9e46 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -3,23 +3,29 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
-obj-$(CONFIG_MTD) += mtdcore.o mtdpart.o mtd_uboot.o
-obj-$(CONFIG_DM_MTD) += mtd-uclass.o
-obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o
-obj-$(CONFIG_ALTERA_QSPI) += altera_qspi.o
-obj-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o
-obj-$(CONFIG_FLASH_CFI_MTD) += cfi_mtd.o
-obj-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o
-obj-$(CONFIG_MW_EEPROM) += mw_eeprom.o
-obj-$(CONFIG_FLASH_PIC32) += pic32_flash.o
-obj-$(CONFIG_ST_SMI) += st_smi.o
-obj-$(CONFIG_STM32_FLASH) += stm32_flash.o
-obj-$(CONFIG_RENESAS_RPC_HF) += renesas_rpc_hf.o
+mtd-$(CONFIG_MTD) += mtdcore.o mtdpart.o mtd_uboot.o
+mtd-$(CONFIG_DM_MTD) += mtd-uclass.o
+mtd-$(CONFIG_MTD_CONCAT) += mtdconcat.o
+mtd-$(CONFIG_ALTERA_QSPI) += altera_qspi.o
+mtd-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o
+mtd-$(CONFIG_FLASH_CFI_MTD) += cfi_mtd.o
+mtd-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o
+mtd-$(CONFIG_MW_EEPROM) += mw_eeprom.o
+mtd-$(CONFIG_FLASH_PIC32) += pic32_flash.o
+mtd-$(CONFIG_ST_SMI) += st_smi.o
+mtd-$(CONFIG_STM32_FLASH) += stm32_flash.o
+mtd-$(CONFIG_RENESAS_RPC_HF) += renesas_rpc_hf.o
 
-# SPL will manually build the files it needs
 ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
+obj-y += mtd.o
 obj-y += nand/
 obj-y += onenand/
 obj-y += spi/
 obj-$(CONFIG_MTD_UBI) += ubi/
+else
+obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd.o
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += nand/
+obj-$(CONFIG_SPL_ONENAND_SUPPORT) += onenand/
+obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += spi/
+obj-$(CONFIG_SPL_UBI) += ubispl/
 endif
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index e5849dc02a..96e186600a 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 nandcore-objs := core.o bbt.o
 obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
 obj-$(CONFIG_MTD_RAW_NAND) += raw/
 obj-$(CONFIG_MTD_SPI_NAND) += spi/
+else
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += raw/
+endif
Boris Brezillon Nov. 29, 2018, 9:21 a.m. UTC | #4
On Thu, 29 Nov 2018 10:16:50 +0100
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi Boris,
> 
> Boris Brezillon <boris.brezillon@bootlin.com> wrote on Thu, 29 Nov 2018
> 00:46:23 +0100:
> 
> > On Thu, 29 Nov 2018 00:07:37 +0100
> > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> > 
> >   
> > > --- a/drivers/Makefile
> > > +++ b/drivers/Makefile
> > > @@ -6,7 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
> > >  obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
> > >  obj-$(CONFIG_$(SPL_TPL_)LED) += led/
> > >  obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
> > > -obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
> > > +obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/    
> > 
> > Can't we have
> > 					 += mtd/
> > 
> > instead?  
> 
> You are right the SPL Makefile lines needs to be improved as well. I
> propose the following diff for that.

This is much better.

Thanks for addressing that.

Boris
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 552687db53..435d0257dd 100644
--- a/Makefile
+++ b/Makefile
@@ -688,11 +688,6 @@  libs-y += drivers/
 libs-y += drivers/dma/
 libs-y += drivers/gpio/
 libs-y += drivers/i2c/
-libs-y += drivers/mtd/
-libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/raw/
-libs-y += drivers/mtd/onenand/
-libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
-libs-y += drivers/mtd/spi/
 libs-y += drivers/net/
 libs-y += drivers/net/phy/
 libs-y += drivers/pci/
diff --git a/drivers/Makefile b/drivers/Makefile
index 4453c62ad3..e7c93875bb 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -6,7 +6,7 @@  obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
-obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
 obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
@@ -99,6 +99,7 @@  obj-$(CONFIG_QE) += qe/
 obj-$(CONFIG_U_QE) += qe/
 obj-y += mailbox/
 obj-y += memory/
+obj-y += mtd/
 obj-y += pwm/
 obj-y += reset/
 obj-y += input/
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 22ceda93c0..aca3a0b811 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -19,4 +19,10 @@  obj-$(CONFIG_ST_SMI) += st_smi.o
 obj-$(CONFIG_STM32_FLASH) += stm32_flash.o
 obj-$(CONFIG_RENESAS_RPC_HF) += renesas_rpc_hf.o
 
+# SPL will manually build the files it needs
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-y += nand/
+obj-y += onenand/
+obj-y += spi/
+obj-$(CONFIG_CMD_UBI) += ubi/
+endif
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index a358bc680e..99ca69ef95 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -2,4 +2,7 @@ 
 
 nandcore-objs := core.o bbt.o
 obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
+ifneq (,$(findstring y,$(CONFIG_CMD_NAND)$(CONFIG_CMD_MTD)))
+obj-y += raw/
+endif
 obj-$(CONFIG_MTD_SPI_NAND) += spi/