All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
@ 2019-10-25 17:39 Miquel Raynal
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code Miquel Raynal
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Miquel Raynal @ 2019-10-25 17:39 UTC (permalink / raw)
  To: u-boot

As rightfully pointed by Jagan, I should have dropped the dependency
of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.

Instead of sending the 40 patches again, here are only the last three
patches with:
* patch 1 (24/26) being corrected as per Jagan's comment
* patch 2 (25/26) is untouched
* patch 3 (26/26) is almost untouched but I had to resolve a conflict
  due to patch 1.

Thanks,
Miquèl

Miquel Raynal (3):
  cmd: nand/sf: isolate legacy code
  cmd: make MTD commands depend on MTD
  mtd: Makefile: deep cleanup

 Makefile                  |  5 --
 cmd/Kconfig               | 10 ++--
 cmd/Makefile              |  3 ++
 cmd/legacy-mtd-utils.c    | 99 +++++++++++++++++++++++++++++++++++++++
 cmd/legacy-mtd-utils.h    | 14 ++++++
 cmd/nand.c                |  2 +
 cmd/sf.c                  |  2 +
 drivers/Makefile          |  7 +--
 drivers/mtd/Makefile      | 50 ++++++++++++++------
 drivers/mtd/mtd_uboot.c   | 94 -------------------------------------
 drivers/mtd/nand/Makefile |  5 ++
 include/linux/mtd/mtd.h   |  6 ---
 12 files changed, 169 insertions(+), 128 deletions(-)
 create mode 100644 cmd/legacy-mtd-utils.c
 create mode 100644 cmd/legacy-mtd-utils.h

-- 
2.20.1

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

