[U-Boot] [PATCH v2 6/14] cmd: Add Kconfig option for CMD_MTDPARTS and related options

Boris Brezillon boris.brezillon at free-electrons.com
Wed Jan 4 10:10:56 CET 2017


Hi Maxime,

On Tue, 22 Nov 2016 13:38:36 +0100
Maxime Ripard <maxime.ripard at free-electrons.com> wrote:

> CMD_MTDPARTS is something the user might or might not want to select, and
> might depends on (or be selected by) other options too.
> 
> This is even truer for the MTDIDS_DEFAULT and MTDPARTS_DEFAULT options that
> might change from one board to another, or from one user to the other,
> depending on what it expects and what storage devices are available.
> 
> In order to ease that configuration, add those options to Kconfig.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
> ---
>  cmd/Kconfig    | 19 +++++++++++++++++++
>  cmd/mtdparts.c |  8 ++++++++
>  2 files changed, 27 insertions(+), 0 deletions(-)
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index e339d8638aa5..cd98e2a2bd00 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -717,6 +717,25 @@ config CMD_FS_GENERIC
>  	help
>  	  Enables filesystem commands (e.g. load, ls) that work for multiple
>  	  fs types.
> +
> +config CMD_MTDPARTS
> +	bool "MTD partition support"

	depends on MTD

Also, it seems that MTD_DEVICE and MTD_PARTITIONS still have to be
defined in the board/soc config header, which is kind of disturbing.

I modified the patch (see below) to add hidden MTD_DEVICE and
MTD_PARTITIONS options and select them from MTDPARTS. This way you can
get rid of all MTD related definitions in sunxi-common.h.

I also have 3 more patches [1][2][3] to expose UBIFS and NAND suboptions
through Kconfig in order to get rid of the extra definitions you add in
sunxi-common.h (patch 9). Let me know if you want me to send them
separately, otherwise, you can include them in your series.

Regards,

Boris

[1]http://code.bulix.org/l9ca0i-107843
[2]http://code.bulix.org/29dzqe-107844
[3]http://code.bulix.org/hp7y46-107845

--->8---
From 55ff74860374b32df1e4073227d2a9aa39873459 Mon Sep 17 00:00:00 2001
From: Maxime Ripard <maxime.ripard at free-electrons.com>
Date: Tue, 22 Nov 2016 13:38:36 +0100
Subject: [PATCH] cmd: Add Kconfig option for CMD_MTDPARTS and related options

CMD_MTDPARTS is something the user might or might not want to select, and
might depends on (or be selected by) other options too. Add the
hidden MTD_DEVICE and MTD_PARTITIONS options and select them from
CMD_MTDPARTS since they are required to properly expose MTD devices and
partitions to various users, including mtdparts.

This is even truer for the MTDIDS_DEFAULT and MTDPARTS_DEFAULT options that
might change from one board to another, or from one user to the other,
depending on what it expects and what storage devices are available.

In order to ease that configuration, add those options to Kconfig.

Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
---
 cmd/Kconfig         | 22 ++++++++++++++++++++++
 cmd/mtdparts.c      |  8 ++++++++
 drivers/mtd/Kconfig |  8 ++++++++
 3 files changed, 38 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 91bd3fb0b58e..05afc2864744 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -763,6 +763,28 @@ config CMD_FS_GENERIC
 	help
 	  Enables filesystem commands (e.g. load, ls) that work for multiple
 	  fs types.
+
+config CMD_MTDPARTS
+	bool "MTD partition support"
+	depends on MTD
+	select MTD_DEVICE
+	select MTD_PARTITIONS
+	help
+	  MTD partition support
+
+config MTDIDS_DEFAULT
+	string "Default MTD IDs"
+	depends on CMD_MTDPARTS
+	help
+	  Defines a default MTD ID
+
+config MTDPARTS_DEFAULT
+	string "Default MTD partition scheme"
+	depends on CMD_MTDPARTS
+	help
+	  Defines a default MTD partitioning scheme in the Linux MTD command
+	  line partitions format
+
 endmenu
 
 config CMD_UBI
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index b9b160dc1e2f..112bf1f3e3cd 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -110,11 +110,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* default values for mtdids and mtdparts variables */
 #if !defined(MTDIDS_DEFAULT)
+#ifdef CONFIG_MTDIDS_DEFAULT
+#define MTDIDS_DEFAULT CONFIG_MTDIDS_DEFAULT
+#else
 #define MTDIDS_DEFAULT NULL
 #endif
+#endif
 #if !defined(MTDPARTS_DEFAULT)
+#ifdef CONFIG_MTDPARTS_DEFAULT
+#define MTDPARTS_DEFAULT CONFIG_MTDPARTS_DEFAULT
+#else
 #define MTDPARTS_DEFAULT NULL
 #endif
+#endif
 #if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
 extern void board_mtdparts_default(const char **mtdids, const char **mtdparts);
 #endif
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 3a9705c41bdf..bebb2f78533e 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -35,6 +35,14 @@ config FLASH_PIC32
 	  This enables access to Microchip PIC32 internal non-CFI flash
 	  chips through PIC32 Non-Volatile-Memory Controller.
 
+config MTD_DEVICE
+	bool
+	depends on MTD
+
+config MTD_PARTITIONS
+	bool
+	depends on MTD
+
 endmenu
 
 source "drivers/mtd/nand/Kconfig"
-- 
2.7.4


More information about the U-Boot mailing list