1 diff -Nurb linux/drivers/mtd/mtdcore.c linux-mtd-rw/drivers/mtd/mtdcore.c
2 --- linux/drivers/mtd/mtdcore.c 2004-11-18 13:16:00.000000000 +0100
3 +++ linux-mtd-rw/drivers/mtd/mtdcore.c 2004-11-18 15:27:13.130036616 +0100
6 #include <linux/mtd/mtd.h>
8 +/* this symbol is exported by the procfs. */
9 +extern struct proc_dir_entry *proc_sys_root;
12 /* These are exported solely for the purpose of mtd_blkdevs.c. You
13 should not use them for _anything_ else */
14 DECLARE_MUTEX(mtd_table_mutex);
17 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
18 static struct proc_dir_entry *proc_mtd;
20 +static struct proc_dir_entry *proc_sys_mtd;
21 +static struct proc_dir_entry *proc_sys_mtd_partition[MAX_MTD_DEVICES];
22 +static struct proc_dir_entry *proc_sys_mtd_partition_rw[MAX_MTD_DEVICES];
25 +/*===================================0
26 + * mtdproc_read_partition_access
28 +static int mtdproc_read_partition_access ( char *page, char **start, off_t off,int count,
29 + int *eof, void *data
32 + int partid = (unsigned int)data;
35 + // NO RETURN FROM HERE UNTIL "up(&mtd_table_mutex)".
36 + down(&mtd_table_mutex);
38 + if (partid < MAX_MTD_DEVICES)
40 + struct mtd_info *this = mtd_table[partid];
43 + page[len] = (this->flags & MTD_WRITEABLE) ? '1' : '0';
48 + up(&mtd_table_mutex);
52 + *start = page + off;
53 + return ((count < len-off) ? count : len-off);
57 +static int mtdproc_write_partition_access (struct file *file, const char *buffer,
58 + unsigned long count, void *data)
60 + int partid = (unsigned int)data;
63 + // NO RETURN FROM HERE UNTIL "up(&mtd_table_mutex)".
64 + down(&mtd_table_mutex);
66 + if (partid < MAX_MTD_DEVICES)
68 + struct mtd_info *this = mtd_table[partid];
69 + if (this && count > 0)
74 + this->flags &= ~(this->master_flags & MTD_WRITEABLE);
78 + this->flags |= ~(this->master_flags & MTD_WRITEABLE);
87 + up(&mtd_table_mutex);
96 static inline int mtd_proc_info (char *buf, int i)
98 struct mtd_info *this = mtd_table[i];
100 this->erasesize, this->name);
104 static int mtd_read_proc ( char *page, char **start, off_t off,int count
105 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
106 ,int *eof, void *data_unused
107 @@ -404,12 +484,31 @@
108 /*====================================================================*/
112 int __init init_mtd(void)
114 #ifdef CONFIG_PROC_FS
115 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
118 if ((proc_mtd = create_proc_entry( "mtd", 0, 0 )))
119 proc_mtd->read_proc = mtd_read_proc;
121 + proc_sys_mtd = proc_mkdir("mtd", proc_sys_root);
122 + for (i=0; i<MAX_MTD_DEVICES; i++)
125 + sprintf (partname, "%d", i);
127 + proc_sys_mtd_partition[i] = proc_mkdir(partname, proc_sys_mtd);
128 + proc_sys_mtd_partition_rw[i] = create_proc_entry ("rw", S_IFREG | S_IRUGO, proc_sys_mtd_partition[i]);
129 + if (proc_sys_mtd_partition_rw[i])
131 + proc_sys_mtd_partition_rw[i]->read_proc = mtdproc_read_partition_access;
132 + proc_sys_mtd_partition_rw[i]->write_proc = mtdproc_write_partition_access;
133 + proc_sys_mtd_partition_rw[i]->data = (void *)i;
137 proc_register_dynamic(&proc_root,&mtd_proc_entry);
145 static void __exit cleanup_mtd(void)
148 diff -Nurb linux/drivers/mtd/mtdpart.c linux-mtd-rw/drivers/mtd/mtdpart.c
149 --- linux/drivers/mtd/mtdpart.c 2004-11-18 13:16:00.000000000 +0100
150 +++ linux-mtd-rw/drivers/mtd/mtdpart.c 2004-11-18 15:27:13.131036464 +0100
152 /* set up the MTD object for this partition */
153 slave->mtd.type = master->type;
154 slave->mtd.flags = master->flags & ~parts[i].mask_flags;
155 + slave->mtd.master_flags = master->flags;
156 + slave->mtd.mask_flags = parts[i].mask_flags;
158 slave->mtd.size = parts[i].size;
159 slave->mtd.oobblock = master->oobblock;
160 slave->mtd.oobsize = master->oobsize;
161 diff -Nurb linux/include/linux/mtd/mtd.h linux-mtd-rw/include/linux/mtd/mtd.h
162 --- linux/include/linux/mtd/mtd.h 2004-11-18 13:16:31.000000000 +0100
163 +++ linux-mtd-rw/include/linux/mtd/mtd.h 2004-11-18 15:27:13.000000000 +0100
166 struct module *owner;
169 + u_int32_t master_flags;
170 + u_int32_t mask_flags;