diff options
author | Hansjoerg Lipp <hjlipp@web.de> | 2006-04-22 12:36:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 15:40:47 -0400 |
commit | 1cdcb6b43fda7424b7435dac8f80b2b5d8a48899 (patch) | |
tree | 3090342c60b9b8f0f8144f67962d3cb3ce2a9207 | |
parent | 53877d06d53a412d901bb323f080296c363d8b51 (diff) |
[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: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/char/tty_io.c | 11 | ||||
-rw-r--r-- | include/linux/tty.h | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index a88b94a82b14..8b2a59969868 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2961,12 +2961,14 @@ static struct class *tty_class; | |||
2961 | * This field is optional, if there is no known struct device for this | 2961 | * This field is optional, if there is no known struct device for this |
2962 | * tty device it can be set to NULL safely. | 2962 | * tty device it can be set to NULL safely. |
2963 | * | 2963 | * |
2964 | * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). | ||
2965 | * | ||
2964 | * This call is required to be made to register an individual tty device if | 2966 | * This call is required to be made to register an individual tty device if |
2965 | * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that | 2967 | * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that |
2966 | * bit is not set, this function should not be called. | 2968 | * bit is not set, this function should not be called. |
2967 | */ | 2969 | */ |
2968 | void tty_register_device(struct tty_driver *driver, unsigned index, | 2970 | struct class_device *tty_register_device(struct tty_driver *driver, |
2969 | struct device *device) | 2971 | unsigned index, struct device *device) |
2970 | { | 2972 | { |
2971 | char name[64]; | 2973 | char name[64]; |
2972 | dev_t dev = MKDEV(driver->major, driver->minor_start) + index; | 2974 | 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 | if (index >= driver->num) { | 2976 | if (index >= driver->num) { |
2975 | printk(KERN_ERR "Attempt to register invalid tty line number " | 2977 | printk(KERN_ERR "Attempt to register invalid tty line number " |
2976 | " (%d).\n", index); | 2978 | " (%d).\n", index); |
2977 | return; | 2979 | return ERR_PTR(-EINVAL); |
2978 | } | 2980 | } |
2979 | 2981 | ||
2980 | devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, | 2982 | 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 | pty_line_name(driver, index, name); | 2986 | pty_line_name(driver, index, name); |
2985 | else | 2987 | else |
2986 | tty_line_name(driver, index, name); | 2988 | tty_line_name(driver, index, name); |
2987 | class_device_create(tty_class, NULL, dev, device, "%s", name); | 2989 | |
2990 | return class_device_create(tty_class, NULL, dev, device, "%s", name); | ||
2988 | } | 2991 | } |
2989 | 2992 | ||
2990 | /** | 2993 | /** |
diff --git a/include/linux/tty.h b/include/linux/tty.h index e898eeb94166..cb35ca50a0a6 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -290,7 +290,9 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); | |||
290 | extern int tty_unregister_ldisc(int disc); | 290 | extern int tty_unregister_ldisc(int disc); |
291 | extern int tty_register_driver(struct tty_driver *driver); | 291 | extern int tty_register_driver(struct tty_driver *driver); |
292 | extern int tty_unregister_driver(struct tty_driver *driver); | 292 | extern int tty_unregister_driver(struct tty_driver *driver); |
293 | extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); | 293 | extern struct class_device *tty_register_device(struct tty_driver *driver, |
294 | unsigned index, | ||
295 | struct device *dev); | ||
294 | extern void tty_unregister_device(struct tty_driver *driver, unsigned index); | 296 | extern void tty_unregister_device(struct tty_driver *driver, unsigned index); |
295 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, | 297 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, |
296 | int buflen); | 298 | int buflen); |