#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/seq_file.h>
#include "mtdcore.h"
/*====================================================================*/
/* Support for /proc/mtd */
+static struct proc_dir_entry *proc_mtd;
+
+#define DYNAMIC_CHANGE_MTD_WRITEABLE
+#ifdef DYNAMIC_CHANGE_MTD_WRITEABLE //tonykuo 2013-11-05
+static struct proc_dir_entry *entry;
+extern int mtd_writeable_proc_write(struct file *file, const char *buffer, unsigned long count, void *data);
+extern int mtd_change_proc_write(struct file *file, const char *buffer, unsigned long count, void *data);
+#endif
+
static int mtd_proc_show(struct seq_file *m, void *v)
{
struct mtd_info *mtd;
static struct proc_dir_entry *proc_mtd;
+//tonykuo 2013-11-05
+static const struct file_operations mtd_write_proc_fops = {
+ .owner = THIS_MODULE,
+ .write = mtd_writeable_proc_write,
+};
+
+static const struct file_operations mtd_change_proc_fops = {
+ .owner = THIS_MODULE,
+ .write = mtd_change_proc_write,
+};
+
static int __init init_mtd(void)
{
int ret;
proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
+#ifdef DYNAMIC_CHANGE_MTD_WRITEABLE //tonykuo 2013-11-05
+ entry = proc_create("driver/mtd_writeable", 0600, NULL, &mtd_write_proc_fops);
+ if (entry != NULL) {
+ printk( "mtd_writeable success\n");
+ }
+
+ entry = proc_create("driver/mtd_change", 0600, NULL, &mtd_change_proc_fops);
+ if (entry != NULL) {
+ printk( "mtd_change success\n");
+ }
+#endif
+
ret = init_mtdchar();
if (ret)
goto out_procfs;
cleanup_mtdchar();
if (proc_mtd)
remove_proc_entry("mtd", NULL);
+
+#ifdef DYNAMIC_CHANGE_MTD_WRITEABLE //tonykuo 2013-11-05
+ if (entry) {
+ remove_proc_entry("driver/mtd_writeable", NULL);
+ remove_proc_entry("driver/mtd_change", NULL);
+ }
+#endif
class_unregister(&mtd_class);
bdi_destroy(&mtd_bdi_unmappable);
bdi_destroy(&mtd_bdi_ro_mappable);