public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* patch to create sysfs char device nodes
@ 2005-06-09 14:16 Paolo Galtieri
  2005-07-04 16:14 ` Coywolf Qi Hunt
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Galtieri @ 2005-06-09 14:16 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Hi,
  with DEVFS going away I discovered that no character device nodes are
created if a flash device is present which contains filesystems. The
mtd-utils package requires the existence of character device nodes for
performing erase, lock and unlock functions.  The problem is that the
flash device driver has not been modified to use sysfs instead of devfs.

I have attached a patch to mtdchar.c which uses the sysfs interface to
create the appropriate nodes.  Please let me know if you have comments.

The changes are for linux-2.6.12-rc5

Thanks
Paolo

[-- Attachment #2: MTDCnew --]
[-- Type: text/plain, Size: 2085 bytes --]

--- drivers/mtd/OLDmtdchar.c	2005-06-06 16:10:39.000000000 -0700
+++ drivers/mtd/mtdchar.c	2005-06-06 16:18:39.000000000 -0700
@@ -15,27 +15,29 @@
 #include <linux/fs.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_DEVFS_FS
-#include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
+
+static struct class_simple *mtd_class;
 
 static void mtd_notify_add(struct mtd_info* mtd)
 {
 	if (!mtd)
 		return;
 
-	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, "mtd/%dro", mtd->index);
+	class_simple_device_add(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
+		NULL, "mtd%d", mtd->index);
+
+	class_simple_device_add(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
+		NULL, "mtd%dro", mtd->index);
+
 }
 
 static void mtd_notify_remove(struct mtd_info* mtd)
 {
 	if (!mtd)
 		return;
-	devfs_remove("mtd/%d", mtd->index);
-	devfs_remove("mtd/%dro", mtd->index);
+	class_simple_device_remove(MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
+	class_simple_device_remove(MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
 }
 
 static struct mtd_notifier notifier = {
@@ -45,19 +47,13 @@
 
 static inline void mtdchar_devfs_init(void)
 {
-	devfs_mk_dir("mtd");
 	register_mtd_user(&notifier);
 }
 
 static inline void mtdchar_devfs_exit(void)
 {
 	unregister_mtd_user(&notifier);
-	devfs_remove("mtd");
 }
-#else /* !DEVFS */
-#define mtdchar_devfs_init() do { } while(0)
-#define mtdchar_devfs_exit() do { } while(0)
-#endif
 
 static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
 {
@@ -543,6 +539,14 @@
 		return -EAGAIN;
 	}
 
+	mtd_class = class_simple_create(THIS_MODULE, "mtd");
+
+	if (IS_ERR(mtd_class)) {
+		printk(KERN_ERR "Error creating mtd class.\n");
+		unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
+		return 1;
+	}
+
 	mtdchar_devfs_init();
 	return 0;
 }
@@ -550,6 +554,7 @@
 static void __exit cleanup_mtdchar(void)
 {
 	mtdchar_devfs_exit();
+	class_simple_destroy(mtd_class);
 	unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: patch to create sysfs char device nodes
  2005-06-09 14:16 patch to create sysfs char device nodes Paolo Galtieri
@ 2005-07-04 16:14 ` Coywolf Qi Hunt
  2005-07-04 16:25   ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Coywolf Qi Hunt @ 2005-07-04 16:14 UTC (permalink / raw)
  To: Paolo Galtieri; +Cc: Andrew Morton, linux-mtd, lkml

On 6/9/05, Paolo Galtieri <pgaltieri@mvista.com> wrote:
> Hi,
>   with DEVFS going away I discovered that no character device nodes are
> created if a flash device is present which contains filesystems. The
> mtd-utils package requires the existence of character device nodes for
> performing erase, lock and unlock functions.  The problem is that the
> flash device driver has not been modified to use sysfs instead of devfs.
> 
> I have attached a patch to mtdchar.c which uses the sysfs interface to
> create the appropriate nodes.  Please let me know if you have comments.

