aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-03-14 07:27:40 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-04-05 08:16:54 -0400
commit660685d9d1b4730f0b5ca97fa95f272f99c63bce (patch)
tree564d8e27ffc6059c1b39843cdea6a457afaaaba7 /drivers/mtd
parentcb70783c65c2eb1b4593fc0b285ddd6d38499185 (diff)
mtd: merge mtdchar module with mtdcore
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. They 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. [dwmw2: Strictly speaking, you can mount file systems on MTD devices just fine without the mtdchar (or mtdblock) devices; you just can't do other manipulations directly on the underlying device. But still I agree that it makes sense to make this unconditional. And Yay! we get to kill off an instance of checking CONFIG_foo_MODULE, which is an abomination that should never happen.] Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/Kconfig13
-rw-r--r--drivers/mtd/Makefile3
-rw-r--r--drivers/mtd/chips/Kconfig1
-rw-r--r--drivers/mtd/devices/Kconfig1
-rw-r--r--drivers/mtd/mtdchar.c20
-rw-r--r--drivers/mtd/mtdcore.c13
-rw-r--r--drivers/mtd/mtdcore.h7
-rw-r--r--drivers/mtd/onenand/Kconfig1
8 files changed, 19 insertions, 40 deletions
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 557bec599f4f..5fab4e6e8301 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -157,19 +157,6 @@ config MTD_BCM47XX_PARTS
157 157
158comment "User Modules And Translation Layers" 158comment "User Modules And Translation Layers"
159 159
160config MTD_CHAR
161 tristate "Direct char device access to MTD devices"
162 help
163 This provides a character device for each MTD device present in
164 the system, allowing the user to read and write directly to the
165 memory chips, and also use ioctl() to obtain information about
166 the device, or to erase parts of it.
167
168config HAVE_MTD_OTP
169 bool
170 help
171 Enable access to OTP regions using MTD_CHAR.
172
173config MTD_BLKDEVS 160config MTD_BLKDEVS
174 tristate "Common interface to block layer for MTD 'translation layers'" 161 tristate "Common interface to block layer for MTD 'translation layers'"
175 depends on BLOCK 162 depends on BLOCK
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 18a38e55b2f0..4cfb31e6c966 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -4,7 +4,7 @@
4 4
5# Core functionality. 5# Core functionality.
6obj-$(CONFIG_MTD) += mtd.o 6obj-$(CONFIG_MTD) += mtd.o
7mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o 7mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
8 8
9obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o 9obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
10obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o 10obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o
15obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o 15obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
16 16
17# 'Users' - code which presents functionality to userspace. 17# 'Users' - code which presents functionality to userspace.
18obj-$(CONFIG_MTD_CHAR) += mtdchar.o
19obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o 18obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o
20obj-$(CONFIG_MTD_BLOCK) += mtdblock.o 19obj-$(CONFIG_MTD_BLOCK) += mtdblock.o
21obj-$(CONFIG_MTD_BLOCK_RO) += mtdblock_ro.o 20obj-$(CONFIG_MTD_BLOCK_RO) += mtdblock_ro.o
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index c219e3d098d9..e4696b37f3de 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -146,7 +146,6 @@ config MTD_CFI_I8
146config MTD_OTP 146config MTD_OTP
147 bool "Protection Registers aka one-time programmable (OTP) bits" 147 bool "Protection Registers aka one-time programmable (OTP) bits"
148 depends on MTD_CFI_ADV_OPTIONS 148 depends on MTD_CFI_ADV_OPTIONS
149 select HAVE_MTD_OTP
150 default n 149 default n
151 help 150 help
152 This enables support for reading, writing and locking so called 151 This enables support for reading, writing and locking so called
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index ec4a2cc3e9b5..2a4d55e4b362 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -71,7 +71,6 @@ config MTD_DATAFLASH_WRITE_VERIFY
71config MTD_DATAFLASH_OTP 71config MTD_DATAFLASH_OTP
72 bool "DataFlash OTP support (Security Register)" 72 bool "DataFlash OTP support (Security Register)"
73 depends on MTD_DATAFLASH 73 depends on MTD_DATAFLASH
74 select HAVE_MTD_OTP
75 help 74 help
76 Newer DataFlash chips (revisions C and D) support 128 bytes of 75 Newer DataFlash chips (revisions C and D) support 128 bytes of
77 one-time-programmable (OTP) data. The first half may be written 76 one-time-programmable (OTP) data. The first half may be written
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index c7292528c7bb..e0e59bf9b915 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -38,6 +38,8 @@
38 38
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
41#include "mtdcore.h"
42
41static DEFINE_MUTEX(mtd_mutex); 43static DEFINE_MUTEX(mtd_mutex);
42 44
43/* 45/*
@@ -365,7 +367,6 @@ static void mtdchar_erase_callback (struct erase_info *instr)
365 wake_up((wait_queue_head_t *)instr->priv); 367 wake_up((wait_queue_head_t *)instr->priv);
366} 368}
367 369
368#ifdef CONFIG_HAVE_MTD_OTP
369static int otp_select_filemode(struct mtd_file_info *mfi, int mode) 370static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
370{ 371{
371 struct mtd_info *mtd = mfi->mtd; 372 struct mtd_info *mtd = mfi->mtd;
@@ -395,9 +396,6 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
395 396
396 return 0; 397 return 0;
397} 398}
398#else
399# define otp_select_filemode(f,m) -EOPNOTSUPP
400#endif
401 399
402static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, 400static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd,
403 uint64_t start, uint32_t length, void __user *ptr, 401 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)
890 break; 888 break;
891 } 889 }
892 890
893#ifdef CONFIG_HAVE_MTD_OTP
894 case OTPSELECT: 891 case OTPSELECT:
895 { 892 {
896 int mode; 893 int mode;
@@ -946,7 +943,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
946 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); 943 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
947 break; 944 break;
948 } 945 }
949#endif
950 946
951 /* This ioctl is being deprecated - it truncates the ECC layout */ 947 /* This ioctl is being deprecated - it truncates the ECC layout */
952 case ECCGETLAYOUT: 948 case ECCGETLAYOUT:
@@ -1242,7 +1238,7 @@ static struct file_system_type mtd_inodefs_type = {
1242}; 1238};
1243MODULE_ALIAS_FS("mtd_inodefs"); 1239MODULE_ALIAS_FS("mtd_inodefs");
1244 1240
1245static int __init init_mtdchar(void) 1241int __init init_mtdchar(void)
1246{ 1242{
1247 int ret; 1243 int ret;
1248 1244
@@ -1268,18 +1264,10 @@ err_unregister_chdev:
1268 return ret; 1264 return ret;
1269} 1265}
1270 1266
1271static void __exit cleanup_mtdchar(void) 1267void __exit cleanup_mtdchar(void)
1272{ 1268{
1273 unregister_filesystem(&mtd_inodefs_type); 1269 unregister_filesystem(&mtd_inodefs_type);
1274 __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd"); 1270 __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd");
1275} 1271}
1276 1272
1277module_init(init_mtdchar);
1278module_exit(cleanup_mtdchar);
1279
1280MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
1281
1282MODULE_LICENSE("GPL");
1283MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
1284MODULE_DESCRIPTION("Direct character-device access to MTD devices");
1285MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR); 1273MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 91c2efd22e1f..71877ff77cbf 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -41,6 +41,7 @@
41#include <linux/mtd/partitions.h> 41#include <linux/mtd/partitions.h>
42 42
43#include "mtdcore.h" 43#include "mtdcore.h"
44
44/* 45/*
45 * backing device capabilities for non-mappable devices (such as NAND flash) 46 * backing device capabilities for non-mappable devices (such as NAND flash)
46 * - permits private mappings, copies are taken of the data 47 * - permits private mappings, copies are taken of the data
@@ -96,11 +97,7 @@ EXPORT_SYMBOL_GPL(__mtd_next_device);
96static LIST_HEAD(mtd_notifiers); 97static LIST_HEAD(mtd_notifiers);
97 98
98 99
99#if defined(CONFIG_MTD_CHAR) || defined(CONFIG_MTD_CHAR_MODULE)
100#define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2) 100#define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2)
101#else
102#define MTD_DEVT(index) 0
103#endif
104 101
105/* REVISIT once MTD uses the driver model better, whoever allocates 102/* REVISIT once MTD uses the driver model better, whoever allocates
106 * the mtd_info will probably want to use the release() hook... 103 * the mtd_info will probably want to use the release() hook...
@@ -1185,8 +1182,15 @@ static int __init init_mtd(void)
1185 1182
1186 proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops); 1183 proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
1187 1184
1185 ret = init_mtdchar();
1186 if (ret)
1187 goto out_procfs;
1188
1188 return 0; 1189 return 0;
1189 1190
1191out_procfs:
1192 if (proc_mtd)
1193 remove_proc_entry("mtd", NULL);
1190err_bdi3: 1194err_bdi3:
1191 bdi_destroy(&mtd_bdi_ro_mappable); 1195 bdi_destroy(&mtd_bdi_ro_mappable);
1192err_bdi2: 1196err_bdi2:
@@ -1200,6 +1204,7 @@ err_reg:
1200 1204
1201static void __exit cleanup_mtd(void) 1205static void __exit cleanup_mtd(void)
1202{ 1206{
1207 cleanup_mtdchar();
1203 if (proc_mtd) 1208 if (proc_mtd)
1204 remove_proc_entry("mtd", NULL); 1209 remove_proc_entry("mtd", NULL);
1205 class_unregister(&mtd_class); 1210 class_unregister(&mtd_class);
diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h
index 9b10fed1ae2c..7b0353399a10 100644
--- a/drivers/mtd/mtdcore.h
+++ b/drivers/mtd/mtdcore.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * These are exported solely for the purpose of mtd_blkdevs.c. You 2 * These are exported solely for the purpose of mtd_blkdevs.c and mtdchar.c.
3 * should not use them for _anything_ else. 3 * You should not use them for _anything_ else.
4 */ 4 */
5 5
6extern struct mutex mtd_table_mutex; 6extern struct mutex mtd_table_mutex;
@@ -14,6 +14,9 @@ int parse_mtd_partitions(struct mtd_info *master, const char * const *types,
14 struct mtd_partition **pparts, 14 struct mtd_partition **pparts,
15 struct mtd_part_parser_data *data); 15 struct mtd_part_parser_data *data);
16 16
17int __init init_mtdchar(void);
18void __exit cleanup_mtdchar(void);
19
17#define mtd_for_each_device(mtd) \ 20#define mtd_for_each_device(mtd) \
18 for ((mtd) = __mtd_next_device(0); \ 21 for ((mtd) = __mtd_next_device(0); \
19 (mtd) != NULL; \ 22 (mtd) != NULL; \
diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
index 91467bb03634..eac7bb28360d 100644
--- a/drivers/mtd/onenand/Kconfig
+++ b/drivers/mtd/onenand/Kconfig
@@ -40,7 +40,6 @@ config MTD_ONENAND_SAMSUNG
40 40
41config MTD_ONENAND_OTP 41config MTD_ONENAND_OTP
42 bool "OneNAND OTP Support" 42 bool "OneNAND OTP Support"
43 select HAVE_MTD_OTP
44 help 43 help
45 One Block of the NAND Flash Array memory is reserved as 44 One Block of the NAND Flash Array memory is reserved as
46 a One-Time Programmable Block memory area. 45 a One-Time Programmable Block memory area.