Skip to contentSkip to conversation

mtd: merge mtdchar module with mtdcore

PATCH New Artem Bityutskiy 2 participants 15 messages Mar 14, 2013 – Apr 4, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 mtd: merge mtdchar module with mtdcore

From: Artem Bityutskiy <[email protected]>

The MTD subsystem has historically tried to be as configurable as possible. The side-effect of this is that its configuration menu is rather large, and we are gradually shrinking it. For example, we recently merged partitions support with the mtdcore.

This patch does the next step - it merges the mtdchar module to mtdcore. And in this case this is not only about eliminating too fine-grained separation and simplifying the configuration menu. This is also about eliminating seemingly useless kernel module.

Indeed, mtdchar is a module that allows user-space making use of MTD devices via /dev/mtd* character devices. If users do not enable it, they simply cannot use MTD devices at all. The cannot read or write the flash contents. Is it a sane and useful setup? I believe not. And everyone just enables mtdchar.

Having mtdchar separate is also a little bit harmful. People sometimes miss the fact that they need to enable an additional configuration option to have user-space MTD interfaces, and then they wonder why on earth the kernel does not allow using the flash? They spend time asking around.

Thus, let's just get rid of this module and make it part of mtd core.

Note, mtdchar had additional configuration option to enable OTP interfaces, which are present on some flashes. I removed that option as well - it saves a really tiny amount space.

---
 drivers/mtd/Kconfig         |   13 -------------
 drivers/mtd/Makefile        |    3 +--
 drivers/mtd/chips/Kconfig   |    1 -
 drivers/mtd/devices/Kconfig |    1 -
 drivers/mtd/mtdchar.c       |    6 ------
 drivers/mtd/mtdcore.c       |    4 ----
 drivers/mtd/onenand/Kconfig |    1 -
 7 files changed, 1 insertion(+), 28 deletions(-)
drivers/mtd/Kconfig +0 -13
index 557bec5..5fab4e6e 100644
@@ -157,19 +157,6 @@ config MTD_BCM47XX_PARTS
 
 comment "User Modules And Translation Layers"
 
-config MTD_CHAR
-	tristate "Direct char device access to MTD devices"
-	help
-	  This provides a character device for each MTD device present in
-	  the system, allowing the user to read and write directly to the
-	  memory chips, and also use ioctl() to obtain information about
-	  the device, or to erase parts of it.
-
-config HAVE_MTD_OTP
-	bool
-	help
-	  Enable access to OTP regions using MTD_CHAR.
-
 config MTD_BLKDEVS
 	tristate "Common interface to block layer for MTD 'translation layers'"
 	depends on BLOCK
drivers/mtd/Makefile +1 -2
index 18a38e5..4cfb31e 100644
@@ -4,7 +4,7 @@
 
 # Core functionality.
 obj-$(CONFIG_MTD)		+= mtd.o
-mtd-y				:= mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o
+mtd-y				:= mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
 
 obj-$(CONFIG_MTD_OF_PARTS)	+= ofpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_BCM63XX_PARTS)	+= bcm63xxpart.o
 obj-$(CONFIG_MTD_BCM47XX_PARTS)	+= bcm47xxpart.o
 
 # 'Users' - code which presents functionality to userspace.
-obj-$(CONFIG_MTD_CHAR)		+= mtdchar.o
 obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
 obj-$(CONFIG_MTD_BLOCK)		+= mtdblock.o
 obj-$(CONFIG_MTD_BLOCK_RO)	+= mtdblock_ro.o
drivers/mtd/chips/Kconfig +0 -1
index c219e3d..e4696b3 100644
@@ -146,7 +146,6 @@ config MTD_CFI_I8
 config MTD_OTP
 	bool "Protection Registers aka one-time programmable (OTP) bits"
 	depends on MTD_CFI_ADV_OPTIONS
-	select HAVE_MTD_OTP
 	default n
 	help
 	  This enables support for reading, writing and locking so called
