Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
David Woodhouse
660685d9 cb70783c

+19 -40
-13
drivers/mtd/Kconfig
··· 157 157 158 158 comment "User Modules And Translation Layers" 159 159 160 - config 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 - 168 - config HAVE_MTD_OTP 169 - bool 170 - help 171 - Enable access to OTP regions using MTD_CHAR. 172 - 173 160 config MTD_BLKDEVS 174 161 tristate "Common interface to block layer for MTD 'translation layers'" 175 162 depends on BLOCK
+1 -2
drivers/mtd/Makefile
··· 4 4 5 5 # Core functionality. 6 6 obj-$(CONFIG_MTD) += mtd.o 7 - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o 7 + mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o 8 8 9 9 obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o 10 10 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o ··· 15 15 obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o 16 16 17 17 # 'Users' - code which presents functionality to userspace. 18 - obj-$(CONFIG_MTD_CHAR) += mtdchar.o 19 18 obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o 20 19 obj-$(CONFIG_MTD_BLOCK) += mtdblock.o 21 20 obj-$(CONFIG_MTD_BLOCK_RO) += mtdblock_ro.o
-1
drivers/mtd/chips/Kconfig
··· 146 146 config MTD_OTP 147 147 bool "Protection Registers aka one-time programmable (OTP) bits" 148 148 depends on MTD_CFI_ADV_OPTIONS 149 - select HAVE_MTD_OTP 150 149 default n 151 150 help 152 151 This enables support for reading, writing and locking so called
-1
drivers/mtd/devices/Kconfig
··· 71 71 config MTD_DATAFLASH_OTP 72 72 bool "DataFlash OTP support (Security Register)" 73 73 depends on MTD_DATAFLASH 74 - select HAVE_MTD_OTP 75 74 help 76 75 Newer DataFlash chips (revisions C and D) support 128 bytes of 77 76 one-time-programmable (OTP) data. The first half may be written
+4 -16
drivers/mtd/mtdchar.c
··· 38 38 39 39 #include <asm/uaccess.h> 40 40 41 + #include "mtdcore.h" 42 + 41 43 static DEFINE_MUTEX(mtd_mutex); 42 44 43 45 /* ··· 367 365 wake_up((wait_queue_head_t *)instr->priv); 368 366 } 369 367 370 - #ifdef CONFIG_HAVE_MTD_OTP 371 368 static int otp_select_filemode(struct mtd_file_info *mfi, int mode) 372 369 { 373 370 struct mtd_info *mtd = mfi->mtd; ··· 396 395 397 396 return 0; 398 397 } 399 - #else 400 - # define otp_select_filemode(f,m) -EOPNOTSUPP 401 - #endif 402 398 403 399 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, 404 400 uint64_t start, uint32_t length, void __user *ptr, ··· 888 890 break; 889 891 } 890 892 891 - #ifdef CONFIG_HAVE_MTD_OTP 892 893 case OTPSELECT: 893 894 { 894 895 int mode; ··· 943 946 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); 944 947 break; 945 948 } 946 - #endif 947 949 948 950 /* This ioctl is being deprecated - it truncates the ECC layout */ 949 951 case ECCGETLAYOUT: ··· 1238 1242 }; 1239 1243 MODULE_ALIAS_FS("mtd_inodefs"); 1240 1244 1241 - static int __init init_mtdchar(void) 1245 + int __init init_mtdchar(void) 1242 1246 { 1243 1247 int ret; 1244 1248 ··· 1264 1268 return ret; 1265 1269 } 1266 1270 1267 - static void __exit cleanup_mtdchar(void) 1271 + void __exit cleanup_mtdchar(void) 1268 1272 { 1269 1273 unregister_filesystem(&mtd_inodefs_type); 1270 1274 __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd"); 1271 1275 } 1272 1276 1273 - module_init(init_mtdchar); 1274 - module_exit(cleanup_mtdchar); 1275 - 1276 - MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR); 1277 - 1278 - MODULE_LICENSE("GPL"); 1279 - MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); 1280 - MODULE_DESCRIPTION("Direct character-device access to MTD devices"); 1281 1277 MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
+9 -4
drivers/mtd/mtdcore.c
··· 41 41 #include <linux/mtd/partitions.h> 42 42 43 43 #include "mtdcore.h" 44 + 44 45 /* 45 46 * backing device capabilities for non-mappable devices (such as NAND flash) 46 47 * - permits private mappings, copies are taken of the data ··· 97 96 static LIST_HEAD(mtd_notifiers); 98 97 99 98 100 - #if defined(CONFIG_MTD_CHAR) || defined(CONFIG_MTD_CHAR_MODULE) 101 99 #define MTD_DEVT(index) MKDEV(MTD_CHAR_MAJOR, (index)*2) 102 - #else 103 - #define MTD_DEVT(index) 0 104 - #endif 105 100 106 101 /* REVISIT once MTD uses the driver model better, whoever allocates 107 102 * the mtd_info will probably want to use the release() hook... ··· 1182 1185 1183 1186 proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops); 1184 1187 1188 + ret = init_mtdchar(); 1189 + if (ret) 1190 + goto out_procfs; 1191 + 1185 1192 return 0; 1186 1193 1194 + out_procfs: 1195 + if (proc_mtd) 1196 + remove_proc_entry("mtd", NULL); 1187 1197 err_bdi3: 1188 1198 bdi_destroy(&mtd_bdi_ro_mappable); 1189 1199 err_bdi2: ··· 1204 1200 1205 1201 static void __exit cleanup_mtd(void) 1206 1202 { 1203 + cleanup_mtdchar(); 1207 1204 if (proc_mtd) 1208 1205 remove_proc_entry("mtd", NULL); 1209 1206 class_unregister(&mtd_class);
+5 -2
drivers/mtd/mtdcore.h
··· 1 1 /* 2 - * These are exported solely for the purpose of mtd_blkdevs.c. You 3 - * should not use them for _anything_ else. 2 + * These are exported solely for the purpose of mtd_blkdevs.c and mtdchar.c. 3 + * You should not use them for _anything_ else. 4 4 */ 5 5 6 6 extern struct mutex mtd_table_mutex; ··· 13 13 int parse_mtd_partitions(struct mtd_info *master, const char * const *types, 14 14 struct mtd_partition **pparts, 15 15 struct mtd_part_parser_data *data); 16 + 17 + int __init init_mtdchar(void); 18 + void __exit cleanup_mtdchar(void); 16 19 17 20 #define mtd_for_each_device(mtd) \ 18 21 for ((mtd) = __mtd_next_device(0); \
-1
drivers/mtd/onenand/Kconfig
··· 40 40 41 41 config MTD_ONENAND_OTP 42 42 bool "OneNAND OTP Support" 43 - select HAVE_MTD_OTP 44 43 help 45 44 One Block of the NAND Flash Array memory is reserved as 46 45 a One-Time Programmable Block memory area.