Suggested patch for mtdchar.c

John Whitney john.whitney at timesys.com
Wed Nov 19 10:06:45 EST 2003


Hello,

I've checked out the latest MTD source, and when I added it to my 2.6.0-pre9
LinuxPPC kernel tree, encountered devfs issues with mtdchar.c.  Listed below
is a patch created from my updated file.  Sorry if something about this has
been posted before, but I didn't find any mention of it in the archives.

--- mtdchar.c.orig    2003-11-19 10:00:54.000000000 -0500
+++ mtdchar.c    2003-11-18 09:37:16.000000000 -0500
@@ -24,10 +24,6 @@
     .add    = mtd_notify_add,
     .remove    = mtd_notify_remove,
 };
-
-static devfs_handle_t devfs_dir_handle;
-static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES];
-static devfs_handle_t devfs_ro_handle[MAX_MTD_DEVICES];
 #endif
 
 static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
@@ -477,22 +473,15 @@
 
 static void mtd_notify_add(struct mtd_info* mtd)
 {
-    char name[8];
-
     if (!mtd)
         return;
 
-    sprintf(name, "%d", mtd->index);
-    devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
-            DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2,
-            S_IFCHR | S_IRUGO | S_IWUGO,
-            &mtd_fops, NULL);
-
-    sprintf(name, "%dro", mtd->index);
-    devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
-            DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1,
-            S_IFCHR | S_IRUGO,
-            &mtd_fops, NULL);
+    devfs_mk_cdev (MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
+                   S_IFCHR | S_IRUGO | S_IWUGO,
+                   "mtd/%d", mtd->index);
+    devfs_mk_cdev (MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
+                   S_IFCHR | S_IRUGO | S_IWUGO,
+                   "mtd/%dro", mtd->index);
 }
 
 static void mtd_notify_remove(struct mtd_info* mtd)
@@ -500,8 +489,8 @@
     if (!mtd)
         return;
 
-    devfs_unregister(devfs_rw_handle[mtd->index]);
-    devfs_unregister(devfs_ro_handle[mtd->index]);
+    devfs_remove ("mtd/%d", mtd->index*2);
+    devfs_remove ("mtd/%dro", mtd->index*2);
 }
 #endif
 
@@ -515,7 +504,7 @@
     }
 
 #ifdef CONFIG_DEVFS_FS
-    devfs_dir_handle = devfs_mk_dir(NULL, "mtd", NULL);
+    devfs_mk_dir("mtd");
 
     register_mtd_user(&notifier);
 #endif
@@ -526,7 +515,7 @@
 {
 #ifdef CONFIG_DEVFS_FS
     unregister_mtd_user(&notifier);
-    devfs_unregister(devfs_dir_handle);
+    devfs_remove ("mtd");
 #endif
     unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
 }




More information about the linux-mtd mailing list