mtd/drivers/mtd mtdchar.c,1.57,1.58

gleixner at infradead.org gleixner at infradead.org
Tue Apr 20 08:22:38 EDT 2004


Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv25059

Modified Files:
	mtdchar.c 
Log Message:
Make devfs work for 2.4 again

Index: mtdchar.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdchar.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- mtdchar.c	30 Mar 2004 20:59:46 -0000	1.57
+++ mtdchar.c	20 Apr 2004 12:22:35 -0000	1.58
@@ -25,6 +25,12 @@
 	.remove	= mtd_notify_remove,
 };
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+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
+
 #endif
 
 static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
@@ -469,11 +475,44 @@
 
 
 #ifdef CONFIG_DEVFS_FS
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+
 /* Notification that a new device has been added. Create the devfs entry for
  * it. */
 
 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);
+}
+
+static void mtd_notify_remove(struct mtd_info* mtd)
+{
+	if (!mtd)
+		return;
+
+	devfs_unregister(devfs_rw_handle[mtd->index]);
+	devfs_unregister(devfs_ro_handle[mtd->index]);
+}
+
+#else
+
+static void mtd_notify_add(struct mtd_info* mtd)
+{
 	if (!mtd)
 		return;
 
@@ -494,6 +533,8 @@
 	devfs_remove ("mtd/%d", mtd->index*2);
 	devfs_remove ("mtd/%dro", mtd->index*2);
 }
+
+#endif
 #endif
 
 static int __init init_mtdchar(void)
@@ -506,8 +547,11 @@
 	}
 
 #ifdef CONFIG_DEVFS_FS
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	devfs_dir_handle = devfs_mk_dir(NULL, "mtd", NULL);
+#else	
 	devfs_mk_dir("mtd");
-
+#endif
 	register_mtd_user(&notifier);
 #endif
 	return 0;
@@ -517,7 +561,11 @@
 {
 #ifdef CONFIG_DEVFS_FS
 	unregister_mtd_user(&notifier);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	devfs_unregister(devfs_dir_handle);
+#else	
 	devfs_remove ("mtd");
+#endif
 #endif
 	unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
 }




More information about the linux-mtd-cvs mailing list