drivers/mtd/devices/Kconfig +0 -1
index ec4a2cc..2a4d55e 100644
@@ -71,7 +71,6 @@ config MTD_DATAFLASH_WRITE_VERIFY
 config MTD_DATAFLASH_OTP
 	bool "DataFlash OTP support (Security Register)"
 	depends on MTD_DATAFLASH
-	select HAVE_MTD_OTP
 	help
 	  Newer DataFlash chips (revisions C and D) support 128 bytes of
 	  one-time-programmable (OTP) data.  The first half may be written
drivers/mtd/mtdchar.c +0 -6
index c2b6729..e50b321 100644
@@ -365,7 +365,6 @@ static void mtdchar_erase_callback (struct erase_info *instr)
 	wake_up((wait_queue_head_t *)instr->priv);
 }
 
-#ifdef CONFIG_HAVE_MTD_OTP
 static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
 {
 	struct mtd_info *mtd = mfi->mtd;
@@ -395,9 +394,6 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
 
 	return 0;
 }
-#else
-# define otp_select_filemode(f,m)	-EOPNOTSUPP
-#endif
 
 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd,
 	uint64_t start, uint32_t length, void __user *ptr,
@@ -890,7 +886,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 		break;
 	}
 
-#ifdef CONFIG_HAVE_MTD_OTP
 	case OTPSELECT:
 	{
 		int mode;
@@ -946,7 +941,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 		ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
 		break;
 	}
-#endif
 
 	/* This ioctl is being deprecated - it truncates the ECC layout */
 	case ECCGETLAYOUT:
drivers/mtd/mtdcore.c +0 -4
index 681bb6d..a8ff916 100644
@@ -96,11 +96,7 @@ EXPORT_SYMBOL_GPL(__mtd_next_device);
 static LIST_HEAD(mtd_notifiers);
 
 
-#if defined(CONFIG_MTD_CHAR) || defined(CONFIG_MTD_CHAR_MODULE)
 #define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2)
