diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2010-01-14 06:10:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-14 06:10:54 -0500 |
commit | 9a58a80a701bdb2d220cdab4914218df5b48d781 (patch) | |
tree | 01eeb65ec70f22ec326d0938d002cc6a2aec73e8 /drivers/isdn/hardware/eicon/diva_didd.c | |
parent | 508e14b4a4fb1a824a14f2c5b8d7df67b313f8e4 (diff) |
proc_fops: convert drivers/isdn/ to seq_file
Convert code away from ->read_proc/->write_proc interfaces. Switch to
proc_create()/proc_create_data() which make addition of proc entries
reliable wrt NULL ->proc_fops, NULL ->data and so on.
Problem with ->read_proc et al is described here commit
786d7e1612f0b0adb6046f19b906609e4fe8b1ba "Fix rmmod/read/write races in
/proc entries"
[akpm@linux-foundation.org: CONFIG_PROC_FS=n build fix]
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Karsten Keil <keil@b1-systems.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/hardware/eicon/diva_didd.c')
-rw-r--r-- | drivers/isdn/hardware/eicon/diva_didd.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c index 993b14cf1778..5d06a7437824 100644 --- a/drivers/isdn/hardware/eicon/diva_didd.c +++ b/drivers/isdn/hardware/eicon/diva_didd.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/proc_fs.h> | 17 | #include <linux/proc_fs.h> |
18 | #include <linux/seq_file.h> | ||
18 | #include <net/net_namespace.h> | 19 | #include <net/net_namespace.h> |
19 | 20 | ||
20 | #include "platform.h" | 21 | #include "platform.h" |
@@ -62,39 +63,41 @@ static char *getrev(const char *revision) | |||
62 | return rev; | 63 | return rev; |
63 | } | 64 | } |
64 | 65 | ||
65 | static int | 66 | static int divadidd_proc_show(struct seq_file *m, void *v) |
66 | proc_read(char *page, char **start, off_t off, int count, int *eof, | ||
67 | void *data) | ||
68 | { | 67 | { |
69 | int len = 0; | ||
70 | char tmprev[32]; | 68 | char tmprev[32]; |
71 | 69 | ||
72 | strcpy(tmprev, main_revision); | 70 | strcpy(tmprev, main_revision); |
73 | len += sprintf(page + len, "%s\n", DRIVERNAME); | 71 | seq_printf(m, "%s\n", DRIVERNAME); |
74 | len += sprintf(page + len, "name : %s\n", DRIVERLNAME); | 72 | seq_printf(m, "name : %s\n", DRIVERLNAME); |
75 | len += sprintf(page + len, "release : %s\n", DRIVERRELEASE_DIDD); | 73 | seq_printf(m, "release : %s\n", DRIVERRELEASE_DIDD); |
76 | len += sprintf(page + len, "build : %s(%s)\n", | 74 | seq_printf(m, "build : %s(%s)\n", |
77 | diva_didd_common_code_build, DIVA_BUILD); | 75 | diva_didd_common_code_build, DIVA_BUILD); |
78 | len += sprintf(page + len, "revision : %s\n", getrev(tmprev)); | 76 | seq_printf(m, "revision : %s\n", getrev(tmprev)); |
79 | 77 | ||
80 | if (off + count >= len) | 78 | return 0; |
81 | *eof = 1; | ||
82 | if (len < off) | ||
83 | return 0; | ||
84 | *start = page + off; | ||
85 | return ((count < len - off) ? count : len - off); | ||
86 | } | 79 | } |
87 | 80 | ||
81 | static int divadidd_proc_open(struct inode *inode, struct file *file) | ||
82 | { | ||
83 | return single_open(file, divadidd_proc_show, NULL); | ||
84 | } | ||
85 | |||
86 | static const struct file_operations divadidd_proc_fops = { | ||
87 | .owner = THIS_MODULE, | ||
88 | .open = divadidd_proc_open, | ||
89 | .read = seq_read, | ||
90 | .llseek = seq_lseek, | ||
91 | .release = single_release, | ||
92 | }; | ||
93 | |||
88 | static int DIVA_INIT_FUNCTION create_proc(void) | 94 | static int DIVA_INIT_FUNCTION create_proc(void) |
89 | { | 95 | { |
90 | proc_net_eicon = proc_mkdir("eicon", init_net.proc_net); | 96 | proc_net_eicon = proc_mkdir("eicon", init_net.proc_net); |
91 | 97 | ||
92 | if (proc_net_eicon) { | 98 | if (proc_net_eicon) { |
93 | if ((proc_didd = | 99 | proc_didd = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon, |
94 | create_proc_entry(DRIVERLNAME, S_IFREG | S_IRUGO, | 100 | &divadidd_proc_fops); |
95 | proc_net_eicon))) { | ||
96 | proc_didd->read_proc = proc_read; | ||
97 | } | ||
98 | return (1); | 101 | return (1); |
99 | } | 102 | } |
100 | return (0); | 103 | return (0); |