Commit 01107d34 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 94fbcded
...@@ -3612,7 +3612,8 @@ static struct class *tty_class; ...@@ -3612,7 +3612,8 @@ static struct class *tty_class;
* This field is optional, if there is no known struct device * This field is optional, if there is no known struct device
* for this tty device it can be set to NULL safely. * 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 * 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 * 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,8 +3623,8 @@ static struct class *tty_class;
* Locking: ?? * Locking: ??
*/ */
struct class_device *tty_register_device(struct tty_driver *driver, struct device *tty_register_device(struct tty_driver *driver, unsigned index,
unsigned index, struct device *device) struct device *device)
{ {
char name[64]; char name[64];
dev_t dev = MKDEV(driver->major, driver->minor_start) + index; 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,7 +3640,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
else else
tty_line_name(driver, index, name); 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, ...@@ -3655,7 +3656,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
void tty_unregister_device(struct tty_driver *driver, unsigned index) 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); EXPORT_SYMBOL(tty_register_device);
...@@ -3895,20 +3896,20 @@ static int __init tty_init(void) ...@@ -3895,20 +3896,20 @@ static int __init tty_init(void)
if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
panic("Couldn't register /dev/tty driver\n"); 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); cdev_init(&console_cdev, &console_fops);
if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
panic("Couldn't register /dev/console driver\n"); 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 #ifdef CONFIG_UNIX98_PTYS
cdev_init(&ptmx_cdev, &ptmx_fops); cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
panic("Couldn't register /dev/ptmx driver\n"); 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 #endif
#ifdef CONFIG_VT #ifdef CONFIG_VT
...@@ -3916,7 +3917,7 @@ static int __init tty_init(void) ...@@ -3916,7 +3917,7 @@ static int __init tty_init(void)
if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
panic("Couldn't register /dev/tty0 driver\n"); 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(); vty_init();
#endif #endif
......
...@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->open_count = 0; cs->open_count = 0;
cs->dev = NULL; cs->dev = NULL;
cs->tty = NULL; cs->tty = NULL;
cs->class = NULL; cs->tty_dev = NULL;
cs->cidmode = cidmode != 0; cs->cidmode = cidmode != 0;
//if(onechannel) { //FIXME //if(onechannel) { //FIXME
......
...@@ -444,7 +444,7 @@ struct cardstate { ...@@ -444,7 +444,7 @@ struct cardstate {
struct gigaset_driver *driver; struct gigaset_driver *driver;
unsigned minor_index; unsigned minor_index;
struct device *dev; struct device *dev;
struct class_device *class; struct device *tty_dev;
const struct gigaset_ops *ops; const struct gigaset_ops *ops;
......
...@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs) ...@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs)
return; return;
tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); 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)) if (!IS_ERR(cs->tty_dev))
class_set_devdata(cs->class, cs); dev_set_drvdata(cs->tty_dev, cs);
else { else {
warn("could not register device to the tty subsystem"); 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) ...@@ -645,7 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
tasklet_disable(&cs->if_wake_tasklet); tasklet_disable(&cs->if_wake_tasklet);
tasklet_kill(&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); tty_unregister_device(drv->tty, cs->minor_index);
} }
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
#include "gigaset.h" #include "gigaset.h"
#include <linux/ctype.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; int ret;
unsigned long flags; unsigned long flags;
struct cardstate *cs = class_get_devdata(class); struct cardstate *cs = dev_get_drvdata(dev);
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
ret = sprintf(buf, "%u\n", cs->cidmode); ret = sprintf(buf, "%u\n", cs->cidmode);
...@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf) ...@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf)
return ret; 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) const char *buf, size_t count)
{ {
struct cardstate *cs = class_get_devdata(class); struct cardstate *cs = dev_get_drvdata(dev);
long int value; long int value;
char *end; char *end;
...@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class, ...@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class,
return count; 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 */ /* free sysfs for device */
void gigaset_free_dev_sysfs(struct cardstate *cs) void gigaset_free_dev_sysfs(struct cardstate *cs)
{ {
if (!cs->class) if (!cs->tty_dev)
return; return;
gig_dbg(DEBUG_INIT, "removing sysfs entries"); 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 */ /* initialize sysfs for device */
void gigaset_init_dev_sysfs(struct cardstate *cs) void gigaset_init_dev_sysfs(struct cardstate *cs)
{ {
if (!cs->class) if (!cs->tty_dev)
return; return;
gig_dbg(DEBUG_INIT, "setting up sysfs"); 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"); dev_err(cs->dev, "could not create sysfs attribute\n");
} }
...@@ -276,9 +276,8 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); ...@@ -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_unregister_ldisc(int disc);
extern int tty_register_driver(struct tty_driver *driver); extern int tty_register_driver(struct tty_driver *driver);
extern int tty_unregister_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, extern struct device *tty_register_device(struct tty_driver *driver,
unsigned index, unsigned index, struct device *dev);
struct device *dev);
extern void tty_unregister_device(struct tty_driver *driver, unsigned index); extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
int buflen); int buflen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment