Driver core: convert tty core to use struct device
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 8 Aug 2006 05:19:37 +0000 (22:19 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 1 Dec 2006 22:51:59 +0000 (14:51 -0800)
Converts from using struct "class_device" to "struct device" making
everything show up properly in /sys/devices/ with symlinks from the
/sys/class directory.

Also fixes up the isdn drivers that were putting something in the class
device's directory.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/tty_io.c
drivers/isdn/gigaset/common.c
drivers/isdn/gigaset/gigaset.h
drivers/isdn/gigaset/interface.c
drivers/isdn/gigaset/proc.c
include/linux/tty.h

index e90ea39c7c4b1112fd7d7db878b96d8531a0f162..50dc49205a231a2c5854a0e9699e39e5db9e6bed 100644 (file)
@@ -3612,7 +3612,8 @@ static struct class *tty_class;
  *             This field is optional, if there is no known struct device
  *             for this tty device it can be set to NULL safely.
  *
- *     Returns a pointer to the class device (or ERR_PTR(-EFOO) on error).
+ *     Returns a pointer to the struct device for this tty device
+ *     (or ERR_PTR(-EFOO) on error).
  *
  *     This call is required to be made to register an individual tty device
  *     if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set.  If
@@ -3622,8 +3623,8 @@ static struct class *tty_class;
  *     Locking: ??
  */
 
-struct class_device *tty_register_device(struct tty_driver *driver,
-                                        unsigned index, struct device *device)
+struct device *tty_register_device(struct tty_driver *driver, unsigned index,
+                                  struct device *device)
 {
        char name[64];
        dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -3639,7 +3640,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
        else
                tty_line_name(driver, index, name);
 
-       return class_device_create(tty_class, NULL, dev, device, "%s", name);
+       return device_create(tty_class, device, dev, name);
 }
 
 /**
@@ -3655,7 +3656,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
 
 void tty_unregister_device(struct tty_driver *driver, unsigned index)
 {
-       class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
+       device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
 }
 
 EXPORT_SYMBOL(tty_register_device);
@@ -3895,20 +3896,20 @@ static int __init tty_init(void)
        if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
                panic("Couldn't register /dev/tty driver\n");
-       class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
+       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
 
        cdev_init(&console_cdev, &console_fops);
        if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
                panic("Couldn't register /dev/console driver\n");
-       class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
+       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
 
 #ifdef CONFIG_UNIX98_PTYS
        cdev_init(&ptmx_cdev, &ptmx_fops);
        if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
                panic("Couldn't register /dev/ptmx driver\n");
-       class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
+       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
 #endif
 
 #ifdef CONFIG_VT
@@ -3916,7 +3917,7 @@ static int __init tty_init(void)
        if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
                panic("Couldn't register /dev/tty0 driver\n");
-       class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
+       device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
 
        vty_init();
 #endif
index 5800beeebb8589f0d5cac5d2cbd414c1fa8b359e..defd5743dba6c7d0626cb4e165159f2ffe2756ed 100644 (file)
@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
        cs->open_count = 0;
        cs->dev = NULL;
        cs->tty = NULL;
-       cs->class = NULL;
+       cs->tty_dev = NULL;
        cs->cidmode = cidmode != 0;
 
        //if(onechannel) { //FIXME
index 884bd72c1bf47fa9b5c8656a14f025d3f13eeeb8..06298cc52bf5bd7e52caaa9c503be27d3137f767 100644 (file)
@@ -444,7 +444,7 @@ struct cardstate {
        struct gigaset_driver *driver;
        unsigned minor_index;
        struct device *dev;
-       struct class_device *class;
+       struct device *tty_dev;
 
        const struct gigaset_ops *ops;
 
index 596f3aebe2f7748c553aa50c860866aa8e37b205..7edea015867e8c7cd1ccca220d3549372dc67977 100644 (file)
@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs)
                return;
 
        tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
-       cs->class = tty_register_device(drv->tty, cs->minor_index, NULL);
+       cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL);
 
-       if (!IS_ERR(cs->class))
-               class_set_devdata(cs->class, cs);
+       if (!IS_ERR(cs->tty_dev))
+               dev_set_drvdata(cs->tty_dev, cs);
        else {
                warn("could not register device to the tty subsystem");
-               cs->class = NULL;
+               cs->tty_dev = NULL;
        }
 }
 
@@ -645,7 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
 
        tasklet_disable(&cs->if_wake_tasklet);
        tasklet_kill(&cs->if_wake_tasklet);
-       cs->class = NULL;
+       cs->tty_dev = NULL;
        tty_unregister_device(drv->tty, cs->minor_index);
 }
 
index 9ad840e95dbe8247928b6191fcedcac8fe2ab63b..e767afa55abfa5cf6b0ee8a3dd25d46893ee15b4 100644 (file)
 #include "gigaset.h"
 #include <linux/ctype.h>
 
-static ssize_t show_cidmode(struct class_device *class, char *buf)
+static ssize_t show_cidmode(struct device *dev,
+                           struct device_attribute *attr, char *buf)
 {
        int ret;
        unsigned long flags;
-       struct cardstate *cs = class_get_devdata(class);
+       struct cardstate *cs = dev_get_drvdata(dev);
 
        spin_lock_irqsave(&cs->lock, flags);
        ret = sprintf(buf, "%u\n", cs->cidmode);
@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf)
        return ret;
 }
 
-static ssize_t set_cidmode(struct class_device *class,
+static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
                           const char *buf, size_t count)
 {
-       struct cardstate *cs = class_get_devdata(class);
+       struct cardstate *cs = dev_get_drvdata(dev);
        long int value;
        char *end;
 
@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class,
        return count;
 }
 
-static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
+static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
 
 /* free sysfs for device */
 void gigaset_free_dev_sysfs(struct cardstate *cs)
 {
-       if (!cs->class)
+       if (!cs->tty_dev)
                return;
 
        gig_dbg(DEBUG_INIT, "removing sysfs entries");
-       class_device_remove_file(cs->class, &class_device_attr_cidmode);
+       device_remove_file(cs->tty_dev, &dev_attr_cidmode);
 }
 
 /* initialize sysfs for device */
 void gigaset_init_dev_sysfs(struct cardstate *cs)
 {
-       if (!cs->class)
+       if (!cs->tty_dev)
                return;
 
        gig_dbg(DEBUG_INIT, "setting up sysfs");
-       if (class_device_create_file(cs->class, &class_device_attr_cidmode))
+       if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
                dev_err(cs->dev, "could not create sysfs attribute\n");
 }
index 44091c0db0b46b473234172a91d983319648e7ce..65321f911c1e4be2769e9c8417dd919140446e90 100644 (file)
@@ -276,9 +276,8 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
 extern int tty_unregister_ldisc(int disc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
-extern struct class_device *tty_register_device(struct tty_driver *driver,
-                                               unsigned index,
-                                               struct device *dev);
+extern struct device *tty_register_device(struct tty_driver *driver,
+                                         unsigned index, struct device *dev);
 extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
                             int buflen);