Messages in this thread Patch in this message | | | Date | Tue, 29 Jul 2008 05:29:08 +0400 | From | Alexey Dobriyan <> | Subject | [PATCH 01/13] proc tty: introduce ->proc_fops |
| |
Add struct tty_operations:proc_fops .
The intent is gradual switch of TTY drivers from ->read_proc usage. proc entries are created with proc_create_data() which even fixes early-read races.
Eventually ->read_proc code will be removed from TTY code, thus helping remove ->read_proc from whole proc code.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> ---
fs/proc/proc_tty.c | 21 +++++++++++++-------- include/linux/tty_driver.h | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-)
--- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c @@ -144,17 +144,22 @@ void proc_tty_register_driver(struct tty_driver *driver) { struct proc_dir_entry *ent; - if (!driver->ops->read_proc || !driver->driver_name || - driver->proc_entry) + if (!driver->driver_name || driver->proc_entry) return; - - ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); - if (!ent) + if (driver->ops->proc_fops) { + ent = proc_create_data(driver->driver_name, 0, proc_tty_driver, + driver->ops->proc_fops, driver); + if (!ent) + return; + } else if (driver->ops->read_proc) { + ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); + if (!ent) + return; + ent->read_proc = driver->ops->read_proc; + ent->data = driver; + } else return; - ent->read_proc = driver->ops->read_proc; ent->owner = driver->owner; - ent->data = driver; - driver->proc_entry = ent; } --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -203,6 +203,9 @@ struct tty_operations { void (*send_xchar)(struct tty_struct *tty, char ch); int (*read_proc)(char *page, char **start, off_t off, int count, int *eof, void *data); +#ifdef CONFIG_PROC_FS + const struct file_operations *proc_fops; +#endif int (*tiocmget)(struct tty_struct *tty, struct file *file); int (*tiocmset)(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -- 1.5.4.5
| |