]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
proc tty: add struct tty_operations::proc_fops
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 31 Mar 2009 22:19:15 +0000 (15:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Apr 2009 15:59:08 +0000 (08:59 -0700)
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: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/proc_tty.c
include/linux/tty_driver.h

index 4a9e0f65ae607732303f3b2a81fad46a9d28f4b0..854827b1d4639db46b7b2f2065d4de86d63ae425 100644 (file)
@@ -144,16 +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->data = driver;
-
        driver->proc_entry = ent;
 }
 
index 08e088334dba25288b8fba8423dfcb58774c833a..c9a69575ded65f6c05d9875d5f432520c6455d53 100644 (file)
@@ -264,6 +264,7 @@ struct tty_operations {
        int (*poll_get_char)(struct tty_driver *driver, int line);
        void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
 #endif
+       const struct file_operations *proc_fops;
 };
 
 struct tty_driver {