1 diff -Nru a/drivers/base/Makefile b/drivers/base/Makefile
2 --- a/drivers/base/Makefile Thu Jan 15 11:05:59 2004
3 +++ b/drivers/base/Makefile Thu Jan 15 11:05:59 2004
5 # Makefile for the Linux device tree
7 obj-y := core.o sys.o interface.o bus.o \
8 - driver.o class.o platform.o \
9 + driver.o class.o class_simple.o platform.o \
10 cpu.o firmware.o init.o map.o
12 obj-$(CONFIG_FW_LOADER) += firmware_class.o
13 diff -Nru a/drivers/base/class.c b/drivers/base/class.c
14 --- a/drivers/base/class.c Thu Jan 15 11:06:02 2004
15 +++ b/drivers/base/class.c Thu Jan 15 11:06:02 2004
20 +static void class_release(struct kobject * kobj)
22 + struct class *class = to_class(kobj);
24 + pr_debug("class '%s': release.\n", class->name);
26 + if (class->class_release)
27 + class->class_release(class);
29 + pr_debug("class '%s' does not have a release() function, "
30 + "be careful\n", class->name);
33 static struct sysfs_ops class_sysfs_ops = {
34 .show = class_attr_show,
35 .store = class_attr_store,
38 static struct kobj_type ktype_class = {
39 .sysfs_ops = &class_sysfs_ops,
40 + .release = class_release,
43 /* Hotplug events for classes go to the class_obj subsys */
44 diff -Nru a/drivers/base/class_simple.c b/drivers/base/class_simple.c
45 --- /dev/null Wed Dec 31 16:00:00 1969
46 +++ b/drivers/base/class_simple.c Thu Jan 15 11:06:03 2004
49 + * class_simple.c - a "simple" interface for classes for simple char devices.
51 + * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
52 + * Copyright (c) 2003-2004 IBM Corp.
54 + * This file is released under the GPLv2
60 +#include <linux/device.h>
61 +#include <linux/kdev_t.h>
62 +#include <linux/err.h>
64 +struct class_simple {
65 + struct class_device_attribute attr;
68 +#define to_class_simple(d) container_of(d, struct class_simple, class)
71 + struct list_head node;
73 + struct class_device class_dev;
75 +#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
77 +static LIST_HEAD(simple_dev_list);
78 +static spinlock_t simple_dev_list_lock = SPIN_LOCK_UNLOCKED;
80 +static void release_simple_dev(struct class_device *class_dev)
82 + struct simple_dev *s_dev = to_simple_dev(class_dev);
86 +static ssize_t show_dev(struct class_device *class_dev, char *buf)
88 + struct simple_dev *s_dev = to_simple_dev(class_dev);
89 + return print_dev_t(buf, s_dev->dev);
92 +static void class_simple_release(struct class *class)
94 + struct class_simple *cs = to_class_simple(class);
99 + * class_simple_create - create a struct class_simple structure
100 + * @owner: pointer to the module that is to "own" this struct class_simple
101 + * @name: pointer to a string for the name of this class.
103 + * This is used to create a struct class_simple pointer that can then be used
104 + * in calls to class_simple_device_add(). This is used when you do not wish to
105 + * create a full blown class support for a type of char devices.
107 + * Note, the pointer created here is to be destroyed when finished by making a
108 + * call to class_simple_destroy().
110 +struct class_simple *class_simple_create(struct module *owner, char *name)
112 + struct class_simple *cs;
115 + cs = kmalloc(sizeof(*cs), GFP_KERNEL);
120 + memset(cs, 0x00, sizeof(*cs));
122 + cs->class.name = name;
123 + cs->class.class_release = class_simple_release;
124 + cs->class.release = release_simple_dev;
126 + cs->attr.attr.name = "dev";
127 + cs->attr.attr.mode = S_IRUGO;
128 + cs->attr.attr.owner = owner;
129 + cs->attr.show = show_dev;
130 + cs->attr.store = NULL;
132 + retval = class_register(&cs->class);
140 + return ERR_PTR(retval);
142 +EXPORT_SYMBOL(class_simple_create);
145 + * class_simple_destroy - destroys a struct class_simple structure
146 + * @cs: pointer to the struct class_simple that is to be destroyed
148 + * Note, the pointer to be destroyed must have been created with a call to
149 + * class_simple_create().
151 +void class_simple_destroy(struct class_simple *cs)
153 + if ((cs == NULL) || (IS_ERR(cs)))
156 + class_unregister(&cs->class);
158 +EXPORT_SYMBOL(class_simple_destroy);
161 + * class_simple_device_add - adds a class device to sysfs for a character driver
162 + * @cs: pointer to the struct class_simple that this device should be registered to.
163 + * @dev: the dev_t for the device to be added.
164 + * @device: a pointer to a struct device that is assiociated with this class device.
165 + * @fmt: string for the class device's name
167 + * This function can be used by simple char device classes that do not
168 + * implement their own class device registration. A struct class_device will
169 + * be created in sysfs, registered to the specified class. A "dev" file will
170 + * be created, showing the dev_t for the device. The pointer to the struct
171 + * class_device will be returned from the call. Any further sysfs files that
172 + * might be required can be created using this pointer.
173 + * Note: the struct class_device passed to this function must have previously been
174 + * created with a call to class_simple_create().
176 +struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
179 + struct simple_dev *s_dev = NULL;
182 + if ((cs == NULL) || (IS_ERR(cs))) {
187 + s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
192 + memset(s_dev, 0x00, sizeof(*s_dev));
195 + s_dev->class_dev.dev = device;
196 + s_dev->class_dev.class = &cs->class;
198 + va_start(args,fmt);
199 + vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
201 + retval = class_device_register(&s_dev->class_dev);
205 + class_device_create_file(&s_dev->class_dev, &cs->attr);
207 + spin_lock(&simple_dev_list_lock);
208 + list_add(&s_dev->node, &simple_dev_list);
209 + spin_unlock(&simple_dev_list_lock);
211 + return &s_dev->class_dev;
215 + return ERR_PTR(retval);
217 +EXPORT_SYMBOL(class_simple_device_add);
220 + * class_simple_device_remove - removes a class device that was created with class_simple_device_add()
221 + * @dev: the dev_t of the device that was previously registered.
223 + * This call unregisters and cleans up a class device that was created with a
224 + * call to class_device_simple_add()
226 +void class_simple_device_remove(dev_t dev)
228 + struct simple_dev *s_dev = NULL;
229 + struct list_head *tmp;
232 + spin_lock(&simple_dev_list_lock);
233 + list_for_each(tmp, &simple_dev_list) {
234 + s_dev = list_entry(tmp, struct simple_dev, node);
235 + if (s_dev->dev == dev) {
241 + list_del(&s_dev->node);
242 + spin_unlock(&simple_dev_list_lock);
243 + class_device_unregister(&s_dev->class_dev);
245 + spin_unlock(&simple_dev_list_lock);
248 +EXPORT_SYMBOL(class_simple_device_remove);
249 diff -Nru a/include/linux/device.h b/include/linux/device.h
250 --- a/include/linux/device.h Thu Jan 15 11:05:58 2004
251 +++ b/include/linux/device.h Thu Jan 15 11:05:58 2004
253 struct device_driver;
256 +struct class_simple;
261 int num_envp, char *buffer, int buffer_size);
263 void (*release)(struct class_device *dev);
264 + void (*class_release)(struct class *class);
267 extern int class_register(struct class *);
269 extern int class_interface_register(struct class_interface *);
270 extern void class_interface_unregister(struct class_interface *);
272 +/* interface for class simple stuff */
273 +extern struct class_simple *class_simple_create(struct module *owner, char *name);
274 +extern void class_simple_destroy(struct class_simple *cs);
275 +extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
276 + __attribute__((format(printf,4,5)));
277 +extern void class_simple_device_remove(dev_t dev);
281 struct list_head node; /* node in sibling list */
282 diff -Nru a/include/sound/core.h b/include/sound/core.h
283 --- a/include/sound/core.h Thu Jan 15 11:06:00 2004
284 +++ b/include/sound/core.h Thu Jan 15 11:06:00 2004
286 int shutdown; /* this card is going down */
287 wait_queue_head_t shutdown_sleep;
288 struct work_struct free_workq; /* for free in workqueue */
289 + struct device *dev;
292 int (*set_power_state) (snd_card_t *card, unsigned int state);
293 diff -Nru a/sound/core/sound.c b/sound/core/sound.c
294 --- a/sound/core/sound.c Thu Jan 15 11:05:49 2004
295 +++ b/sound/core/sound.c Thu Jan 15 11:05:49 2004
297 static int major = CONFIG_SND_MAJOR;
299 static int cards_limit = SNDRV_CARDS;
300 -#ifdef CONFIG_DEVFS_FS
301 static int device_mode = S_IFCHR | S_IRUGO | S_IWUGO;
304 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
305 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
308 static DECLARE_MUTEX(sound_mutex);
310 +extern struct class_simple *sound_class;
316 int minor = snd_kernel_minor(type, card, dev);
318 + struct device *device = NULL;
322 @@ -221,10 +221,14 @@
325 list_add_tail(&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]);
326 -#ifdef CONFIG_DEVFS_FS
327 - if (strncmp(name, "controlC", 8)) /* created in sound.c */
329 + if (strncmp(name, "controlC", 8)) { /* created in sound.c */
330 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
333 + device = card->dev;
334 + class_simple_device_add(sound_class, MKDEV(major, minor), device, name);
340 @@ -252,10 +256,12 @@
344 -#ifdef CONFIG_DEVFS_FS
345 - if (strncmp(mptr->name, "controlC", 8)) /* created in sound.c */
347 + if (strncmp(mptr->name, "controlC", 8)) { /* created in sound.c */
348 devfs_remove("snd/%s", mptr->name);
350 + class_simple_device_remove(MKDEV(major, minor));
353 list_del(&mptr->list);
358 static int __init alsa_sound_init(void)
360 -#ifdef CONFIG_DEVFS_FS
363 #ifdef CONFIG_SND_OSSEMUL
366 @@ -358,10 +362,10 @@
367 #ifdef CONFIG_SND_OSSEMUL
368 snd_info_minor_register();
370 -#ifdef CONFIG_DEVFS_FS
371 - for (controlnum = 0; controlnum < cards_limit; controlnum++)
372 + for (controlnum = 0; controlnum < cards_limit; controlnum++) {
373 devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
375 + class_simple_device_add(sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);
378 printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n");
384 - for (controlnum = 0; controlnum < cards_limit; controlnum++)
385 + for (controlnum = 0; controlnum < cards_limit; controlnum++) {
386 devfs_remove("snd/controlC%d", controlnum);
387 + class_simple_device_remove(MKDEV(major, controlnum<<5));
390 #ifdef CONFIG_SND_OSSEMUL
391 snd_info_minor_unregister();
392 diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
393 --- a/sound/pci/intel8x0.c Thu Jan 15 11:05:58 2004
394 +++ b/sound/pci/intel8x0.c Thu Jan 15 11:05:58 2004
395 @@ -2591,6 +2591,7 @@
399 + card->dev = &pci->dev;
401 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) {
403 diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
404 --- a/drivers/char/lp.c Thu Jan 15 12:13:07 2004
405 +++ b/drivers/char/lp.c Thu Jan 15 12:13:07 2004
407 struct lp_struct lp_table[LP_NO];
409 static unsigned int lp_count = 0;
410 +static struct class_simple *lp_class;
412 #ifdef CONFIG_LP_CONSOLE
413 static struct parport *console_registered; // initially NULL
418 + class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL,
420 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
426 devfs_mk_dir("printers");
427 + lp_class = class_simple_create(THIS_MODULE, "printer");
429 if (parport_register_driver (&lp_driver)) {
430 printk (KERN_ERR "lp: unable to register with parport\n");
433 parport_unregister_device(lp_table[offset].dev);
434 devfs_remove("printers/%d", offset);
435 + class_simple_device_remove(MKDEV(LP_MAJOR, offset));
437 devfs_remove("printers");
438 + class_simple_destroy(lp_class);
441 __setup("lp=", lp_setup);
442 diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
443 --- a/drivers/char/misc.c Thu Jan 15 11:05:56 2004
444 +++ b/drivers/char/misc.c Thu Jan 15 11:05:56 2004
446 #include <linux/devfs_fs_kernel.h>
447 #include <linux/stat.h>
448 #include <linux/init.h>
450 +#include <linux/device.h>
451 #include <linux/tty.h>
452 #include <linux/kmod.h>
460 + * - add a struct class_device to struct miscdevice and make all usages of
463 +static struct class_simple *misc_class;
465 static struct file_operations misc_fops = {
466 .owner = THIS_MODULE,
469 "misc/%s", misc->name);
472 + class_simple_device_add(misc_class, MKDEV(MISC_MAJOR, misc->minor),
473 + misc->dev, misc->name);
474 devfs_mk_cdev(MKDEV(MISC_MAJOR, misc->minor),
475 S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, misc->devfs_name);
480 list_del(&misc->list);
481 + class_simple_device_remove(MKDEV(MISC_MAJOR, misc->minor));
482 devfs_remove(misc->devfs_name);
483 if (i < DYNAMIC_MINORS && i>0) {
484 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
487 ent->proc_fops = &misc_proc_fops;
489 + misc_class = class_simple_create(THIS_MODULE, "misc");
490 + if (IS_ERR(misc_class))
491 + return PTR_ERR(misc_class);
492 #ifdef CONFIG_MVME16x
499 -module_init(misc_init);
500 +subsys_initcall(misc_init);
501 diff -Nru a/include/linux/miscdevice.h b/include/linux/miscdevice.h
502 --- a/include/linux/miscdevice.h Thu Jan 15 11:05:53 2004
503 +++ b/include/linux/miscdevice.h Thu Jan 15 11:05:53 2004
506 #define TUN_MINOR 200
514 struct file_operations *fops;
515 struct list_head list;
516 + struct device *dev;
520 This adds class/raw/ support for all raw devices. It also provides a
521 symlink to the block device that the raw device is mapped to. For
524 $ tree /sys/class/raw/
528 | `-- device -> ../../../block/sda
531 | `-- device -> ../../../block/sda/sda2
536 Note, in order to get that symlink, I had to export get_gendisk() so that
537 modules can use it. I hope this is ok with everyone.
539 This is based on a patch originally written by
540 Leann Ogasawara <ogasawara@osdl.org>
544 diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
545 --- a/drivers/block/genhd.c Thu Jan 15 11:05:57 2004
546 +++ b/drivers/block/genhd.c Thu Jan 15 11:05:57 2004
548 return kobj ? to_disk(kobj) : NULL;
551 +EXPORT_SYMBOL(get_gendisk);
553 #ifdef CONFIG_PROC_FS
555 static void *part_start(struct seq_file *part, loff_t *pos)
556 diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
557 --- a/drivers/char/raw.c Thu Jan 15 11:05:47 2004
558 +++ b/drivers/char/raw.c Thu Jan 15 11:05:47 2004
560 #include <linux/raw.h>
561 #include <linux/capability.h>
562 #include <linux/uio.h>
563 +#include <linux/device.h>
564 +#include <linux/genhd.h>
566 #include <asm/uaccess.h>
572 +static struct class_simple *raw_class;
573 static struct raw_device_data raw_devices[MAX_RAW_MINORS];
574 static DECLARE_MUTEX(raw_mutex);
575 static struct file_operations raw_ctl_fops; /* forward declaration */
577 return ioctl_by_bdev(bdev, command, arg);
580 +static void bind_device(struct raw_config_request rq)
583 + struct gendisk *gen;
584 + struct class_device *dev;
585 + struct kobject *target = NULL;
587 + gen = get_gendisk(MKDEV(rq.block_major, rq.block_minor), &part);
589 + if (part && gen->part[part])
590 + target = &gen->part[part]->kobj;
592 + target = &gen->kobj;
595 + class_simple_device_remove(MKDEV(RAW_MAJOR, rq.raw_minor));
596 + dev = class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, rq.raw_minor),
597 + NULL, "raw%d", rq.raw_minor);
598 + if (dev && target) {
599 + sysfs_create_link(&dev->kobj, target, "device");
604 * Deal with ioctls against the raw-device control interface, to bind
605 * and unbind other raw devices.
606 @@ -187,12 +213,15 @@
607 if (rq.block_major == 0 && rq.block_minor == 0) {
609 rawdev->binding = NULL;
610 + class_simple_device_remove(MKDEV(RAW_MAJOR, rq.raw_minor));
612 rawdev->binding = bdget(dev);
613 if (rawdev->binding == NULL)
617 __module_get(THIS_MODULE);
626 register_chrdev(RAW_MAJOR, "raw", &raw_fops);
628 + raw_class = class_simple_create(THIS_MODULE, "raw");
629 + if (IS_ERR(raw_class)) {
630 + printk (KERN_ERR "Error creating raw class.\n");
631 + return PTR_ERR(raw_class);
633 + class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
635 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
636 S_IFCHR | S_IRUGO | S_IWUGO,
639 devfs_remove("raw/raw%d", i);
640 devfs_remove("raw/rawctl");
642 + class_simple_device_remove(MKDEV(RAW_MAJOR, 0));
643 + class_simple_destroy(raw_class);
644 unregister_chrdev(RAW_MAJOR, "raw");
647 diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
648 --- a/sound/oss/soundcard.c Thu Jan 15 11:06:01 2004
649 +++ b/sound/oss/soundcard.c Thu Jan 15 11:06:01 2004
653 unsigned long seq_time = 0; /* Time for /dev/sequencer */
654 +extern struct class_simple *sound_class;
657 * Table for configurable mixer volume handling
659 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
660 S_IFCHR | dev_list[i].mode,
661 "sound/%s", dev_list[i].name);
662 + class_simple_device_add(sound_class,
663 + MKDEV(SOUND_MAJOR, dev_list[i].minor),
664 + NULL, "%s", dev_list[i].name);
666 if (!dev_list[i].num)
669 dev_list[i].minor + (j*0x10)),
670 S_IFCHR | dev_list[i].mode,
671 "sound/%s%d", dev_list[i].name, j);
672 + class_simple_device_add(sound_class,
673 + MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
675 + "%s%d", dev_list[i].name, j);
679 @@ -593,10 +601,13 @@
681 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
682 devfs_remove("sound/%s", dev_list[i].name);
683 + class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor));
684 if (!dev_list[i].num)
686 - for (j = 1; j < *dev_list[i].num; j++)
687 + for (j = 1; j < *dev_list[i].num; j++) {
688 devfs_remove("sound/%s%d", dev_list[i].name, j);
689 + class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
693 unregister_sound_special(1);
694 diff -Nru a/sound/sound_core.c b/sound/sound_core.c
695 --- a/sound/sound_core.c Thu Jan 15 11:05:56 2004
696 +++ b/sound/sound_core.c Thu Jan 15 11:05:56 2004
698 extern int msnd_pinnacle_init(void);
701 +struct class_simple *sound_class;
702 +EXPORT_SYMBOL(sound_class);
705 * Low level list operator. Scan the ordered list, find a hole and
706 * join into it. Called with the lock asserted
709 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
710 S_IFCHR | mode, s->name);
711 + class_simple_device_add(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
717 spin_unlock(&sound_loader_lock);
719 devfs_remove(p->name);
720 + class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor));
726 unregister_chrdev(SOUND_MAJOR, "sound");
727 devfs_remove("sound");
728 + class_simple_destroy(sound_class);
731 static int __init init_soundcore(void)
735 devfs_mk_dir ("sound");
736 + sound_class = class_simple_create(THIS_MODULE, "sound");
737 + if (IS_ERR(sound_class))
738 + return PTR_ERR(sound_class);
742 diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
743 --- a/drivers/char/tty_io.c Thu Jan 15 11:05:50 2004
744 +++ b/drivers/char/tty_io.c Thu Jan 15 11:05:50 2004
745 @@ -2069,79 +2069,7 @@
746 tty->driver->write(tty, 0, &ch, 1);
750 - struct list_head node;
752 - struct class_device class_dev;
754 -#define to_tty_dev(d) container_of(d, struct tty_dev, class_dev)
756 -static void release_tty_dev(struct class_device *class_dev)
758 - struct tty_dev *tty_dev = to_tty_dev(class_dev);
762 -static struct class tty_class = {
764 - .release = &release_tty_dev,
767 -static LIST_HEAD(tty_dev_list);
768 -static spinlock_t tty_dev_list_lock = SPIN_LOCK_UNLOCKED;
770 -static ssize_t show_dev(struct class_device *class_dev, char *buf)
772 - struct tty_dev *tty_dev = to_tty_dev(class_dev);
773 - return print_dev_t(buf, tty_dev->dev);
775 -static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
777 -static void tty_add_class_device(char *name, dev_t dev, struct device *device)
779 - struct tty_dev *tty_dev = NULL;
782 - tty_dev = kmalloc(sizeof(*tty_dev), GFP_KERNEL);
785 - memset(tty_dev, 0x00, sizeof(*tty_dev));
787 - tty_dev->class_dev.dev = device;
788 - tty_dev->class_dev.class = &tty_class;
789 - snprintf(tty_dev->class_dev.class_id, BUS_ID_SIZE, "%s", name);
790 - retval = class_device_register(&tty_dev->class_dev);
793 - class_device_create_file (&tty_dev->class_dev, &class_device_attr_dev);
794 - tty_dev->dev = dev;
795 - spin_lock(&tty_dev_list_lock);
796 - list_add(&tty_dev->node, &tty_dev_list);
797 - spin_unlock(&tty_dev_list_lock);
803 -static void tty_remove_class_device(dev_t dev)
805 - struct tty_dev *tty_dev = NULL;
806 - struct list_head *tmp;
809 - spin_lock(&tty_dev_list_lock);
810 - list_for_each (tmp, &tty_dev_list) {
811 - tty_dev = list_entry(tmp, struct tty_dev, node);
812 - if (tty_dev->dev == dev) {
813 - list_del(&tty_dev->node);
818 - spin_unlock(&tty_dev_list_lock);
820 - class_device_unregister(&tty_dev->class_dev);
822 +static struct class_simple *tty_class;
825 * tty_register_device - register a tty device
826 @@ -2174,7 +2102,7 @@
827 if (driver->type != TTY_DRIVER_TYPE_PTY) {
829 tty_line_name(driver, index, name);
830 - tty_add_class_device(name, dev, device);
831 + class_simple_device_add(tty_class, dev, device, name);
835 @@ -2189,7 +2117,7 @@
836 void tty_unregister_device(struct tty_driver *driver, unsigned index)
838 devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
839 - tty_remove_class_device(MKDEV(driver->major, driver->minor_start) + index);
840 + class_simple_device_remove(MKDEV(driver->major, driver->minor_start) + index);
843 EXPORT_SYMBOL(tty_register_device);
844 @@ -2406,7 +2334,10 @@
846 static int __init tty_class_init(void)
848 - return class_register(&tty_class);
849 + tty_class = class_simple_create(THIS_MODULE, "tty");
850 + if (IS_ERR(tty_class))
851 + return PTR_ERR(tty_class);
855 postcore_initcall(tty_class_init);
856 @@ -2431,7 +2362,7 @@
857 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
858 panic("Couldn't register /dev/tty driver\n");
859 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
860 - tty_add_class_device ("tty", MKDEV(TTYAUX_MAJOR, 0), NULL);
861 + class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
863 strcpy(console_cdev.kobj.name, "dev.console");
864 cdev_init(&console_cdev, &console_fops);
865 @@ -2439,7 +2370,7 @@
866 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
867 panic("Couldn't register /dev/console driver\n");
868 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
869 - tty_add_class_device ("console", MKDEV(TTYAUX_MAJOR, 1), NULL);
870 + class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
872 tty_kobj.kset = tty_cdev.kobj.kset;
873 kobject_register(&tty_kobj);
874 @@ -2451,7 +2382,7 @@
875 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
876 panic("Couldn't register /dev/ptmx driver\n");
877 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
878 - tty_add_class_device ("ptmx", MKDEV(TTYAUX_MAJOR, 2), NULL);
879 + class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
883 @@ -2461,7 +2392,7 @@
884 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
885 panic("Couldn't register /dev/tty0 driver\n");
886 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
887 - tty_add_class_device ("tty0", MKDEV(TTY_MAJOR, 0), NULL);
888 + class_simple_device_add(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
892 diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
893 --- a/drivers/char/vc_screen.c Thu Jan 15 11:05:48 2004
894 +++ b/drivers/char/vc_screen.c Thu Jan 15 11:05:48 2004
896 #include <linux/kbd_kern.h>
897 #include <linux/console.h>
898 #include <linux/smp_lock.h>
899 +#include <linux/device.h>
900 #include <asm/uaccess.h>
901 #include <asm/byteorder.h>
902 #include <asm/unaligned.h>
907 +static struct class_simple *vc_class;
909 void vcs_make_devfs(struct tty_struct *tty)
911 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 1),
912 @@ -477,19 +480,26 @@
913 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
914 S_IFCHR|S_IRUSR|S_IWUSR,
915 "vcc/a%u", tty->index + 1);
916 + class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
917 + class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
919 void vcs_remove_devfs(struct tty_struct *tty)
921 devfs_remove("vcc/%u", tty->index + 1);
922 devfs_remove("vcc/a%u", tty->index + 1);
923 + class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 1));
924 + class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 129));
927 int __init vcs_init(void)
929 if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
930 panic("unable to get major %d for vcs device", VCS_MAJOR);
931 + vc_class = class_simple_create(THIS_MODULE, "vc");
933 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
934 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
935 + class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
936 + class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
939 diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c
940 --- a/drivers/char/vt.c Thu Jan 15 11:05:50 2004
941 +++ b/drivers/char/vt.c Thu Jan 15 11:05:50 2004
942 @@ -2539,6 +2539,8 @@
944 int __init vty_init(void)
948 console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
950 panic("Couldn't allocate console driver\n");
951 @@ -2566,7 +2568,6 @@
952 #ifdef CONFIG_FRAMEBUFFER_CONSOLE