* [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code
  2019-10-25 17:39 [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Miquel Raynal
@ 2019-10-25 17:39 ` Miquel Raynal
  2019-12-05  2:53   ` Tom Rini
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD Miquel Raynal
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Miquel Raynal @ 2019-10-25 17:39 UTC (permalink / raw)
  To: u-boot

The 'sf' command is not supposed to rely on the MTD stack, but both
'sf' and 'nand' commands use helpers located in mtd_uboot.c. Despite
their location, these functions do not depend at all on the MTD
stack.

This file (drivers/mtd/mtd_uboot.c) is only compiled if CONFIG_MTD is
selected, which is inconsistent with the current situation. Solve this
by moving these three functions (which are only used by the above two
commands) out of mtd_uboot.c and put them in a C file only compiled
with cmd/sf.c and cmd/nand.c.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 cmd/Makefile            |  3 ++
 cmd/legacy-mtd-utils.c  | 99 +++++++++++++++++++++++++++++++++++++++++
 cmd/legacy-mtd-utils.h  | 14 ++++++
 cmd/nand.c              |  2 +
 cmd/sf.c                |  2 +
 drivers/mtd/Makefile    |  2 +-
 drivers/mtd/mtd_uboot.c | 94 --------------------------------------
 include/linux/mtd/mtd.h |  6 ---
 8 files changed, 121 insertions(+), 101 deletions(-)
 create mode 100644 cmd/legacy-mtd-utils.c
 create mode 100644 cmd/legacy-mtd-utils.h

diff --git a/cmd/Makefile b/cmd/Makefile
index ac843b4b16..88b77c9f78 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -97,6 +97,9 @@ obj-$(CONFIG_CMD_MMC) += mmc.o
 obj-$(CONFIG_MP) += mp.o
 obj-$(CONFIG_CMD_MTD) += mtd.o
 obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
+ifneq ($(CONFIG_CMD_NAND)$(CONFIG_CMD_SF),)
+obj-y += legacy-mtd-utils.o
+endif
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
 obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o
diff --git a/cmd/legacy-mtd-utils.c b/cmd/legacy-mtd-utils.c
new file mode 100644
index 0000000000..1aa3bfc8ec
--- /dev/null
+++ b/cmd/legacy-mtd-utils.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <jffs2/jffs2.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/string.h>
+#include <mtd.h>
+
+int get_part(const char *partname, int *idx, loff_t *off, loff_t *size,
+	     loff_t *maxsize, int devtype)
+{
+#ifdef CONFIG_CMD_MTDPARTS
+	struct mtd_device *dev;
+	struct part_info *part;
+	u8 pnum;
+	int ret;
+
+	ret = mtdparts_init();
+	if (ret)
+		return ret;
+
+	ret = find_dev_and_part(partname, &dev, &pnum, &part);
+	if (ret)
+		return ret;
+
+	if (dev->id->type != devtype) {
+		printf("not same typ %d != %d\n", dev->id->type, devtype);
+		return -1;
+	}
+
+	*off = part->offset;
+	*size = part->size;
+	*maxsize = part->size;
+	*idx = dev->id->num;
+
+	return 0;
+#else
+	puts("mtdparts support missing.\n");
+	return -1;
+#endif
+}
+
+int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
+		loff_t *maxsize, int devtype, uint64_t chipsize)
+{
+	if (!str2off(arg, off))
+		return get_part(arg, idx, off, size, maxsize, devtype);
+
+	if (*off >= chipsize) {
+		puts("Offset exceeds device limit\n");
+		return -1;
+	}
+
+	*maxsize = chipsize - *off;
+	*size = *maxsize;
+	return 0;
+}
+
+int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
+		     loff_t *size, loff_t *maxsize, int devtype,
+		     uint64_t chipsize)
+{
+	int ret;
+
+	if (argc == 0) {
+		*off = 0;
+		*size = chipsize;
+		*maxsize = *size;
+		goto print;
+	}
+
+	ret = mtd_arg_off(argv[0], idx, off, size, maxsize, devtype,
+			  chipsize);
+	if (ret)
+		return ret;
+
+	if (argc == 1)
+		goto print;
+
+	if (!str2off(argv[1], size)) {
+		printf("'%s' is not a number\n", argv[1]);
+		return -1;
+	}
+
+	if (*size > *maxsize) {
+		puts("Size exceeds partition or device limit\n");
+		return -1;
+	}
+
+print:
+	printf("device %d ", *idx);
+	if (*size == chipsize)
+		puts("whole chip\n");
+	else
+		printf("offset 0x%llx, size 0x%llx\n",
+		       (unsigned long long)*off, (unsigned long long)*size);
+	return 0;
+}
diff --git a/cmd/legacy-mtd-utils.h b/cmd/legacy-mtd-utils.h
new file mode 100644
index 0000000000..b31342bcb7
--- /dev/null
+++ b/cmd/legacy-mtd-utils.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef __LEGACY_MTD_UTILS_H
+#define __LEGACY_MTD_UTILS_H
+
+int get_part(const char *partname, int *idx, loff_t *off, loff_t *size,
+	     loff_t *maxsize, int devtype);
+int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
+		loff_t *maxsize, int devtype, uint64_t chipsize);
+int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
+		     loff_t *size, loff_t *maxsize, int devtype,
+		     uint64_t chipsize);
+
+#endif /* LEGACY_MTD_UTILS_H */
diff --git a/cmd/nand.c b/cmd/nand.c
index 27efef20bc..f40936cf68 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -30,6 +30,8 @@
 #include <jffs2/jffs2.h>
 #include <nand.h>
 
+#include "legacy-mtd-utils.h"
+
 #if defined(CONFIG_CMD_MTDPARTS)
 
 /* partition handling routines */
diff --git a/cmd/sf.c b/cmd/sf.c
index 6ccf98ae51..e993b3e5ad 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -18,6 +18,8 @@
 #include <asm/io.h>
 #include <dm/device-internal.h>
 
+#include "legacy-mtd-utils.h"
+
 static struct spi_flash *flash;
 
 /*
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 3542042245..c9a96adace 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -3,7 +3,7 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-ifneq (,$(findstring y,$(CONFIG_MTD)$(CONFIG_CMD_NAND)$(CONFIG_CMD_ONENAND)$(CONFIG_CMD_SF)$(CONFIG_CMD_MTD)))
+ifneq (,$(findstring y,$(CONFIG_MTD)$(CONFIG_CMD_ONENAND)$(CONFIG_CMD_MTD)))
 obj-y += mtdcore.o mtd_uboot.o
 endif
 obj-$(CONFIG_DM_MTD) += mtd-uclass.o
diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index 7c6c9ac0bc..8aeccb016d 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -7,7 +7,6 @@
 #include <env.h>
 #include <dm/device.h>
 #include <dm/uclass-internal.h>
-#include <jffs2/jffs2.h> /* LEGACY */
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <mtd.h>
@@ -356,96 +355,3 @@ int mtd_probe_devices(void)
 	return 0;
 }
 #endif /* defined(CONFIG_MTD_PARTITIONS) */
