aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/capi.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2010-01-14 06:10:54 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-14 06:10:54 -0500
commit9a58a80a701bdb2d220cdab4914218df5b48d781 (patch)
tree01eeb65ec70f22ec326d0938d002cc6a2aec73e8 /drivers/isdn/gigaset/capi.c
parent508e14b4a4fb1a824a14f2c5b8d7df67b313f8e4 (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/gigaset/capi.c')
-rw-r--r--drivers/isdn/gigaset/capi.c75
1 files changed, 36 insertions, 39 deletions
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 3f5cd06af104..6f0ae32906bf 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -13,6 +13,8 @@
13 13
14#include "gigaset.h" 14#include "gigaset.h"
15#include <linux/ctype.h> 15#include <linux/ctype.h>
16#include <linux/proc_fs.h>
17#include <linux/seq_file.h>
16#include <linux/isdn/capilli.h> 18#include <linux/isdn/capilli.h>
17#include <linux/isdn/capicmd.h> 19#include <linux/isdn/capicmd.h>
18#include <linux/isdn/capiutil.h> 20#include <linux/isdn/capiutil.h>
@@ -2106,35 +2108,22 @@ static char *gigaset_procinfo(struct capi_ctr *ctr)
2106 return ctr->name; /* ToDo: more? */ 2108 return ctr->name; /* ToDo: more? */
2107} 2109}
2108 2110
2109/** 2111static int gigaset_proc_show(struct seq_file *m, void *v)
2110 * gigaset_ctr_read_proc() - build controller proc file entry
2111 * @page: buffer of PAGE_SIZE bytes for receiving the entry.
2112 * @start: unused.
2113 * @off: unused.
2114 * @count: unused.
2115 * @eof: unused.
2116 * @ctr: controller descriptor structure.
2117 *
2118 * Return value: length of generated entry
2119 */
2120static int gigaset_ctr_read_proc(char *page, char **start, off_t off,
2121 int count, int *eof, struct capi_ctr *ctr)
2122{ 2112{
2113 struct capi_ctr *ctr = m->private;
2123 struct cardstate *cs = ctr->driverdata; 2114 struct cardstate *cs = ctr->driverdata;
2124 char *s; 2115 char *s;
2125 int i; 2116 int i;
2126 int len = 0; 2117
2127 len += sprintf(page+len, "%-16s %s\n", "name", ctr->name); 2118 seq_printf(m, "%-16s %s\n", "name", ctr->name);
2128 len += sprintf(page+len, "%-16s %s %s\n", "dev", 2119 seq_printf(m, "%-16s %s %s\n", "dev",
2129 dev_driver_string(cs->dev), dev_name(cs->dev)); 2120 dev_driver_string(cs->dev), dev_name(cs->dev));
2130 len += sprintf(page+len, "%-16s %d\n", "id", cs->myid); 2121 seq_printf(m, "%-16s %d\n", "id", cs->myid);
2131 if (cs->gotfwver) 2122 if (cs->gotfwver)
2132 len += sprintf(page+len, "%-16s %d.%d.%d.%d\n", "firmware", 2123 seq_printf(m, "%-16s %d.%d.%d.%d\n", "firmware",
2133 cs->fwver[0], cs->fwver[1], cs->fwver[2], cs->fwver[3]); 2124 cs->fwver[0], cs->fwver[1], cs->fwver[2], cs->fwver[3]);
2134 len += sprintf(page+len, "%-16s %d\n", "channels", 2125 seq_printf(m, "%-16s %d\n", "channels", cs->channels);
2135 cs->channels); 2126 seq_printf(m, "%-16s %s\n", "onechannel", cs->onechannel ? "yes" : "no");
2136 len += sprintf(page+len, "%-16s %s\n", "onechannel",
2137 cs->onechannel ? "yes" : "no");
2138 2127
2139 switch (cs->mode) { 2128 switch (cs->mode) {
2140 case M_UNKNOWN: 2129 case M_UNKNOWN:
@@ -2152,7 +2141,7 @@ static int gigaset_ctr_read_proc(char *page, char **start, off_t off,
2152 default: 2141 default:
2153 s = "??"; 2142 s = "??";
2154 } 2143 }
2155 len += sprintf(page+len, "%-16s %s\n", "mode", s); 2144 seq_printf(m, "%-16s %s\n", "mode", s);
2156 2145
2157 switch (cs->mstate) { 2146 switch (cs->mstate) {
2158 case MS_UNINITIALIZED: 2147 case MS_UNINITIALIZED:
@@ -2176,25 +2165,21 @@ static int gigaset_ctr_read_proc(char *page, char **start, off_t off,
2176 default: 2165 default:
2177 s = "??"; 2166 s = "??";
2178 } 2167 }
2179 len += sprintf(page+len, "%-16s %s\n", "mstate", s); 2168 seq_printf(m, "%-16s %s\n", "mstate", s);
2180 2169
2181 len += sprintf(page+len, "%-16s %s\n", "running", 2170 seq_printf(m, "%-16s %s\n", "running", cs->running ? "yes" : "no");
2182 cs->running ? "yes" : "no"); 2171 seq_printf(m, "%-16s %s\n", "connected", cs->connected ? "yes" : "no");
2183 len += sprintf(page+len, "%-16s %s\n", "connected", 2172 seq_printf(m, "%-16s %s\n", "isdn_up", cs->isdn_up ? "yes" : "no");
2184 cs->connected ? "yes" : "no"); 2173 seq_printf(m, "%-16s %s\n", "cidmode", cs->cidmode ? "yes" : "no");
2185 len += sprintf(page+len, "%-16s %s\n", "isdn_up",
2186 cs->isdn_up ? "yes" : "no");
2187 len += sprintf(page+len, "%-16s %s\n", "cidmode",
2188 cs->cidmode ? "yes" : "no");
2189 2174
2190 for (i = 0; i < cs->channels; i++) { 2175 for (i = 0; i < cs->channels; i++) {
2191 len += sprintf(page+len, "[%d]%-13s %d\n", i, "corrupted", 2176 seq_printf(m, "[%d]%-13s %d\n", i, "corrupted",
2192 cs->bcs[i].corrupted); 2177 cs->bcs[i].corrupted);
2193 len += sprintf(page+len, "[%d]%-13s %d\n", i, "trans_down", 2178 seq_printf(m, "[%d]%-13s %d\n", i, "trans_down",
2194 cs->bcs[i].trans_down); 2179 cs->bcs[i].trans_down);
2195 len += sprintf(page+len, "[%d]%-13s %d\n", i, "trans_up", 2180 seq_printf(m, "[%d]%-13s %d\n", i, "trans_up",
2196 cs->bcs[i].trans_up); 2181 cs->bcs[i].trans_up);
2197 len += sprintf(page+len, "[%d]%-13s %d\n", i, "chstate", 2182 seq_printf(m, "[%d]%-13s %d\n", i, "chstate",
2198 cs->bcs[i].chstate); 2183 cs->bcs[i].chstate);
2199 switch (cs->bcs[i].proto2) { 2184 switch (cs->bcs[i].proto2) {
2200 case L2_BITSYNC: 2185 case L2_BITSYNC:
@@ -2209,11 +2194,23 @@ static int gigaset_ctr_read_proc(char *page, char **start, off_t off,
2209 default: 2194 default:
2210 s = "??"; 2195 s = "??";
2211 } 2196 }
2212 len += sprintf(page+len, "[%d]%-13s %s\n", i, "proto2", s); 2197 seq_printf(m, "[%d]%-13s %s\n", i, "proto2", s);
2213 } 2198 }
2214 return len; 2199 return 0;
2215} 2200}
2216 2201
2202static int gigaset_proc_open(struct inode *inode, struct file *file)
2203{
2204 return single_open(file, gigaset_proc_show, PDE(inode)->data);
2205}
2206
2207static const struct file_operations gigaset_proc_fops = {
2208 .owner = THIS_MODULE,
2209 .open = gigaset_proc_open,
2210 .read = seq_read,
2211 .llseek = seq_lseek,
2212 .release = single_release,
2213};
2217 2214
2218static struct capi_driver capi_driver_gigaset = { 2215static struct capi_driver capi_driver_gigaset = {
2219 .name = "gigaset", 2216 .name = "gigaset",
@@ -2256,7 +2253,7 @@ int gigaset_isdn_register(struct cardstate *cs, const char *isdnid)
2256 iif->ctr.release_appl = gigaset_release_appl; 2253 iif->ctr.release_appl = gigaset_release_appl;
2257 iif->ctr.send_message = gigaset_send_message; 2254 iif->ctr.send_message = gigaset_send_message;
2258 iif->ctr.procinfo = gigaset_procinfo; 2255 iif->ctr.procinfo = gigaset_procinfo;
2259 iif->ctr.ctr_read_proc = gigaset_ctr_read_proc; 2256 iif->ctr.proc_fops = &gigaset_proc_fops;
2260 INIT_LIST_HEAD(&iif->appls); 2257 INIT_LIST_HEAD(&iif->appls);
2261 skb_queue_head_init(&iif->sendqueue); 2258 skb_queue_head_init(&iif->sendqueue);
2262 atomic_set(&iif->sendqlen, 0); 2259 atomic_set(&iif->sendqlen, 0);