Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / packages / linux / linux-dm800 / linux-2.6.12-brcm-mtd-blkdevfs-fix.diff
1 Index: stblinux-2.6.12/drivers/mtd/mtd_blkdevs.c
2 ===================================================================
3 --- stblinux-2.6.12.orig/drivers/mtd/mtd_blkdevs.c      2007-07-26 00:55:00.000000000 +0200
4 +++ stblinux-2.6.12/drivers/mtd/mtd_blkdevs.c   2008-01-16 23:58:30.000000000 +0100
5 @@ -21,6 +21,7 @@
6  #include <linux/init.h>
7  #include <asm/semaphore.h>
8  #include <asm/uaccess.h>
9 +#include <linux/devfs_fs_kernel.h>
10  
11  static LIST_HEAD(blktrans_majors);
12  
13 @@ -302,6 +303,9 @@
14                 snprintf(gd->disk_name, sizeof(gd->disk_name),
15                          "%s%d", tr->name, new->devnum);
16  
17 +       snprintf(gd->devfs_name, sizeof(gd->devfs_name),
18 +                "%s/%c", tr->name, (tr->part_bits?'a':'0') + new->devnum);
19 +
20         /* 2.5 has capacity in units of 512 bytes while still
21            having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */
22         set_capacity(gd, (new->size * new->blksize) >> 9);
23 @@ -418,6 +422,8 @@
24                 return ret;
25         }
26  
27 +       devfs_mk_dir(tr->name);
28 +
29         INIT_LIST_HEAD(&tr->devs);
30         list_add(&tr->list, &blktrans_majors);
31  
32 @@ -450,6 +456,7 @@
33                 tr->remove_dev(dev);
34         }
35  
36 +       devfs_remove(tr->name);
37         blk_cleanup_queue(tr->blkcore_priv->rq);
38         unregister_blkdev(tr->major, tr->name);
39  
40 Index: stblinux-2.6.12/drivers/mtd/mtdchar.c
41 ===================================================================
42 --- stblinux-2.6.12.orig/drivers/mtd/mtdchar.c  2008-01-21 01:37:38.000000000 +0100
43 +++ stblinux-2.6.12/drivers/mtd/mtdchar.c       2008-01-21 01:37:40.000000000 +0100
44 @@ -26,6 +26,8 @@
45  
46  static struct class *mtd_class;
47  
48 +#include <linux/devfs_fs_kernel.h>
49 +
50  static void mtd_notify_add(struct mtd_info* mtd)
51  {
52         if (!mtd)
53 @@ -50,6 +52,12 @@
54                             MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
55                             NULL, "mtd%dro", mtd->index);
56  #endif
57 +
58 +       devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
59 +                     S_IFCHR | S_IRUGO | S_IWUGO, "mtd/%d", mtd->index);
60 +
61 +       devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
62 +                     S_IFCHR | S_IRUGO, "mtd/%dro", mtd->index);
63  }
64  
65  static void mtd_notify_remove(struct mtd_info* mtd)
66 @@ -59,6 +67,9 @@
67  
68         class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
69         class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
70 +
71 +       devfs_remove("mtd/%d", mtd->index);
72 +       devfs_remove("mtd/%dro", mtd->index);
73  }
74  
75  static struct mtd_notifier notifier = {
76 @@ -66,6 +77,17 @@
77         .remove = mtd_notify_remove,
78  };
79  
80 +static inline void mtdchar_devfs_init(void)
81 +{
82 +       devfs_mk_dir("mtd");
83 +}
84 +
85 +static inline void mtdchar_devfs_exit(void)
86 +{
87 +       devfs_remove("mtd");
88 +}
89 +
90 +
91  /*
92   * We use file->private_data to store a pointer to the MTDdevice.
93   * Since alighment is at least 32 bits, we have 2 bits free for OTP
94 @@ -807,6 +829,7 @@
95                 return PTR_ERR(mtd_class);
96         }
97  
98 +       mtdchar_devfs_init();
99         register_mtd_user(&notifier);
100         return 0;
101  }
102 @@ -815,6 +838,7 @@
103  {
104         unregister_mtd_user(&notifier);
105         class_destroy(mtd_class);
106 +       mtdchar_devfs_exit();
107         unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
108  }
109