-
-/* Legacy */
-
-static int get_part(const char *partname, int *idx, loff_t *off, loff_t *size,
-		loff_t *maxsize, int devtype)
-{
-#ifdef CONFIG_CMD_MTDPARTS
-	struct mtd_device *dev;
-	struct part_info *part;
-	u8 pnum;
-	int ret;
-
-	ret = mtdparts_init();
-	if (ret)
-		return ret;
-
-	ret = find_dev_and_part(partname, &dev, &pnum, &part);
-	if (ret)
-		return ret;
-
-	if (dev->id->type != devtype) {
-		printf("not same typ %d != %d\n", dev->id->type, devtype);
-		return -1;
-	}
-
-	*off = part->offset;
-	*size = part->size;
-	*maxsize = part->size;
-	*idx = dev->id->num;
-
-	return 0;
-#else
-	puts("mtdparts support missing.\n");
-	return -1;
-#endif
-}
-
-int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
-		loff_t *maxsize, int devtype, uint64_t chipsize)
-{
-	if (!str2off(arg, off))
-		return get_part(arg, idx, off, size, maxsize, devtype);
-
-	if (*off >= chipsize) {
-		puts("Offset exceeds device limit\n");
-		return -1;
-	}
-
-	*maxsize = chipsize - *off;
-	*size = *maxsize;
-	return 0;
-}
-
-int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
-		     loff_t *size, loff_t *maxsize, int devtype,
-		     uint64_t chipsize)
-{
-	int ret;
-
-	if (argc == 0) {
-		*off = 0;
-		*size = chipsize;
-		*maxsize = *size;
-		goto print;
-	}
-
-	ret = mtd_arg_off(argv[0], idx, off, size, maxsize, devtype,
-			  chipsize);
-	if (ret)
-		return ret;
-
-	if (argc == 1)
-		goto print;
-
-	if (!str2off(argv[1], size)) {
-		printf("'%s' is not a number\n", argv[1]);
-		return -1;
-	}
-
-	if (*size > *maxsize) {
-		puts("Size exceeds partition or device limit\n");
-		return -1;
-	}
-
-print:
-	printf("device %d ", *idx);
-	if (*size == chipsize)
-		puts("whole chip\n");
-	else
-		printf("offset 0x%llx, size 0x%llx\n",
-		       (unsigned long long)*off, (unsigned long long)*size);
-	return 0;
-}
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index e3549f0a46..ceffd994de 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -588,12 +588,6 @@ struct mtd_info *__mtd_next_device(int i);
 	     (mtd) != NULL;				\
 	     (mtd) = __mtd_next_device(mtd->index + 1))
 
-int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
-		loff_t *maxsize, int devtype, uint64_t chipsize);
-int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
-		     loff_t *size, loff_t *maxsize, int devtype,
-		     uint64_t chipsize);
-
 /* drivers/mtd/mtdcore.c */
 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
 			  const uint64_t length, uint64_t *len_incl_bad,
-- 
2.20.1

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