-#else
-#define MTD_DEVT(index) 0
-#endif
 
 /* REVISIT once MTD uses the driver model better, whoever allocates
  * the mtd_info will probably want to use the release() hook...
drivers/mtd/onenand/Kconfig +0 -1
index 91467bb..eac7bb2 100644
@@ -40,7 +40,6 @@ config MTD_ONENAND_SAMSUNG
 
 config MTD_ONENAND_OTP
 	bool "OneNAND OTP Support"
-	select HAVE_MTD_OTP
 	help
 	  One Block of the NAND Flash Array memory is reserved as
 	  a One-Time Programmable Block memory area.
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/4 mtd: merge mtdchar module with mtdcore

Quoted 11 lines · Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The MTD subsystem has historically tried to be as configurable as possible. The side-effect of this is that its configuration menu is rather large, and we are gradually shrinking it. For example, we recently merged partitions support with the mtdcore.

This patch does the next step - it merges the mtdchar module to mtdcore. And in this case this is not only about eliminating too fine-grained separation and simplifying the configuration menu. This is also about eliminating seemingly useless kernel module.

I've pushed the patch-set to the l2-mtd.git tree.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#2 lore raw

PATCH 2/4 Documentation: mtd: amend the sysfs docs after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 Documentation/ABI/testing/sysfs-class-mtd |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-class-mtd +2 -4
index 938ef71..3105644 100644
@@ -14,8 +14,7 @@ Description:
 		The /sys/class/mtd/mtd{0,1,2,3,...} directories correspond
 		to each /dev/mtdX character device.  These may represent
 		physical/simulated flash devices, partitions on a flash
-		device, or concatenated flash devices.  They exist regardless
-		of whether CONFIG_MTD_CHAR is actually enabled.
+		device, or concatenated flash devices.
 
 What:		/sys/class/mtd/mtdXro/
 Date:		April 2009
@@ -23,8 +22,7 @@ KernelVersion:	2.6.29
 Contact:	linux-mtd at lists.infradead.org
 Description:
 		These directories provide the corresponding read-only device
-		nodes for /sys/class/mtd/mtdX/ .  They are only created
-		(for the benefit of udev) if CONFIG_MTD_CHAR is enabled.
+		nodes for /sys/class/mtd/mtdX/ .
 
 What:		/sys/class/mtd/mtdX/dev
 Date:		April 2009
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/4 arm: mach-pxa: amend Kconfig after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 arch/arm/mach-pxa/Kconfig |    1 -
 1 file changed, 1 deletion(-)
arch/arm/mach-pxa/Kconfig +0 -1
index 86eec41..0e74ba0 100644
@@ -160,7 +160,6 @@ config MACH_XCEP
 	select MTD
 	select MTD_CFI
 	select MTD_CFI_INTELEXT
-	select MTD_CHAR
 	select MTD_PHYSMAP
 	select PXA25x
 	select SMC91X
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/4 arch: cris: amend Kconfig after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 arch/cris/Kconfig                  |    1 -
 arch/cris/arch-v32/drivers/Kconfig |    1 -
 2 files changed, 2 deletions(-)
arch/cris/Kconfig +0 -1
index bb0ac66..2d15a46 100644
@@ -264,7 +264,6 @@ config ETRAX_AXISFLASHMAP
 	select MTD_CFI
 	select MTD_CFI_AMDSTD
 	select MTD_JEDECPROBE if ETRAX_ARCH_V32
-	select MTD_CHAR
 	select MTD_BLOCK
 	select MTD_COMPLEX_MAPPINGS
 	help
arch/cris/arch-v32/drivers/Kconfig +0 -1
index af4a486..c55971a 100644
@@ -404,7 +404,6 @@ config ETRAX_AXISFLASHMAP
 	select MTD_CFI
 	select MTD_CFI_AMDSTD
 	select MTD_JEDECPROBE
-	select MTD_CHAR
 	select MTD_BLOCK
 	select MTD_COMPLEX_MAPPINGS
 	help
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 1/4 mtd: merge mtdchar module with mtdcore

In reply to Artem Bityutskiy
Quoted 3 lines · On Thu, 14 Mar 2013 13:27:40 +0200 Artem Bityutskiy <[email protected]> wrote:

Indeed, mtdchar is a module that allows user-space making use of MTD devices via /dev/mtd* character devices. If users do not enable it, they simply cannot use MTD devices at all. The cannot read or write the flash contents. Is it a

s/ The cannot/ They cannot/

What about the defconfig files?

Thanks,
Shmulik

#6 lore raw

PATCH 1/4 mtd: merge mtdchar module with mtdcore

Quoted 6 lines · Shmulik Ladkani
Quoted 3 lines · On Thu, 14 Mar 2013 13:27:40 +0200 Artem Bityutskiy <[email protected]> wrote:

Indeed, mtdchar is a module that allows user-space making use of MTD devices via /dev/mtd* character devices. If users do not enable it, they simply cannot use MTD devices at all. The cannot read or write the flash contents. Is it a

s/ The cannot/ They cannot/

Fixed.

Quoted 1 line

What about the defconfig files?

There are too many of them. I do not want to update them because it is not necessary and the non-existing symbol will just be ignored by Kbuild. People who support their defconfigs will eventually update them eventually.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#8 lore raw

PATCH 1/7 mtd: mtdcore: remove few useless #ifdef's

From: Artem Bityutskiy <[email protected]>

Remove a couple of useles '#ifdef CONFIG_PROC_FS's around procfs functions which anyway turn into empty function in 'proc_fs.h' file when CONFIG_PROC_FS is not defined.

---
 drivers/mtd/mtdcore.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/mtd/mtdcore.c +4 -7
index 681bb6d..91c2efd 100644
@@ -1116,8 +1116,6 @@ EXPORT_SYMBOL_GPL(mtd_kmalloc_up_to);
 /*====================================================================*/
 /* Support for /proc/mtd */
 
-static struct proc_dir_entry *proc_mtd;
-
 static int mtd_proc_show(struct seq_file *m, void *v)
 {
 	struct mtd_info *mtd;
@@ -1163,6 +1161,8 @@ static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name)
 	return ret;
 }
 
