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/capi/capidrv.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/capi/capidrv.c')
-rw-r--r-- | drivers/isdn/capi/capidrv.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 66b7d7a86474..bb450152fb74 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/isdn.h> | 24 | #include <linux/isdn.h> |
25 | #include <linux/isdnif.h> | 25 | #include <linux/isdnif.h> |
26 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
27 | #include <linux/seq_file.h> | ||
27 | #include <linux/capi.h> | 28 | #include <linux/capi.h> |
28 | #include <linux/kernelcapi.h> | 29 | #include <linux/kernelcapi.h> |
29 | #include <linux/ctype.h> | 30 | #include <linux/ctype.h> |
@@ -2229,59 +2230,37 @@ static void lower_callback(unsigned int cmd, u32 contr, void *data) | |||
2229 | * /proc/capi/capidrv: | 2230 | * /proc/capi/capidrv: |
2230 | * nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt | 2231 | * nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt |
2231 | */ | 2232 | */ |
2232 | static int proc_capidrv_read_proc(char *page, char **start, off_t off, | 2233 | static int capidrv_proc_show(struct seq_file *m, void *v) |
2233 | int count, int *eof, void *data) | ||
2234 | { | 2234 | { |
2235 | int len = 0; | 2235 | seq_printf(m, "%lu %lu %lu %lu\n", |
2236 | |||
2237 | len += sprintf(page+len, "%lu %lu %lu %lu\n", | ||
2238 | global.ap.nrecvctlpkt, | 2236 | global.ap.nrecvctlpkt, |
2239 | global.ap.nrecvdatapkt, | 2237 | global.ap.nrecvdatapkt, |
2240 | global.ap.nsentctlpkt, | 2238 | global.ap.nsentctlpkt, |
2241 | global.ap.nsentdatapkt); | 2239 | global.ap.nsentdatapkt); |
2242 | if (off+count >= len) | 2240 | return 0; |
2243 | *eof = 1; | 2241 | } |
2244 | if (len < off) | 2242 | |
2245 | return 0; | 2243 | static int capidrv_proc_open(struct inode *inode, struct file *file) |
2246 | *start = page + off; | 2244 | { |
2247 | return ((count < len-off) ? count : len-off); | 2245 | return single_open(file, capidrv_proc_show, NULL); |
2248 | } | 2246 | } |
2249 | 2247 | ||
2250 | static struct procfsentries { | 2248 | static const struct file_operations capidrv_proc_fops = { |
2251 | char *name; | 2249 | .owner = THIS_MODULE, |
2252 | mode_t mode; | 2250 | .open = capidrv_proc_open, |
2253 | int (*read_proc)(char *page, char **start, off_t off, | 2251 | .read = seq_read, |
2254 | int count, int *eof, void *data); | 2252 | .llseek = seq_lseek, |
2255 | struct proc_dir_entry *procent; | 2253 | .release = single_release, |
2256 | } procfsentries[] = { | ||
2257 | /* { "capi", S_IFDIR, 0 }, */ | ||
2258 | { "capi/capidrv", 0 , proc_capidrv_read_proc }, | ||
2259 | }; | 2254 | }; |
2260 | 2255 | ||
2261 | static void __init proc_init(void) | 2256 | static void __init proc_init(void) |
2262 | { | 2257 | { |
2263 | int nelem = ARRAY_SIZE(procfsentries); | 2258 | proc_create("capi/capidrv", 0, NULL, &capidrv_proc_fops); |
2264 | int i; | ||
2265 | |||
2266 | for (i=0; i < nelem; i++) { | ||
2267 | struct procfsentries *p = procfsentries + i; | ||
2268 | p->procent = create_proc_entry(p->name, p->mode, NULL); | ||
2269 | if (p->procent) p->procent->read_proc = p->read_proc; | ||
2270 | } | ||
2271 | } | 2259 | } |
2272 | 2260 | ||
2273 | static void __exit proc_exit(void) | 2261 | static void __exit proc_exit(void) |
2274 | { | 2262 | { |
2275 | int nelem = ARRAY_SIZE(procfsentries); | 2263 | remove_proc_entry("capi/capidrv", NULL); |
2276 | int i; | ||
2277 | |||
2278 | for (i=nelem-1; i >= 0; i--) { | ||
2279 | struct procfsentries *p = procfsentries + i; | ||
2280 | if (p->procent) { | ||
2281 | remove_proc_entry(p->name, NULL); | ||
2282 | p->procent = NULL; | ||
2283 | } | ||
2284 | } | ||
2285 | } | 2264 | } |
2286 | 2265 | ||
2287 | static int __init capidrv_init(void) | 2266 | static int __init capidrv_init(void) |