]> git.pld-linux.org Git - packages/kernel.git/blame - 2.6.0-t3-sysfs_mem-lkml.patch
- obsolete
[packages/kernel.git] / 2.6.0-t3-sysfs_mem-lkml.patch
CommitLineData
69ec5240 1--- a/drivers/char/mem.c Mon Aug 18 16:51:45 2003
2+++ b/drivers/char/mem.c Mon Aug 18 16:51:45 2003
3@@ -24,6 +24,7 @@
4 #include <linux/smp_lock.h>
5 #include <linux/devfs_fs_kernel.h>
6 #include <linux/ptrace.h>
7+#include <linux/device.h>
8
9 #include <asm/uaccess.h>
10 #include <asm/io.h>
11@@ -649,7 +650,7 @@
12 .open = memory_open, /* just a selector for the real open */
13 };
14
15-static const struct {
16+static const struct mem_dev {
17 unsigned int minor;
18 char *name;
19 umode_t mode;
20@@ -668,6 +669,23 @@
21 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops},
22 };
23
24+static void release_mem_dev(struct class_device *class_dev)
25+{
26+ kfree(class_dev);
27+}
28+
29+static struct class mem_class = {
30+ .name = "mem",
31+ .release = &release_mem_dev,
32+};
33+
34+static ssize_t show_dev(struct class_device *class_dev, char *buf)
35+{
36+ struct mem_dev *mem_dev = class_get_devdata(class_dev);
37+ return print_dev_t(buf, MKDEV(MEM_MAJOR, mem_dev->minor));
38+}
39+static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
40+
41 static int __init chr_dev_init(void)
42 {
43 int i;
44@@ -675,7 +693,20 @@
45 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
46 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
47
48+ class_register(&mem_class);
49 for (i = 0; i < ARRAY_SIZE(devlist); i++) {
50+ struct class_device *class_dev;
51+
52+ class_dev = kmalloc(sizeof(*class_dev), GFP_KERNEL);
53+ if (class_dev) {
54+ memset(class_dev, 0x00, sizeof(*class_dev));
55+ class_dev->class = &mem_class;
56+ strncpy(class_dev->class_id, devlist[i].name, BUS_ID_SIZE);
57+ class_set_devdata(class_dev, (void *)&devlist[i]);
58+ if (!class_device_register(class_dev));
59+ class_device_create_file(class_dev, &class_device_attr_dev);
60+ }
61+
62 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
63 S_IFCHR | devlist[i].mode, devlist[i].name);
64 }
65
This page took 0.190563 seconds and 4 git commands to generate.