diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-08-28 05:57:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-29 03:19:38 -0400 |
commit | ea00b8e2223170a842bee06e0f27754ccdf2a217 (patch) | |
tree | d167e267a05de6a1f422d805b0290047af313981 /net/can/bcm.c | |
parent | 4923576b8ac5bfd36ab2beb176aeb747aaab7e41 (diff) |
can: switch to seq_file
create_proc_read_entry() is going to be removed soon.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/can/bcm.c')
-rw-r--r-- | net/can/bcm.c | 85 |
1 files changed, 36 insertions, 49 deletions
diff --git a/net/can/bcm.c b/net/can/bcm.c index 72720c710351..597da4f8f888 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/hrtimer.h> | 46 | #include <linux/hrtimer.h> |
47 | #include <linux/list.h> | 47 | #include <linux/list.h> |
48 | #include <linux/proc_fs.h> | 48 | #include <linux/proc_fs.h> |
49 | #include <linux/seq_file.h> | ||
49 | #include <linux/uio.h> | 50 | #include <linux/uio.h> |
50 | #include <linux/net.h> | 51 | #include <linux/net.h> |
51 | #include <linux/netdevice.h> | 52 | #include <linux/netdevice.h> |
@@ -146,23 +147,18 @@ static char *bcm_proc_getifname(int ifindex) | |||
146 | return "???"; | 147 | return "???"; |
147 | } | 148 | } |
148 | 149 | ||
149 | static int bcm_read_proc(char *page, char **start, off_t off, | 150 | static int bcm_proc_show(struct seq_file *m, void *v) |
150 | int count, int *eof, void *data) | ||
151 | { | 151 | { |
152 | int len = 0; | 152 | struct sock *sk = (struct sock *)m->private; |
153 | struct sock *sk = (struct sock *)data; | ||
154 | struct bcm_sock *bo = bcm_sk(sk); | 153 | struct bcm_sock *bo = bcm_sk(sk); |
155 | struct bcm_op *op; | 154 | struct bcm_op *op; |
156 | 155 | ||
157 | len += snprintf(page + len, PAGE_SIZE - len, ">>> socket %p", | 156 | seq_printf(m, ">>> socket %p", sk->sk_socket); |
158 | sk->sk_socket); | 157 | seq_printf(m, " / sk %p", sk); |
159 | len += snprintf(page + len, PAGE_SIZE - len, " / sk %p", sk); | 158 | seq_printf(m, " / bo %p", bo); |
160 | len += snprintf(page + len, PAGE_SIZE - len, " / bo %p", bo); | 159 | seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs); |
161 | len += snprintf(page + len, PAGE_SIZE - len, " / dropped %lu", | 160 | seq_printf(m, " / bound %s", bcm_proc_getifname(bo->ifindex)); |
162 | bo->dropped_usr_msgs); | 161 | seq_printf(m, " <<<\n"); |
163 | len += snprintf(page + len, PAGE_SIZE - len, " / bound %s", | ||
164 | bcm_proc_getifname(bo->ifindex)); | ||
165 | len += snprintf(page + len, PAGE_SIZE - len, " <<<\n"); | ||
166 | 162 | ||
167 | list_for_each_entry(op, &bo->rx_ops, list) { | 163 | list_for_each_entry(op, &bo->rx_ops, list) { |
168 | 164 | ||
@@ -172,71 +168,62 @@ static int bcm_read_proc(char *page, char **start, off_t off, | |||
172 | if (!op->frames_abs) | 168 | if (!op->frames_abs) |
173 | continue; | 169 | continue; |
174 | 170 | ||
175 | len += snprintf(page + len, PAGE_SIZE - len, | 171 | seq_printf(m, "rx_op: %03X %-5s ", |
176 | "rx_op: %03X %-5s ", | ||
177 | op->can_id, bcm_proc_getifname(op->ifindex)); | 172 | op->can_id, bcm_proc_getifname(op->ifindex)); |
178 | len += snprintf(page + len, PAGE_SIZE - len, "[%d]%c ", | 173 | seq_printf(m, "[%d]%c ", op->nframes, |
179 | op->nframes, | ||
180 | (op->flags & RX_CHECK_DLC)?'d':' '); | 174 | (op->flags & RX_CHECK_DLC)?'d':' '); |
181 | if (op->kt_ival1.tv64) | 175 | if (op->kt_ival1.tv64) |
182 | len += snprintf(page + len, PAGE_SIZE - len, | 176 | seq_printf(m, "timeo=%lld ", |
183 | "timeo=%lld ", | ||
184 | (long long) | 177 | (long long) |
185 | ktime_to_us(op->kt_ival1)); | 178 | ktime_to_us(op->kt_ival1)); |
186 | 179 | ||
187 | if (op->kt_ival2.tv64) | 180 | if (op->kt_ival2.tv64) |
188 | len += snprintf(page + len, PAGE_SIZE - len, | 181 | seq_printf(m, "thr=%lld ", |
189 | "thr=%lld ", | ||
190 | (long long) | 182 | (long long) |
191 | ktime_to_us(op->kt_ival2)); | 183 | ktime_to_us(op->kt_ival2)); |
192 | 184 | ||
193 | len += snprintf(page + len, PAGE_SIZE - len, | 185 | seq_printf(m, "# recv %ld (%ld) => reduction: ", |
194 | "# recv %ld (%ld) => reduction: ", | ||
195 | op->frames_filtered, op->frames_abs); | 186 | op->frames_filtered, op->frames_abs); |
196 | 187 | ||
197 | reduction = 100 - (op->frames_filtered * 100) / op->frames_abs; | 188 | reduction = 100 - (op->frames_filtered * 100) / op->frames_abs; |
198 | 189 | ||
199 | len += snprintf(page + len, PAGE_SIZE - len, "%s%ld%%\n", | 190 | seq_printf(m, "%s%ld%%\n", |
200 | (reduction == 100)?"near ":"", reduction); | 191 | (reduction == 100)?"near ":"", reduction); |
201 | |||
202 | if (len > PAGE_SIZE - 200) { | ||
203 | /* mark output cut off */ | ||
204 | len += snprintf(page + len, PAGE_SIZE - len, "(..)\n"); | ||
205 | break; | ||
206 | } | ||
207 | } | 192 | } |
208 | 193 | ||
209 | list_for_each_entry(op, &bo->tx_ops, list) { | 194 | list_for_each_entry(op, &bo->tx_ops, list) { |
210 | 195 | ||
211 | len += snprintf(page + len, PAGE_SIZE - len, | 196 | seq_printf(m, "tx_op: %03X %s [%d] ", |
212 | "tx_op: %03X %s [%d] ", | ||
213 | op->can_id, bcm_proc_getifname(op->ifindex), | 197 | op->can_id, bcm_proc_getifname(op->ifindex), |
214 | op->nframes); | 198 | op->nframes); |
215 | 199 | ||
216 | if (op->kt_ival1.tv64) | 200 | if (op->kt_ival1.tv64) |
217 | len += snprintf(page + len, PAGE_SIZE - len, "t1=%lld ", | 201 | seq_printf(m, "t1=%lld ", |
218 | (long long) ktime_to_us(op->kt_ival1)); | 202 | (long long) ktime_to_us(op->kt_ival1)); |
219 | 203 | ||
220 | if (op->kt_ival2.tv64) | 204 | if (op->kt_ival2.tv64) |
221 | len += snprintf(page + len, PAGE_SIZE - len, "t2=%lld ", | 205 | seq_printf(m, "t2=%lld ", |
222 | (long long) ktime_to_us(op->kt_ival2)); | 206 | (long long) ktime_to_us(op->kt_ival2)); |
223 | 207 | ||
224 | len += snprintf(page + len, PAGE_SIZE - len, "# sent %ld\n", | 208 | seq_printf(m, "# sent %ld\n", op->frames_abs); |
225 | op->frames_abs); | ||
226 | |||
227 | if (len > PAGE_SIZE - 100) { | ||
228 | /* mark output cut off */ | ||
229 | len += snprintf(page + len, PAGE_SIZE - len, "(..)\n"); | ||
230 | break; | ||
231 | } | ||
232 | } | 209 | } |
210 | seq_putc(m, '\n'); | ||
211 | return 0; | ||
212 | } | ||
233 | 213 | ||
234 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 214 | static int bcm_proc_open(struct inode *inode, struct file *file) |
235 | 215 | { | |
236 | *eof = 1; | 216 | return single_open(file, bcm_proc_show, PDE(inode)->data); |
237 | return len; | ||
238 | } | 217 | } |
239 | 218 | ||
219 | static const struct file_operations bcm_proc_fops = { | ||
220 | .owner = THIS_MODULE, | ||
221 | .open = bcm_proc_open, | ||
222 | .read = seq_read, | ||
223 | .llseek = seq_lseek, | ||
224 | .release = single_release, | ||
225 | }; | ||
226 | |||
240 | /* | 227 | /* |
241 | * bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface | 228 | * bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface |
242 | * of the given bcm tx op | 229 | * of the given bcm tx op |
@@ -1515,9 +1502,9 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, | |||
1515 | if (proc_dir) { | 1502 | if (proc_dir) { |
1516 | /* unique socket address as filename */ | 1503 | /* unique socket address as filename */ |
1517 | sprintf(bo->procname, "%p", sock); | 1504 | sprintf(bo->procname, "%p", sock); |
1518 | bo->bcm_proc_read = create_proc_read_entry(bo->procname, 0644, | 1505 | bo->bcm_proc_read = proc_create_data(bo->procname, 0644, |
1519 | proc_dir, | 1506 | proc_dir, |
1520 | bcm_read_proc, sk); | 1507 | &bcm_proc_fops, sk); |
1521 | } | 1508 | } |
1522 | 1509 | ||
1523 | return 0; | 1510 | return 0; |