[U-Boot] [PATCH v3 25/28] cmd: nand/sf: isolate legacy code
Boris Brezillon
boris.brezillon at bootlin.com
Wed Dec 5 10:37:54 UTC 2018
On Wed, 5 Dec 2018 00:57:11 +0100
Miquel Raynal <miquel.raynal at bootlin.com> 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 incoherent with the current situation. Solve this
^inconsistent
> by mobing these three functions (which are only used by the above two
^ moving
> 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 at bootlin.com>
> ---
> cmd/Makefile | 4 +-
> cmd/legacy-mtd-utils.c | 99 +++++++++++++++++++++++++++++++++++++++++
> cmd/legacy-mtd-utils.h | 14 ++++++
> cmd/nand.c | 2 +
> cmd/sf.c | 2 +
> drivers/mtd/mtd_uboot.c | 94 --------------------------------------
> include/linux/mtd/mtd.h | 6 ---
> 7 files changed, 119 insertions(+), 102 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 0534ddc679..54c54c062d 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -94,7 +94,7 @@ obj-$(CONFIG_CMD_MMC_SPI) += mmc_spi.o
> obj-$(CONFIG_MP) += mp.o
> obj-$(CONFIG_CMD_MTD) += mtd.o
> obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
> -obj-$(CONFIG_CMD_NAND) += nand.o
> +obj-$(CONFIG_CMD_NAND) += nand.o legacy-mtd-utils.o
> obj-$(CONFIG_CMD_NET) += net.o
> obj-$(CONFIG_CMD_ONENAND) += onenand.o
> obj-$(CONFIG_CMD_OSD) += osd.o
> @@ -115,7 +115,7 @@ obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o
> obj-$(CONFIG_SANDBOX) += host.o
> obj-$(CONFIG_CMD_SATA) += sata.o
> obj-$(CONFIG_CMD_NVME) += nvme.o
> -obj-$(CONFIG_CMD_SF) += sf.o
> +obj-$(CONFIG_CMD_SF) += sf.o legacy-mtd-utils.o
That won't work if you enable both CMD_SF and CMD_NAND. The linker will
complain that some symbols are duplicated.
Either you add a new hidden Kconfig option that is selected by CMD_NAND
and CMD_SF, or you use the ifeq trick:
ifeq (,$(findstring y,$(CONFIG_CMD_NAND)$(CONFIG_CMD_SF)))
obj-y += legacy-mtd-utils.o
endif
More information about the U-Boot
mailing list