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
4 #include <linux/smp_lock.h>
5 #include <linux/devfs_fs_kernel.h>
6 #include <linux/ptrace.h>
7 +#include <linux/device.h>
9 #include <asm/uaccess.h>
12 .open = memory_open, /* just a selector for the real open */
15 -static const struct {
16 +static const struct mem_dev {
21 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops},
24 +static void release_mem_dev(struct class_device *class_dev)
29 +static struct class mem_class = {
31 + .release = &release_mem_dev,
34 +static ssize_t show_dev(struct class_device *class_dev, char *buf)
36 + struct mem_dev *mem_dev = class_get_devdata(class_dev);
37 + return print_dev_t(buf, MKDEV(MEM_MAJOR, mem_dev->minor));
39 +static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
41 static int __init chr_dev_init(void)
45 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
46 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
48 + class_register(&mem_class);
49 for (i = 0; i < ARRAY_SIZE(devlist); i++) {
50 + struct class_device *class_dev;
52 + class_dev = kmalloc(sizeof(*class_dev), GFP_KERNEL);
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);
62 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
63 S_IFCHR | devlist[i].mode, devlist[i].name);