From e860233bb08152dbd558365e3fc93b75bc8696a3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 30 Jun 2005 01:23:27 +0100 Subject: [PATCH] --- yaml --- r: 4575 b: refs/heads/master c: 9bc7b38731dd1cc1635ab12f8de48866f603b06e h: refs/heads/master i: 4573: fe98ebb21f406c9a66ca4eca82d16c0967274990 4571: bb3712482767400aabdf361b9e0b20da08719a16 4567: eb5a89a33e7876a93df26c419178947ddd7fd571 4559: 47c2abedf41f054a12e9bc65bbb0ee3dcaf564af 4543: 3248091ed75b3b3829a61a0f9ae3947572dba1c3 v: v3 --- [refs] | 2 +- trunk/drivers/mtd/mtdchar.c | 52 +++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/[refs] b/[refs] index 852fa06f3693..7e2a1fd08768 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bd7bcf52dabba9c391142fd515221fcb87b7c712 +refs/heads/master: 9bc7b38731dd1cc1635ab12f8de48866f603b06e diff --git a/trunk/drivers/mtd/mtdchar.c b/trunk/drivers/mtd/mtdchar.c index da3f1a8f756e..b606f811eeb4 100644 --- a/trunk/drivers/mtd/mtdchar.c +++ b/trunk/drivers/mtd/mtdchar.c @@ -1,5 +1,5 @@ /* - * $Id: mtdchar.c,v 1.70 2005/04/01 15:36:11 nico Exp $ + * $Id: mtdchar.c,v 1.72 2005/06/30 00:23:24 tpoynor Exp $ * * Character-device access to raw MTD devices. * @@ -15,27 +15,30 @@ #include #include -#ifdef CONFIG_DEVFS_FS -#include +#include + +static struct class *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_device_create(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), + NULL, "mtd%d", mtd->index); + + class_device_create(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_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2)); + class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1)); } static struct mtd_notifier notifier = { @@ -43,22 +46,6 @@ static struct mtd_notifier notifier = { .remove = mtd_notify_remove, }; -static inline void mtdchar_devfs_init(void) -{ - devfs_mk_dir("mtd"); - register_mtd_user(¬ifier); -} - -static inline void mtdchar_devfs_exit(void) -{ - unregister_mtd_user(¬ifier); - devfs_remove("mtd"); -} -#else /* !DEVFS */ -#define mtdchar_devfs_init() do { } while(0) -#define mtdchar_devfs_exit() do { } while(0) -#endif - /* * We use file->private_data to store a pointer to the MTDdevice. * Since alighment is at least 32 bits, we have 2 bits free for OTP @@ -657,13 +644,22 @@ static int __init init_mtdchar(void) return -EAGAIN; } - mtdchar_devfs_init(); + mtd_class = class_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; + } + + register_mtd_user(¬ifier); return 0; } static void __exit cleanup_mtdchar(void) { - mtdchar_devfs_exit(); + unregister_mtd_user(¬ifier); + class_destroy(mtd_class); unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); }