Commit 1cdcb6b4 authored by Hansjoerg Lipp's avatar Hansjoerg Lipp Committed by Greg Kroah-Hartman

[PATCH] TTY: return class device pointer from tty_register_device()

Let tty_register_device() return a pointer to the class device it creates.
This allows registrants to add their own sysfs files under the class
device node.
Signed-off-by: default avatarHansjoerg Lipp <hjlipp@web.de>
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 53877d06
...@@ -2961,12 +2961,14 @@ static struct class *tty_class; ...@@ -2961,12 +2961,14 @@ static struct class *tty_class;
* This field is optional, if there is no known struct device for this * This field is optional, if there is no known struct device for this
* tty device it can be set to NULL safely. * tty device it can be set to NULL safely.
* *
* Returns a pointer to the class device (or ERR_PTR(-EFOO) on error).
*
* This call is required to be made to register an individual tty device if * This call is required to be made to register an individual tty device if
* the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that
* bit is not set, this function should not be called. * bit is not set, this function should not be called.
*/ */
void tty_register_device(struct tty_driver *driver, unsigned index, struct class_device *tty_register_device(struct tty_driver *driver,
struct device *device) unsigned index, 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;
...@@ -2974,7 +2976,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index, ...@@ -2974,7 +2976,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
if (index >= driver->num) { if (index >= driver->num) {
printk(KERN_ERR "Attempt to register invalid tty line number " printk(KERN_ERR "Attempt to register invalid tty line number "
" (%d).\n", index); " (%d).\n", index);
return; return ERR_PTR(-EINVAL);
} }
devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
...@@ -2984,7 +2986,8 @@ void tty_register_device(struct tty_driver *driver, unsigned index, ...@@ -2984,7 +2986,8 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
pty_line_name(driver, index, name); pty_line_name(driver, index, name);
else else
tty_line_name(driver, index, name); tty_line_name(driver, index, name);
class_device_create(tty_class, NULL, dev, device, "%s", name);
return class_device_create(tty_class, NULL, dev, device, "%s", name);
} }
/** /**
......
...@@ -290,7 +290,9 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); ...@@ -290,7 +290,9 @@ 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 void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); extern struct class_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 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