Commit ae149b6b authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc tty: add struct tty_operations::proc_fops

Used for gradual switch of TTY drivers from using ->read_proc which helps
with gradual switch from ->read_proc for the whole tree.

As side effect, fix possible race condition when ->data initialized after
PDE is hooked into proc tree.

->proc_fops takes precedence over ->read_proc.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 15f7176e
...@@ -144,16 +144,22 @@ void proc_tty_register_driver(struct tty_driver *driver) ...@@ -144,16 +144,22 @@ void proc_tty_register_driver(struct tty_driver *driver)
{ {
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
if (!driver->ops->read_proc || !driver->driver_name || if (!driver->driver_name || driver->proc_entry)
driver->proc_entry)
return; return;
ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); if (driver->ops->proc_fops) {
if (!ent) 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; return;
ent->read_proc = driver->ops->read_proc;
ent->data = driver;
driver->proc_entry = ent; driver->proc_entry = ent;
} }
......
...@@ -264,6 +264,7 @@ struct tty_operations { ...@@ -264,6 +264,7 @@ struct tty_operations {
int (*poll_get_char)(struct tty_driver *driver, int line); int (*poll_get_char)(struct tty_driver *driver, int line);
void (*poll_put_char)(struct tty_driver *driver, int line, char ch); void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
#endif #endif
const struct file_operations *proc_fops;
}; };
struct tty_driver { struct tty_driver {
......
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