diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-08-08 01:19:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-01 17:51:59 -0500 |
commit | 01107d343076c34b9e1ce5d073292bd7f3097fda (patch) | |
tree | 075dcadaff7c124022157c8ee819550cd1023440 | |
parent | 94fbcded4ea0dc14cbfb222a5c68372f150d1476 (diff) |
Driver core: convert tty core to use struct device
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>
-rw-r--r-- | drivers/char/tty_io.c | 19 | ||||
-rw-r--r-- | drivers/isdn/gigaset/common.c | 2 | ||||
-rw-r--r-- | drivers/isdn/gigaset/gigaset.h | 2 | ||||
-rw-r--r-- | drivers/isdn/gigaset/interface.c | 10 | ||||
-rw-r--r-- | drivers/isdn/gigaset/proc.c | 19 | ||||
-rw-r--r-- | include/linux/tty.h | 5 |
6 files changed, 29 insertions, 28 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e90ea39c7c4b..50dc49205a23 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -3612,7 +3612,8 @@ static struct class *tty_class; | |||
3612 | * This field is optional, if there is no known struct device | 3612 | * This field is optional, if there is no known struct device |
3613 | * for this tty device it can be set to NULL safely. | 3613 | * for this tty device it can be set to NULL safely. |
3614 | * | 3614 | * |
3615 | * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). | 3615 | * Returns a pointer to the struct device for this tty device |
3616 | * (or ERR_PTR(-EFOO) on error). | ||
3616 | * | 3617 | * |
3617 | * This call is required to be made to register an individual tty device | 3618 | * This call is required to be made to register an individual tty device |
3618 | * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If | 3619 | * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If |
@@ -3622,8 +3623,8 @@ static struct class *tty_class; | |||
3622 | * Locking: ?? | 3623 | * Locking: ?? |
3623 | */ | 3624 | */ |
3624 | 3625 | ||
3625 | struct class_device *tty_register_device(struct tty_driver *driver, | 3626 | struct device *tty_register_device(struct tty_driver *driver, unsigned index, |
3626 | unsigned index, struct device *device) | 3627 | struct device *device) |
3627 | { | 3628 | { |
3628 | char name[64]; | 3629 | char name[64]; |
3629 | dev_t dev = MKDEV(driver->major, driver->minor_start) + index; | 3630 | dev_t dev = MKDEV(driver->major, driver->minor_start) + index; |
@@ -3639,7 +3640,7 @@ struct class_device *tty_register_device(struct tty_driver *driver, | |||
3639 | else | 3640 | else |
3640 | tty_line_name(driver, index, name); | 3641 | tty_line_name(driver, index, name); |
3641 | 3642 | ||
3642 | return class_device_create(tty_class, NULL, dev, device, "%s", name); | 3643 | return device_create(tty_class, device, dev, name); |
3643 | } | 3644 | } |
3644 | 3645 | ||
3645 | /** | 3646 | /** |
@@ -3655,7 +3656,7 @@ struct class_device *tty_register_device(struct tty_driver *driver, | |||
3655 | 3656 | ||
3656 | void tty_unregister_device(struct tty_driver *driver, unsigned index) | 3657 | void tty_unregister_device(struct tty_driver *driver, unsigned index) |
3657 | { | 3658 | { |
3658 | class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); | 3659 | device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); |
3659 | } | 3660 | } |
3660 | 3661 | ||
3661 | EXPORT_SYMBOL(tty_register_device); | 3662 | EXPORT_SYMBOL(tty_register_device); |
@@ -3895,20 +3896,20 @@ static int __init tty_init(void) | |||
3895 | if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || | 3896 | if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || |
3896 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) | 3897 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) |
3897 | panic("Couldn't register /dev/tty driver\n"); | 3898 | panic("Couldn't register /dev/tty driver\n"); |
3898 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); | 3899 | device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty"); |
3899 | 3900 | ||
3900 | cdev_init(&console_cdev, &console_fops); | 3901 | cdev_init(&console_cdev, &console_fops); |
3901 | if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || | 3902 | if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || |
3902 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) | 3903 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) |
3903 | panic("Couldn't register /dev/console driver\n"); | 3904 | panic("Couldn't register /dev/console driver\n"); |
3904 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); | 3905 | device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console"); |
3905 | 3906 | ||
3906 | #ifdef CONFIG_UNIX98_PTYS | 3907 | #ifdef CONFIG_UNIX98_PTYS |
3907 | cdev_init(&ptmx_cdev, &ptmx_fops); | 3908 | cdev_init(&ptmx_cdev, &ptmx_fops); |
3908 | if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || | 3909 | if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || |
3909 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) | 3910 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) |
3910 | panic("Couldn't register /dev/ptmx driver\n"); | 3911 | panic("Couldn't register /dev/ptmx driver\n"); |
3911 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); | 3912 | device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx"); |
3912 | #endif | 3913 | #endif |
3913 | 3914 | ||
3914 | #ifdef CONFIG_VT | 3915 | #ifdef CONFIG_VT |
@@ -3916,7 +3917,7 @@ static int __init tty_init(void) | |||
3916 | if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || | 3917 | if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || |
3917 | register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) | 3918 | register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) |
3918 | panic("Couldn't register /dev/tty0 driver\n"); | 3919 | panic("Couldn't register /dev/tty0 driver\n"); |
3919 | class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); | 3920 | device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0"); |
3920 | 3921 | ||
3921 | vty_init(); | 3922 | vty_init(); |
3922 | #endif | 3923 | #endif |
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 5800beeebb85..defd5743dba6 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
702 | cs->open_count = 0; | 702 | cs->open_count = 0; |
703 | cs->dev = NULL; | 703 | cs->dev = NULL; |
704 | cs->tty = NULL; | 704 | cs->tty = NULL; |
705 | cs->class = NULL; | 705 | cs->tty_dev = NULL; |
706 | cs->cidmode = cidmode != 0; | 706 | cs->cidmode = cidmode != 0; |
707 | 707 | ||
708 | //if(onechannel) { //FIXME | 708 | //if(onechannel) { //FIXME |
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 884bd72c1bf4..06298cc52bf5 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -444,7 +444,7 @@ struct cardstate { | |||
444 | struct gigaset_driver *driver; | 444 | struct gigaset_driver *driver; |
445 | unsigned minor_index; | 445 | unsigned minor_index; |
446 | struct device *dev; | 446 | struct device *dev; |
447 | struct class_device *class; | 447 | struct device *tty_dev; |
448 | 448 | ||
449 | const struct gigaset_ops *ops; | 449 | const struct gigaset_ops *ops; |
450 | 450 | ||
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 596f3aebe2f7..7edea015867e 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c | |||
@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs) | |||
625 | return; | 625 | return; |
626 | 626 | ||
627 | tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); | 627 | tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); |
628 | cs->class = tty_register_device(drv->tty, cs->minor_index, NULL); | 628 | cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL); |
629 | 629 | ||
630 | if (!IS_ERR(cs->class)) | 630 | if (!IS_ERR(cs->tty_dev)) |
631 | class_set_devdata(cs->class, cs); | 631 | dev_set_drvdata(cs->tty_dev, cs); |
632 | else { | 632 | else { |
633 | warn("could not register device to the tty subsystem"); | 633 | warn("could not register device to the tty subsystem"); |
634 | cs->class = NULL; | 634 | cs->tty_dev = NULL; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
@@ -645,7 +645,7 @@ void gigaset_if_free(struct cardstate *cs) | |||
645 | 645 | ||
646 | tasklet_disable(&cs->if_wake_tasklet); | 646 | tasklet_disable(&cs->if_wake_tasklet); |
647 | tasklet_kill(&cs->if_wake_tasklet); | 647 | tasklet_kill(&cs->if_wake_tasklet); |
648 | cs->class = NULL; | 648 | cs->tty_dev = NULL; |
649 | tty_unregister_device(drv->tty, cs->minor_index); | 649 | tty_unregister_device(drv->tty, cs->minor_index); |
650 | } | 650 | } |
651 | 651 | ||
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index 9ad840e95dbe..e767afa55abf 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c | |||
@@ -16,11 +16,12 @@ | |||
16 | #include "gigaset.h" | 16 | #include "gigaset.h" |
17 | #include <linux/ctype.h> | 17 | #include <linux/ctype.h> |
18 | 18 | ||
19 | static ssize_t show_cidmode(struct class_device *class, char *buf) | 19 | static ssize_t show_cidmode(struct device *dev, |
20 | struct device_attribute *attr, char *buf) | ||
20 | { | 21 | { |
21 | int ret; | 22 | int ret; |
22 | unsigned long flags; | 23 | unsigned long flags; |
23 | struct cardstate *cs = class_get_devdata(class); | 24 | struct cardstate *cs = dev_get_drvdata(dev); |
24 | 25 | ||
25 | spin_lock_irqsave(&cs->lock, flags); | 26 | spin_lock_irqsave(&cs->lock, flags); |
26 | ret = sprintf(buf, "%u\n", cs->cidmode); | 27 | ret = sprintf(buf, "%u\n", cs->cidmode); |
@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf) | |||
29 | return ret; | 30 | return ret; |
30 | } | 31 | } |
31 | 32 | ||
32 | static ssize_t set_cidmode(struct class_device *class, | 33 | static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, |
33 | const char *buf, size_t count) | 34 | const char *buf, size_t count) |
34 | { | 35 | { |
35 | struct cardstate *cs = class_get_devdata(class); | 36 | struct cardstate *cs = dev_get_drvdata(dev); |
36 | long int value; | 37 | long int value; |
37 | char *end; | 38 | char *end; |
38 | 39 | ||
@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class, | |||
64 | return count; | 65 | return count; |
65 | } | 66 | } |
66 | 67 | ||
67 | static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); | 68 | static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); |
68 | 69 | ||
69 | /* free sysfs for device */ | 70 | /* free sysfs for device */ |
70 | void gigaset_free_dev_sysfs(struct cardstate *cs) | 71 | void gigaset_free_dev_sysfs(struct cardstate *cs) |
71 | { | 72 | { |
72 | if (!cs->class) | 73 | if (!cs->tty_dev) |
73 | return; | 74 | return; |
74 | 75 | ||
75 | gig_dbg(DEBUG_INIT, "removing sysfs entries"); | 76 | gig_dbg(DEBUG_INIT, "removing sysfs entries"); |
76 | class_device_remove_file(cs->class, &class_device_attr_cidmode); | 77 | device_remove_file(cs->tty_dev, &dev_attr_cidmode); |
77 | } | 78 | } |
78 | 79 | ||
79 | /* initialize sysfs for device */ | 80 | /* initialize sysfs for device */ |
80 | void gigaset_init_dev_sysfs(struct cardstate *cs) | 81 | void gigaset_init_dev_sysfs(struct cardstate *cs) |
81 | { | 82 | { |
82 | if (!cs->class) | 83 | if (!cs->tty_dev) |
83 | return; | 84 | return; |
84 | 85 | ||
85 | gig_dbg(DEBUG_INIT, "setting up sysfs"); | 86 | gig_dbg(DEBUG_INIT, "setting up sysfs"); |
86 | if (class_device_create_file(cs->class, &class_device_attr_cidmode)) | 87 | if (device_create_file(cs->tty_dev, &dev_attr_cidmode)) |
87 | dev_err(cs->dev, "could not create sysfs attribute\n"); | 88 | dev_err(cs->dev, "could not create sysfs attribute\n"); |
88 | } | 89 | } |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 44091c0db0b4..65321f911c1e 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -276,9 +276,8 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); | |||
276 | extern int tty_unregister_ldisc(int disc); | 276 | extern int tty_unregister_ldisc(int disc); |
277 | extern int tty_register_driver(struct tty_driver *driver); | 277 | extern int tty_register_driver(struct tty_driver *driver); |
278 | extern int tty_unregister_driver(struct tty_driver *driver); | 278 | extern int tty_unregister_driver(struct tty_driver *driver); |
279 | extern struct class_device *tty_register_device(struct tty_driver *driver, | 279 | extern struct device *tty_register_device(struct tty_driver *driver, |
280 | unsigned index, | 280 | unsigned index, struct device *dev); |
281 | struct device *dev); | ||
282 | extern void tty_unregister_device(struct tty_driver *driver, unsigned index); | 281 | extern void tty_unregister_device(struct tty_driver *driver, unsigned index); |
283 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, | 282 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, |
284 | int buflen); | 283 | int buflen); |