Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 660685d9 authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse
Browse files

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: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent cb70783c
Loading
Loading
Loading
Loading
+0 −13
Original line number Original line Diff line number Diff line
@@ -157,19 +157,6 @@ config MTD_BCM47XX_PARTS


comment "User Modules And Translation Layers"
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
config MTD_BLKDEVS
	tristate "Common interface to block layer for MTD 'translation layers'"
	tristate "Common interface to block layer for MTD 'translation layers'"
	depends on BLOCK
	depends on BLOCK
+1 −2
Original line number Original line Diff line number Diff line
@@ -4,7 +4,7 @@


# Core functionality.
# Core functionality.
obj-$(CONFIG_MTD)		+= mtd.o
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_OF_PARTS)	+= ofpart.o
obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.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
obj-$(CONFIG_MTD_BCM47XX_PARTS)	+= bcm47xxpart.o


# 'Users' - code which presents functionality to userspace.
# 'Users' - code which presents functionality to userspace.
obj-$(CONFIG_MTD_CHAR)		+= mtdchar.o
obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
obj-$(CONFIG_MTD_BLOCK)		+= mtdblock.o
obj-$(CONFIG_MTD_BLOCK)		+= mtdblock.o
obj-$(CONFIG_MTD_BLOCK_RO)	+= mtdblock_ro.o
obj-$(CONFIG_MTD_BLOCK_RO)	+= mtdblock_ro.o
+0 −1
Original line number Original line Diff line number Diff line
@@ -146,7 +146,6 @@ config MTD_CFI_I8
config MTD_OTP
config MTD_OTP
	bool "Protection Registers aka one-time programmable (OTP) bits"
	bool "Protection Registers aka one-time programmable (OTP) bits"
	depends on MTD_CFI_ADV_OPTIONS
	depends on MTD_CFI_ADV_OPTIONS
	select HAVE_MTD_OTP
	default n
	default n
	help
	help
	  This enables support for reading, writing and locking so called
	  This enables support for reading, writing and locking so called
+0 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,6 @@ config MTD_DATAFLASH_WRITE_VERIFY
config MTD_DATAFLASH_OTP
config MTD_DATAFLASH_OTP
	bool "DataFlash OTP support (Security Register)"
	bool "DataFlash OTP support (Security Register)"
	depends on MTD_DATAFLASH
	depends on MTD_DATAFLASH
	select HAVE_MTD_OTP
	help
	help
	  Newer DataFlash chips (revisions C and D) support 128 bytes of
	  Newer DataFlash chips (revisions C and D) support 128 bytes of
	  one-time-programmable (OTP) data.  The first half may be written
	  one-time-programmable (OTP) data.  The first half may be written
+4 −16
Original line number Original line Diff line number Diff line
@@ -38,6 +38,8 @@


#include <asm/uaccess.h>
#include <asm/uaccess.h>


#include "mtdcore.h"

static DEFINE_MUTEX(mtd_mutex);
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);
	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)
static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
{
{
	struct mtd_info *mtd = mfi->mtd;
	struct mtd_info *mtd = mfi->mtd;
@@ -395,9 +396,6 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)


	return 0;
	return 0;
}
}
#else
# define otp_select_filemode(f,m)	-EOPNOTSUPP
#endif


static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd,
static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd,
	uint64_t start, uint32_t length, void __user *ptr,
	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;
		break;
	}
	}


#ifdef CONFIG_HAVE_MTD_OTP
	case OTPSELECT:
	case OTPSELECT:
	{
	{
		int mode;
		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);
		ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
		break;
		break;
	}
	}
#endif


	/* This ioctl is being deprecated - it truncates the ECC layout */
	/* This ioctl is being deprecated - it truncates the ECC layout */
	case ECCGETLAYOUT:
	case ECCGETLAYOUT:
@@ -1242,7 +1238,7 @@ static struct file_system_type mtd_inodefs_type = {
};
};
MODULE_ALIAS_FS("mtd_inodefs");
MODULE_ALIAS_FS("mtd_inodefs");


static int __init init_mtdchar(void)
int __init init_mtdchar(void)
{
{
	int ret;
	int ret;


@@ -1268,18 +1264,10 @@ static int __init init_mtdchar(void)
	return ret;
	return ret;
}
}


static void __exit cleanup_mtdchar(void)
void __exit cleanup_mtdchar(void)
{
{
	unregister_filesystem(&mtd_inodefs_type);
	unregister_filesystem(&mtd_inodefs_type);
	__unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd");
	__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 <dwmw2@infradead.org>");
MODULE_DESCRIPTION("Direct character-device access to MTD devices");
MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR);
Loading