[PATCH 01/13] proc tty: introduce ->proc_fops

From: Alexey Dobriyan
Date: Mon Jul 28 2008 - 21:29:19 EST


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@xxxxxxxxx>
---

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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/