linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/13] proc tty: introduce ->proc_fops
@ 2008-07-29  1:29 Alexey Dobriyan
  2008-07-29  9:53 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2008-07-29  1:29 UTC (permalink / raw)
  To: akpm, alan; +Cc: linux-kernel

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-02  3:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-29  1:29 [PATCH 01/13] proc tty: introduce ->proc_fops Alexey Dobriyan
2008-07-29  9:53 ` Alan Cox
2008-08-02  3:45   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).