From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@osdl.org, alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 01/13] proc tty: introduce ->proc_fops
Date: Tue, 29 Jul 2008 05:29:08 +0400 [thread overview]
Message-ID: <20080729012908.GA3135@martell.zuzino.mipt.ru> (raw)
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
next reply other threads:[~2008-07-29 1:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 1:29 Alexey Dobriyan [this message]
2008-07-29 9:53 ` [PATCH 01/13] proc tty: introduce ->proc_fops Alan Cox
2008-08-02 3:45 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080729012908.GA3135@martell.zuzino.mipt.ru \
--to=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).