I encountered the same problem days ago. Thanks for the patch. A patch
based on yours will be sent in the next mail.

-- 
Coywolf Qi Hunt
http://ahbl.org/~coywolf/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: patch to create sysfs char device nodes
  2005-07-04 16:14 ` Coywolf Qi Hunt
@ 2005-07-04 16:25   ` Thomas Gleixner
  2005-07-04 17:15     ` Coywolf Qi Hunt
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2005-07-04 16:25 UTC (permalink / raw)
  To: coywolf; +Cc: Andrew Morton, Paolo Galtieri, linux-mtd, lkml

On Tue, 2005-07-05 at 00:14 +0800, Coywolf Qi Hunt wrote:
> On 6/9/05, Paolo Galtieri <pgaltieri@mvista.com> wrote:
> > Hi,
> >   with DEVFS going away I discovered that no character device nodes are
> > created if a flash device is present which contains filesystems. The
> > mtd-utils package requires the existence of character device nodes for
> > performing erase, lock and unlock functions.  The problem is that the
> > flash device driver has not been modified to use sysfs instead of devfs.
> > 
> > I have attached a patch to mtdchar.c which uses the sysfs interface to
> > create the appropriate nodes.  Please let me know if you have comments.
> 
> I encountered the same problem days ago. Thanks for the patch. A patch
> based on yours will be sent in the next mail.

A reworked patch is in the MTD CVS and in the mtd-git tree already. No
need to send something

tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: patch to create sysfs char device nodes
  2005-07-04 16:25   ` Thomas Gleixner
@ 2005-07-04 17:15     ` Coywolf Qi Hunt
  0 siblings, 0 replies; 4+ messages in thread
From: Coywolf Qi Hunt @ 2005-07-04 17:15 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-mtd, Paolo Galtieri, coywolf

On Mon, Jul 04, 2005 at 06:25:41PM +0200, Thomas Gleixner wrote:
> On Tue, 2005-07-05 at 00:14 +0800, Coywolf Qi Hunt wrote:
> > On 6/9/05, Paolo Galtieri <pgaltieri@mvista.com> wrote:
> > > Hi,
> > >   with DEVFS going away I discovered that no character device nodes are
> > > created if a flash device is present which contains filesystems. The
> > > mtd-utils package requires the existence of character device nodes for
> > > performing erase, lock and unlock functions.  The problem is that the
> > > flash device driver has not been modified to use sysfs instead of devfs.
> > > 
> > > I have attached a patch to mtdchar.c which uses the sysfs interface to
> > > create the appropriate nodes.  Please let me know if you have comments.
> > 
> > I encountered the same problem days ago. Thanks for the patch. A patch
> > based on yours will be sent in the next mail.
> 
> A reworked patch is in the MTD CVS and in the mtd-git tree already. No
> need to send something
> 
> tglx
> 


Basically the git diff is what I was trying to do. plus


Index: mtd/drivers/mtd/mtdchar.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdchar.c,v
retrieving revision 1.72
diff -p -u -r1.72 mtdchar.c
--- mtd/drivers/mtd/mtdchar.c	30 Jun 2005 00:23:24 -0000	1.72
+++ mtd/drivers/mtd/mtdchar.c	4 Jul 2005 17:08:14 -0000
@@ -649,7 +649,7 @@ static int __init init_mtdchar(void)
 	if (IS_ERR(mtd_class)) {
 		printk(KERN_ERR "Error creating mtd class.\n");
 		unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
-		return 1;
+		return PTR_ERR(mtd_class);
 	}
 
 	register_mtd_user(&notifier);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-04 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-09 14:16 patch to create sysfs char device nodes Paolo Galtieri
2005-07-04 16:14 ` Coywolf Qi Hunt
2005-07-04 16:25   ` Thomas Gleixner
2005-07-04 17:15     ` Coywolf Qi Hunt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox