* [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
* Re: [PATCH 01/13] proc tty: introduce ->proc_fops
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
0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2008-07-29 9:53 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: akpm, linux-kernel
On Tue, 29 Jul 2008 05:29:08 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 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.
I'm going to NAK this but not because I think the concept is wrong. I
think the way its been done is perhaps wrong.
You've added ifdefs to a lot of drivers and more basically duplicate
code. Is there a reason you can't keep the ->read_proc method in the tty
code but as a function called by a single instance of proc_fops and
seq_file methods for the whole tty driver layer.
Ie have a single tty seq_file method that calls driver->ops->read_proc as
the seqfile iterator ?
> int count, int *eof, void *data);
> +#ifdef CONFIG_PROC_FS
> + const struct file_operations *proc_fops;
> +#endif
I'd prefer you didn't put variables in the middle of the methods. Also
the ifdef isn't needed. It's not worth one pointer to create a load of
ifdefs
Alan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 01/13] proc tty: introduce ->proc_fops
2008-07-29 9:53 ` Alan Cox
@ 2008-08-02 3:45 ` Alexey Dobriyan
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2008-08-02 3:45 UTC (permalink / raw)
To: Alan Cox; +Cc: akpm, linux-kernel
On Tue, Jul 29, 2008 at 10:53:50AM +0100, Alan Cox wrote:
> On Tue, 29 Jul 2008 05:29:08 +0400
> Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> > 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.
>
> I'm going to NAK this but not because I think the concept is wrong. I
> think the way its been done is perhaps wrong.
>
> You've added ifdefs to a lot of drivers and more basically duplicate
> code.
It's boileplate code which is hard to screwup, unlike boilerplate at the
end of every ->read_proc hook.
> Is there a reason you can't keep the ->read_proc method in the tty
> code but as a function called by a single instance of proc_fops and
> seq_file methods for the whole tty driver layer.
>
> Ie have a single tty seq_file method that calls driver->ops->read_proc as
> the seqfile iterator ?
I think it should be struct tty_operations::proc_fops .
In fact, posted conversions are bit incorrect.
Let's look at cyclades. It prints banner, then information about each
card. The very right way to print it via seq_files is implement
struct seq_operations::start, next, stop, show.
If TTY driver prints something simple, just one show hook is enough.
If TTY driver wants something more complex, right way start to be
seq_operations and one hook is not enough anymore.
But I don't really care about this exact issue, as long as ->read_proc
TTY hook is gone as ->read_proc proc hook.
> > int count, int *eof, void *data);
> > +#ifdef CONFIG_PROC_FS
> > + const struct file_operations *proc_fops;
> > +#endif
>
> I'd prefer you didn't put variables in the middle of the methods. Also
> the ifdef isn't needed. It's not worth one pointer to create a load of
> ifdefs
OK.
^ 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).