+static struct proc_dir_entry *proc_mtd;
+
 static int __init init_mtd(void)
 {
 	int ret;
@@ -1183,9 +1183,8 @@ static int __init init_mtd(void)
 	if (ret)
 		goto err_bdi3;
 
-#ifdef CONFIG_PROC_FS
 	proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
-#endif /* CONFIG_PROC_FS */
+
 	return 0;
 
 err_bdi3:
@@ -1201,10 +1200,8 @@ err_reg:
 
 static void __exit cleanup_mtd(void)
 {
-#ifdef CONFIG_PROC_FS
 	if (proc_mtd)
-		remove_proc_entry( "mtd", NULL);
-#endif /* CONFIG_PROC_FS */
+		remove_proc_entry("mtd", NULL);
 	class_unregister(&mtd_class);
 	bdi_destroy(&mtd_bdi_unmappable);
 	bdi_destroy(&mtd_bdi_ro_mappable);
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH 2/7 mtd: mtdchar: use proper kernel print level

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

We normally use 'pr_err()' for error messages, not 'pr_notice()'.

---
 drivers/mtd/mtdchar.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/mtdchar.c +5 -3
index c2b6729..c729252 100644
@@ -1249,16 +1249,18 @@ static int __init init_mtdchar(void)
 	ret = __register_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS,
 				   "mtd", &mtd_fops);
 	if (ret < 0) {
-		pr_notice("Can't allocate major number %d for "
-				"Memory Technology Devices.\n", MTD_CHAR_MAJOR);
+		pr_err("Can't allocate major number %d for MTD\n",
+		       MTD_CHAR_MAJOR);
 		return ret;
 	}
 
 	ret = register_filesystem(&mtd_inodefs_type);
 	if (ret) {
-		pr_notice("Can't register mtd_inodefs filesystem: %d\n", ret);
+		pr_err("Can't register mtd_inodefs filesystem, error %d\n",
+		       ret);
 		goto err_unregister_chdev;
 	}
+
 	return ret;
 
 err_unregister_chdev:
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 3/7 mtd: mtdcore: cleanup mtdcore.h a little

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

Remove useless export qualifiers. Not that this is a problem, but we more often declare function prototypes without 'export', so this is just about being more consistent. And I am going to add a couple more prototypes here.

Additionally, remove a useless comment.

---
 drivers/mtd/mtdcore.h |   28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)
drivers/mtd/mtdcore.h +11 -17
index 62bf5ac..9b10fed 100644
@@ -1,24 +1,18 @@
-/* linux/drivers/mtd/mtdcore.h
- *
- * Header file for driver private mtdcore exports
- *
+/*
+ * These are exported solely for the purpose of mtd_blkdevs.c. You
+ * should not use them for _anything_ else.
  */
 
-/* These are exported solely for the purpose of mtd_blkdevs.c. You
-   should not use them for _anything_ else */
-
 extern struct mutex mtd_table_mutex;
-extern struct mtd_info *__mtd_next_device(int i);
 