* [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD
  2019-10-25 17:39 [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Miquel Raynal
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code Miquel Raynal
@ 2019-10-25 17:39 ` Miquel Raynal
  2019-12-05  2:53   ` Tom Rini
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup Miquel Raynal
  2019-10-26 10:20 ` [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Jagan Teki
  3 siblings, 1 reply; 13+ messages in thread
From: Miquel Raynal @ 2019-10-25 17:39 UTC (permalink / raw)
  To: u-boot

Defconfigs have been fixed, now we can add proper dependencies in
Kconfig. SPI FLASH is still not dependent on MTD (deeper rework needed).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 cmd/Kconfig | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 33adf29a96..01d4330e04 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -799,6 +799,7 @@ config CMD_FDC
 config CMD_FLASH
 	bool "flinfo, erase, protect"
 	default y
+	depends on MTD
 	help
 	  NOR flash support.
 	    flinfo - print FLASH memory information
@@ -988,6 +989,7 @@ config CMD_MMC_SWRITE
 
 config CMD_MTD
 	bool "mtd"
+	depends on MTD
 	select MTD_PARTITIONS
 	help
 	  MTD commands support.
@@ -995,6 +997,7 @@ config CMD_MTD
 config CMD_NAND
 	bool "nand"
 	default y if NAND_SUNXI
+	depends on MTD_RAW_NAND
 	help
 	  NAND support.
 
@@ -1026,6 +1029,7 @@ config CMD_NVME
 
 config CMD_ONENAND
 	bool "onenand - access to onenand device"
+	depends on MTD
 	help
 	  OneNAND is a brand of NAND ('Not AND' gate) flash which provides
 	  various useful features. This command allows reading, writing,
@@ -1895,7 +1899,7 @@ config CMD_JFFS2
 
 config CMD_MTDPARTS
 	bool "MTD partition support"
-	select MTD if (CMD_NAND || NAND)
+	depends on MTD
 	help
 	  MTD partitioning tool support.
 	  It is strongly encouraged to avoid using this command
@@ -1915,14 +1919,14 @@ config CMD_MTDPARTS_SPREAD
 
 config MTDIDS_DEFAULT
 	string "Default MTD IDs"
-	depends on MTD_PARTITIONS || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
+	depends on MTD || SPI_FLASH
 	help
 	  Defines a default MTD IDs list for use with MTD partitions in the
 	  Linux MTD command line partitions format.
 
 config MTDPARTS_DEFAULT
 	string "Default MTD partition scheme"
-	depends on MTD_PARTITIONS || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
+	depends on MTD || SPI_FLASH
 	help
 	  Defines a default MTD partitioning scheme in the Linux MTD command
 	  line partitions format
-- 
2.20.1

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

* [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup
  2019-10-25 17:39 [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Miquel Raynal
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code Miquel Raynal
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD Miquel Raynal
@ 2019-10-25 17:39 ` Miquel Raynal
  2019-12-05  2:53   ` Tom Rini
  2019-10-26 10:20 ` [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Jagan Teki
  3 siblings, 1 reply; 13+ messages in thread
From: Miquel Raynal @ 2019-10-25 17:39 UTC (permalink / raw)
  To: u-boot

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. MTD core files and some MTD device drivers are
compiled in a mtd.o object and included in the final object only if
MTD support is required (there are two different symbols for that, one
for U-Boot and one for the SPL).

Now that all defconfigs have been fixed, we can stop the logic where
enabling a command selects the core files to compile. This logic is
broken since selecting a symbol with a 'depends on' will not enforce
this secondary dependency.

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

diff --git a/Makefile b/Makefile
index 1d9ade948b..e55c0b236e 100644
--- a/Makefile
+++ b/Makefile
@@ -708,11 +708,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/power/ \
diff --git a/drivers/Makefile b/drivers/Makefile
index a4bb5e4975..708aa2a1a7 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
 obj-$(CONFIG_$(SPL_TPL_)INPUT) += input/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
-obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
+obj-y += mtd/
 obj-$(CONFIG_$(SPL_TPL_)PCH_SUPPORT) += pch/
 obj-$(CONFIG_$(SPL_TPL_)PCI) += pci/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
@@ -19,7 +19,6 @@ obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
 obj-$(CONFIG_$(SPL_TPL_)RTC_SUPPORT) += rtc/
 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/
@@ -42,9 +41,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/
@@ -102,6 +98,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 c9a96adace..fd4c6687cb 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -3,20 +3,40 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-ifneq (,$(findstring y,$(CONFIG_MTD)$(CONFIG_CMD_ONENAND)$(CONFIG_CMD_MTD)))
-obj-y += mtdcore.o mtd_uboot.o
+mtd-$(CONFIG_MTD) += mtdcore.o mtd_uboot.o
+mtd-$(CONFIG_DM_MTD) += mtd-uclass.o
+mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.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
+
+# U-Boot build
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
+
+ifneq ($(mtd-y),)
+obj-y += mtd.o
 endif
-obj-$(CONFIG_DM_MTD) += mtd-uclass.o
-obj-$(CONFIG_MTD_PARTITIONS) += mtdpart.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
-
 obj-y += nand/
+obj-y += onenand/
+obj-y += spi/
+obj-$(CONFIG_MTD_UBI) += ubi/
+
+#SPL/TPL build
+else
+
+ifneq ($(mtd-y),)
+obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd.o
+endif
+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 a358bc680e..96e186600a 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -1,5 +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
-- 
2.20.1

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-25 17:39 [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Miquel Raynal
                   ` (2 preceding siblings ...)
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup Miquel Raynal
@ 2019-10-26 10:20 ` Jagan Teki
  2019-10-26 22:03   ` Miquel Raynal
  3 siblings, 1 reply; 13+ messages in thread
From: Jagan Teki @ 2019-10-26 10:20 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
<miquel.raynal@bootlin.com> wrote:
>
> As rightfully pointed by Jagan, I should have dropped the dependency
> of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
>
> Instead of sending the 40 patches again, here are only the last three
> patches with:
> * patch 1 (24/26) being corrected as per Jagan's comment
> * patch 2 (25/26) is untouched
> * patch 3 (26/26) is almost untouched but I had to resolve a conflict
>   due to patch 1.
>
> Thanks,
> Miquèl
>
> Miquel Raynal (3):
>   cmd: nand/sf: isolate legacy code
>   cmd: make MTD commands depend on MTD
>   mtd: Makefile: deep cleanup

Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-26 10:20 ` [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Jagan Teki
@ 2019-10-26 22:03   ` Miquel Raynal
  2019-10-27 11:53     ` Jagan Teki
  0 siblings, 1 reply; 13+ messages in thread
From: Miquel Raynal @ 2019-10-26 22:03 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

Jagan Teki <jagan@amarulasolutions.com> wrote on Sat, 26 Oct 2019
15:50:06 +0530:

> On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> <miquel.raynal@bootlin.com> wrote:
> >
> > As rightfully pointed by Jagan, I should have dropped the dependency
> > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> >
> > Instead of sending the 40 patches again, here are only the last three
> > patches with:
> > * patch 1 (24/26) being corrected as per Jagan's comment
> > * patch 2 (25/26) is untouched
> > * patch 3 (26/26) is almost untouched but I had to resolve a conflict
> >   due to patch 1.
> >
> > Thanks,
> > Miquèl
> >
> > Miquel Raynal (3):
> >   cmd: nand/sf: isolate legacy code
> >   cmd: make MTD commands depend on MTD
> >   mtd: Makefile: deep cleanup  
> 
> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>

Thanks!

Who is supposed to take the two series?

Miquèl

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-26 22:03   ` Miquel Raynal
@ 2019-10-27 11:53     ` Jagan Teki
  2019-10-27 14:06       ` Tom Rini
  0 siblings, 1 reply; 13+ messages in thread
From: Jagan Teki @ 2019-10-27 11:53 UTC (permalink / raw)
  To: u-boot

On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Hi Jagan,
>
> Jagan Teki <jagan@amarulasolutions.com> wrote on Sat, 26 Oct 2019
> 15:50:06 +0530:
>
> > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > <miquel.raynal@bootlin.com> wrote:
> > >
> > > As rightfully pointed by Jagan, I should have dropped the dependency
> > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > >
> > > Instead of sending the 40 patches again, here are only the last three
> > > patches with:
> > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > * patch 2 (25/26) is untouched
> > > * patch 3 (26/26) is almost untouched but I had to resolve a conflict
> > >   due to patch 1.
> > >
> > > Thanks,
> > > Miquèl
> > >
> > > Miquel Raynal (3):
> > >   cmd: nand/sf: isolate legacy code
> > >   cmd: make MTD commands depend on MTD
> > >   mtd: Makefile: deep cleanup
> >
> > Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
>
> Thanks!
>
> Who is supposed to take the two series?

Looks like there are several defconfig changes in master, please
rebase on master and send your branch (some where from github or so).

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-27 11:53     ` Jagan Teki
@ 2019-10-27 14:06       ` Tom Rini
  2019-10-27 14:24         ` Jagan Teki
  0 siblings, 1 reply; 13+ messages in thread
From: Tom Rini @ 2019-10-27 14:06 UTC (permalink / raw)
  To: u-boot

On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:
> On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >
> > Hi Jagan,
> >
> > Jagan Teki <jagan@amarulasolutions.com> wrote on Sat, 26 Oct 2019
> > 15:50:06 +0530:
> >
> > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > > <miquel.raynal@bootlin.com> wrote:
> > > >
> > > > As rightfully pointed by Jagan, I should have dropped the dependency
> > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > >
> > > > Instead of sending the 40 patches again, here are only the last three
> > > > patches with:
> > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > * patch 2 (25/26) is untouched
> > > > * patch 3 (26/26) is almost untouched but I had to resolve a conflict
> > > >   due to patch 1.
> > > >
> > > > Thanks,
> > > > Miquèl
> > > >
> > > > Miquel Raynal (3):
> > > >   cmd: nand/sf: isolate legacy code
> > > >   cmd: make MTD commands depend on MTD
> > > >   mtd: Makefile: deep cleanup
> > >
> > > Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
> >
> > Thanks!
> >
> > Who is supposed to take the two series?
> 
> Looks like there are several defconfig changes in master, please
> rebase on master and send your branch (some where from github or so).

If it's just defconfigs, I'll grab it so I can have the series also be
the only thing in the tree when I do the before/after size check.
Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191027/a520e7df/attachment.sig>

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-27 14:06       ` Tom Rini
@ 2019-10-27 14:24         ` Jagan Teki
  2019-10-27 14:40           ` Miquel Raynal
  0 siblings, 1 reply; 13+ messages in thread
From: Jagan Teki @ 2019-10-27 14:24 UTC (permalink / raw)
  To: u-boot

On Sun, 27 Oct, 2019, 15:06 Tom Rini, <trini@konsulko.com> wrote:

> On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:
> > On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal <miquel.raynal@bootlin.com>
> wrote:
> > >
> > > Hi Jagan,
> > >
> > > Jagan Teki <jagan@amarulasolutions.com> wrote on Sat, 26 Oct 2019
> > > 15:50:06 +0530:
> > >
> > > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > > > <miquel.raynal@bootlin.com> wrote:
> > > > >
> > > > > As rightfully pointed by Jagan, I should have dropped the
> dependency
> > > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the
> "MTD
> > > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > > >
> > > > > Instead of sending the 40 patches again, here are only the last
> three
> > > > > patches with:
> > > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > > * patch 2 (25/26) is untouched
> > > > > * patch 3 (26/26) is almost untouched but I had to resolve a
> conflict
> > > > >   due to patch 1.
> > > > >
> > > > > Thanks,
> > > > > Miquèl
> > > > >
> > > > > Miquel Raynal (3):
> > > > >   cmd: nand/sf: isolate legacy code
> > > > >   cmd: make MTD commands depend on MTD
> > > > >   mtd: Makefile: deep cleanup
> > > >
> > > > Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
> > >
> > > Thanks!
> > >
> > > Who is supposed to take the two series?
> >
> > Looks like there are several defconfig changes in master, please
> > rebase on master and send your branch (some where from github or so).
>
> If it's just defconfigs, I'll grab it so I can have the series also be
> the only thing in the tree when I do the before/after size check.
> Thanks!
>

Thanks Tom.

>

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

* [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup
  2019-10-27 14:24         ` Jagan Teki
@ 2019-10-27 14:40           ` Miquel Raynal
  0 siblings, 0 replies; 13+ messages in thread
From: Miquel Raynal @ 2019-10-27 14:40 UTC (permalink / raw)
  To: u-boot

Hello,

Jagan Teki <jagan@amarulasolutions.com> wrote on Sun, 27 Oct 2019
15:24:40 +0100:

> On Sun, 27 Oct, 2019, 15:06 Tom Rini, <trini@konsulko.com> wrote:
> 
> > On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:  
> > > On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal <miquel.raynal@bootlin.com>  
> > wrote:  
> > > >
> > > > Hi Jagan,
> > > >
> > > > Jagan Teki <jagan@amarulasolutions.com> wrote on Sat, 26 Oct 2019
> > > > 15:50:06 +0530:
> > > >  
> > > > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > > > > <miquel.raynal@bootlin.com> wrote:  
> > > > > >
> > > > > > As rightfully pointed by Jagan, I should have dropped the  
> > dependency  
> > > > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the  
> > "MTD  
> > > > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > > > >
> > > > > > Instead of sending the 40 patches again, here are only the last  
> > three  
> > > > > > patches with:
> > > > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > > > * patch 2 (25/26) is untouched
> > > > > > * patch 3 (26/26) is almost untouched but I had to resolve a  
> > conflict  
> > > > > >   due to patch 1.
> > > > > >
> > > > > > Thanks,
> > > > > > Miquèl
> > > > > >
> > > > > > Miquel Raynal (3):
> > > > > >   cmd: nand/sf: isolate legacy code
> > > > > >   cmd: make MTD commands depend on MTD
> > > > > >   mtd: Makefile: deep cleanup  
> > > > >
> > > > > Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>  
> > > >
> > > > Thanks!
> > > >
> > > > Who is supposed to take the two series?  
> > >
> > > Looks like there are several defconfig changes in master, please
> > > rebase on master and send your branch (some where from github or so).  
> >
> > If it's just defconfigs, I'll grab it so I can have the series also be
> > the only thing in the tree when I do the before/after size check.
> > Thanks!
> >  
> 
> Thanks Tom.
> 
> >  

Great! Thanks Tom.

Miquèl

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

* [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code Miquel Raynal
@ 2019-12-05  2:53   ` Tom Rini
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2019-12-05  2:53 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 25, 2019 at 07:39:29PM +0200, Miquel Raynal wrote:

> The 'sf' command is not supposed to rely on the MTD stack, but both
> 'sf' and 'nand' commands use helpers located in mtd_uboot.c. Despite
> their location, these functions do not depend at all on the MTD
> stack.
> 
> This file (drivers/mtd/mtd_uboot.c) is only compiled if CONFIG_MTD is
> selected, which is inconsistent with the current situation. Solve this
> by moving these three functions (which are only used by the above two
> commands) out of mtd_uboot.c and put them in a C file only compiled
> with cmd/sf.c and cmd/nand.c.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191204/c27fa452/attachment.sig>

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

* [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD Miquel Raynal
@ 2019-12-05  2:53   ` Tom Rini
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2019-12-05  2:53 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 25, 2019 at 07:39:30PM +0200, Miquel Raynal wrote:

> Defconfigs have been fixed, now we can add proper dependencies in
> Kconfig. SPI FLASH is still not dependent on MTD (deeper rework needed).
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191204/827ff7d6/attachment.sig>

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

* [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup
  2019-10-25 17:39 ` [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup Miquel Raynal
@ 2019-12-05  2:53   ` Tom Rini
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2019-12-05  2:53 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 25, 2019 at 07:39:31PM +0200, Miquel Raynal wrote:

> 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. MTD core files and some MTD device drivers are
> compiled in a mtd.o object and included in the final object only if
> MTD support is required (there are two different symbols for that, one
> for U-Boot and one for the SPL).
> 
> Now that all defconfigs have been fixed, we can stop the logic where
> enabling a command selects the core files to compile. This logic is
> broken since selecting a symbol with a 'depends on' will not enforce
> this secondary dependency.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191204/784dad3b/attachment.sig>

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

end of thread, other threads:[~2019-12-05  2:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 17:39 [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Miquel Raynal
2019-10-25 17:39 ` [U-Boot] [PATCH v6 1/3] cmd: nand/sf: isolate legacy code Miquel Raynal
2019-12-05  2:53   ` Tom Rini
2019-10-25 17:39 ` [U-Boot] [PATCH v6 2/3] cmd: make MTD commands depend on MTD Miquel Raynal
2019-12-05  2:53   ` Tom Rini
2019-10-25 17:39 ` [U-Boot] [PATCH v6 3/3] mtd: Makefile: deep cleanup Miquel Raynal
2019-12-05  2:53   ` Tom Rini
2019-10-26 10:20 ` [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup Jagan Teki
2019-10-26 22:03   ` Miquel Raynal
2019-10-27 11:53     ` Jagan Teki
2019-10-27 14:06       ` Tom Rini
2019-10-27 14:24         ` Jagan Teki
2019-10-27 14:40           ` Miquel Raynal

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