-extern int add_mtd_device(struct mtd_info *mtd);
-extern int del_mtd_device(struct mtd_info *mtd);
-extern int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *,
-			      int);
-extern int del_mtd_partitions(struct mtd_info *);
-extern int parse_mtd_partitions(struct mtd_info *master,
-				const char * const *types,
-				struct mtd_partition **pparts,
-				struct mtd_part_parser_data *data);
+struct mtd_info *__mtd_next_device(int i);
+int add_mtd_device(struct mtd_info *mtd);
+int del_mtd_device(struct mtd_info *mtd);
+int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
+int del_mtd_partitions(struct mtd_info *);
+int parse_mtd_partitions(struct mtd_info *master, const char * const *types,
+			 struct mtd_partition **pparts,
+			 struct mtd_part_parser_data *data);
 
 #define mtd_for_each_device(mtd)			\
 	for ((mtd) = __mtd_next_device(0);		\
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH 4/7 mtd: merge mtdchar module with mtdcore

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The MTD subsystem has historically tried to be as configurable as possible. The side-effect of this is that its configuration menu is rather large, and we are gradually shrinking it. For example, we recently merged partitions support with the mtdcore.

This patch does the next step - it merges the mtdchar module to mtdcore. And in this case this is not only about eliminating too fine-grained separation and simplifying the configuration menu. This is also about eliminating seemingly useless kernel module.

Indeed, mtdchar is a module that allows user-space making use of MTD devices via /dev/mtd* character devices. If users do not enable it, they simply cannot use MTD devices at all. The cannot read or write the flash contents. Is it a sane and useful setup? I believe not. And everyone just enables mtdchar.

Having mtdchar separate is also a little bit harmful. People sometimes miss the fact that they need to enable an additional configuration option to have user-space MTD interfaces, and then they wonder why on earth the kernel does not allow using the flash? They spend time asking around.

Thus, let's just get rid of this module and make it part of mtd core.

Note, mtdchar had additional configuration option to enable OTP interfaces, which are present on some flashes. I removed that option as well - it saves a really tiny amount space.

---
 drivers/mtd/Kconfig         |   13 -------------
 drivers/mtd/Makefile        |    3 +--
 drivers/mtd/chips/Kconfig   |    1 -
 drivers/mtd/devices/Kconfig |    1 -
 drivers/mtd/mtdchar.c       |   20 ++++----------------
 drivers/mtd/mtdcore.c       |   13 +++++++++----
 drivers/mtd/mtdcore.h       |    7 +++++--
 drivers/mtd/onenand/Kconfig |    1 -
 8 files changed, 19 insertions(+), 40 deletions(-)
drivers/mtd/Kconfig +0 -13
index 557bec5..5fab4e6e 100644
@@ -157,19 +157,6 @@ config MTD_BCM47XX_PARTS
 
 comment "User Modules And Translation Layers"
 
-config MTD_CHAR
-	tristate "Direct char device access to MTD devices"
-	help
-	  This provides a character device for each MTD device present in
-	  the system, allowing the user to read and write directly to the
-	  memory chips, and also use ioctl() to obtain information about
-	  the device, or to erase parts of it.
-
-config HAVE_MTD_OTP
-	bool
-	help
-	  Enable access to OTP regions using MTD_CHAR.
-
 config MTD_BLKDEVS
 	tristate "Common interface to block layer for MTD 'translation layers'"
 	depends on BLOCK
drivers/mtd/Makefile +1 -2
index 18a38e5..4cfb31e 100644
@@ -4,7 +4,7 @@
 
 # Core functionality.
 obj-$(CONFIG_MTD)		+= mtd.o
-mtd-y				:= mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o
+mtd-y				:= mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
 
 obj-$(CONFIG_MTD_OF_PARTS)	+= ofpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_BCM63XX_PARTS)	+= bcm63xxpart.o
 obj-$(CONFIG_MTD_BCM47XX_PARTS)	+= bcm47xxpart.o
 
 # 'Users' - code which presents functionality to userspace.
-obj-$(CONFIG_MTD_CHAR)		+= mtdchar.o
 obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
 obj-$(CONFIG_MTD_BLOCK)		+= mtdblock.o
 obj-$(CONFIG_MTD_BLOCK_RO)	+= mtdblock_ro.o
drivers/mtd/chips/Kconfig +0 -1
index c219e3d..e4696b3 100644
@@ -146,7 +146,6 @@ config MTD_CFI_I8
 config MTD_OTP
 	bool "Protection Registers aka one-time programmable (OTP) bits"
 	depends on MTD_CFI_ADV_OPTIONS
-	select HAVE_MTD_OTP
 	default n
 	help
 	  This enables support for reading, writing and locking so called
drivers/mtd/devices/Kconfig +0 -1
index ec4a2cc..2a4d55e 100644
@@ -71,7 +71,6 @@ config MTD_DATAFLASH_WRITE_VERIFY
 config MTD_DATAFLASH_OTP
 	bool "DataFlash OTP support (Security Register)"
 	depends on MTD_DATAFLASH
-	select HAVE_MTD_OTP
 	help
 	  Newer DataFlash chips (revisions C and D) support 128 bytes of
 	  one-time-programmable (OTP) data.  The first half may be written
drivers/mtd/mtdchar.c +4 -16
index c729252..e0e59bf 100644
@@ -38,6 +38,8 @@
 
 #include <asm/uaccess.h>
 
+#include "mtdcore.h"
+
 static DEFINE_MUTEX(mtd_mutex);
 
 /*
@@ -365,7 +367,6 @@ static void mtdchar_erase_callback (struct erase_info *instr)
 	wake_up((wait_queue_head_t *)instr->priv);
 }
 
-#ifdef CONFIG_HAVE_MTD_OTP
 static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
 {
 	struct mtd_info *mtd = mfi->mtd;
@@ -395,9 +396,6 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
 
 	return 0;
 }
-#else
-# define otp_select_filemode(f,m)	-EOPNOTSUPP
-#endif
 
 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd,
 	uint64_t start, uint32_t length, void __user *ptr,
@@ -890,7 +888,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 		break;
 	}
 
-#ifdef CONFIG_HAVE_MTD_OTP
 	case OTPSELECT:
 	{
 		int mode;
@@ -946,7 +943,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 		ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
 		break;
 	}
-#endif
 
 	/* This ioctl is being deprecated - it truncates the ECC layout */
 	case ECCGETLAYOUT:
@@ -1242,7 +1238,7 @@ static struct file_system_type mtd_inodefs_type = {
 };
 MODULE_ALIAS_FS("mtd_inodefs");
 
-static int __init init_mtdchar(void)
+int __init init_mtdchar(void)
 {
 	int ret;
 
@@ -1268,18 +1264,10 @@ err_unregister_chdev:
 	return ret;
 }
 
-static void __exit cleanup_mtdchar(void)
+void __exit cleanup_mtdchar(void)
 {
 	unregister_filesystem(&mtd_inodefs_type);
 	__unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd");
 }
 
-module_init(init_mtdchar);
-module_exit(cleanup_mtdchar);
-
-MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("David Woodhouse <[email protected]>");
-MODULE_DESCRIPTION("Direct character-device access to MTD devices");
 MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
drivers/mtd/mtdcore.c +9 -4
index 91c2efd..71877ff 100644
@@ -41,6 +41,7 @@
 #include <linux/mtd/partitions.h>
 
 #include "mtdcore.h"
+
 /*
  * backing device capabilities for non-mappable devices (such as NAND flash)
  * - permits private mappings, copies are taken of the data
@@ -96,11 +97,7 @@ EXPORT_SYMBOL_GPL(__mtd_next_device);
 static LIST_HEAD(mtd_notifiers);
 
 
-#if defined(CONFIG_MTD_CHAR) || defined(CONFIG_MTD_CHAR_MODULE)
 #define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2)
-#else
-#define MTD_DEVT(index) 0
-#endif
 
 /* REVISIT once MTD uses the driver model better, whoever allocates
  * the mtd_info will probably want to use the release() hook...
@@ -1185,8 +1182,15 @@ static int __init init_mtd(void)
 
 	proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
 
+	ret = init_mtdchar();
+	if (ret)
+		goto out_procfs;
+
 	return 0;
 
+out_procfs:
+	if (proc_mtd)
+		remove_proc_entry("mtd", NULL);
 err_bdi3:
 	bdi_destroy(&mtd_bdi_ro_mappable);
 err_bdi2:
@@ -1200,6 +1204,7 @@ err_reg:
 
 static void __exit cleanup_mtd(void)
 {
+	cleanup_mtdchar();
 	if (proc_mtd)
 		remove_proc_entry("mtd", NULL);
 	class_unregister(&mtd_class);
drivers/mtd/mtdcore.h +5 -2
index 9b10fed..7b03533 100644
@@ -1,6 +1,6 @@
 /*
- * These are exported solely for the purpose of mtd_blkdevs.c. You
- * should not use them for _anything_ else.
+ * These are exported solely for the purpose of mtd_blkdevs.c and mtdchar.c.
+ * You should not use them for _anything_ else.
  */
 
 extern struct mutex mtd_table_mutex;
@@ -14,6 +14,9 @@ int parse_mtd_partitions(struct mtd_info *master, const char * const *types,
 			 struct mtd_partition **pparts,
 			 struct mtd_part_parser_data *data);
 
+int __init init_mtdchar(void);
+void __exit cleanup_mtdchar(void);
+
 #define mtd_for_each_device(mtd)			\
 	for ((mtd) = __mtd_next_device(0);		\
 	     (mtd) != NULL;				\
drivers/mtd/onenand/Kconfig +0 -1
index 91467bb..eac7bb2 100644
@@ -40,7 +40,6 @@ config MTD_ONENAND_SAMSUNG
 
 config MTD_ONENAND_OTP
 	bool "OneNAND OTP Support"
-	select HAVE_MTD_OTP
 	help
 	  One Block of the NAND Flash Array memory is reserved as
 	  a One-Time Programmable Block memory area.
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH 5/7 Documentation: mtd: amend the sysfs docs after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 Documentation/ABI/testing/sysfs-class-mtd |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-class-mtd +2 -4
index 938ef71..3105644 100644
@@ -14,8 +14,7 @@ Description:
 		The /sys/class/mtd/mtd{0,1,2,3,...} directories correspond
 		to each /dev/mtdX character device.  These may represent
 		physical/simulated flash devices, partitions on a flash
-		device, or concatenated flash devices.  They exist regardless
-		of whether CONFIG_MTD_CHAR is actually enabled.
+		device, or concatenated flash devices.
 
 What:		/sys/class/mtd/mtdXro/
 Date:		April 2009
@@ -23,8 +22,7 @@ KernelVersion:	2.6.29
 Contact:	[email protected]
 Description:
 		These directories provide the corresponding read-only device
-		nodes for /sys/class/mtd/mtdX/ .  They are only created
-		(for the benefit of udev) if CONFIG_MTD_CHAR is enabled.
+		nodes for /sys/class/mtd/mtdX/ .
 
 What:		/sys/class/mtd/mtdX/dev
 Date:		April 2009
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH 6/7 arm: mach-pxa: amend Kconfig after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 arch/arm/mach-pxa/Kconfig |    1 -
 1 file changed, 1 deletion(-)
arch/arm/mach-pxa/Kconfig +0 -1
index 86eec41..0e74ba0 100644
@@ -160,7 +160,6 @@ config MACH_XCEP
 	select MTD
 	select MTD_CFI
 	select MTD_CFI_INTELEXT
-	select MTD_CHAR
 	select MTD_PHYSMAP
 	select PXA25x
 	select SMC91X
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH 7/7 arch: cris: amend Kconfig after mtdchar merge

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

The mtdchar module was merged with the mtdcore module, which means that the MTD_CHAR Kconfig symbol does not exist any more.

---
 arch/cris/Kconfig                  |    1 -
 arch/cris/arch-v32/drivers/Kconfig |    1 -
 2 files changed, 2 deletions(-)
arch/cris/Kconfig +0 -1
index bb0ac66..2d15a46 100644
@@ -264,7 +264,6 @@ config ETRAX_AXISFLASHMAP
 	select MTD_CFI
 	select MTD_CFI_AMDSTD
 	select MTD_JEDECPROBE if ETRAX_ARCH_V32
-	select MTD_CHAR
 	select MTD_BLOCK
 	select MTD_COMPLEX_MAPPINGS
 	help
arch/cris/arch-v32/drivers/Kconfig +0 -1
index af4a486..c55971a 100644
@@ -404,7 +404,6 @@ config ETRAX_AXISFLASHMAP
 	select MTD_CFI
 	select MTD_CFI_AMDSTD
 	select MTD_JEDECPROBE
-	select MTD_CHAR
 	select MTD_BLOCK
 	select MTD_COMPLEX_MAPPINGS
 	help
Signature · 1 line
1.7.10.4