Commit ea00b8e2 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

can: switch to seq_file

create_proc_read_entry() is going to be removed soon.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4923576b
......@@ -46,6 +46,7 @@
#include <linux/hrtimer.h>
#include <linux/list.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/uio.h>
#include <linux/net.h>
#include <linux/netdevice.h>
......@@ -146,23 +147,18 @@ static char *bcm_proc_getifname(int ifindex)
return "???";
}
static int bcm_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int bcm_proc_show(struct seq_file *m, void *v)
{
int len = 0;
struct sock *sk = (struct sock *)data;
struct sock *sk = (struct sock *)m->private;
struct bcm_sock *bo = bcm_sk(sk);
struct bcm_op *op;
len += snprintf(page + len, PAGE_SIZE - len, ">>> socket %p",
sk->sk_socket);
len += snprintf(page + len, PAGE_SIZE - len, " / sk %p", sk);
len += snprintf(page + len, PAGE_SIZE - len, " / bo %p", bo);
len += snprintf(page + len, PAGE_SIZE - len, " / dropped %lu",
bo->dropped_usr_msgs);
len += snprintf(page + len, PAGE_SIZE - len, " / bound %s",
bcm_proc_getifname(bo->ifindex));
len += snprintf(page + len, PAGE_SIZE - len, " <<<\n");
seq_printf(m, ">>> socket %p", sk->sk_socket);
seq_printf(m, " / sk %p", sk);
seq_printf(m, " / bo %p", bo);
seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs);
seq_printf(m, " / bound %s", bcm_proc_getifname(bo->ifindex));
seq_printf(m, " <<<\n");
list_for_each_entry(op, &bo->rx_ops, list) {
......@@ -172,71 +168,62 @@ static int bcm_read_proc(char *page, char **start, off_t off,
if (!op->frames_abs)
continue;
len += snprintf(page + len, PAGE_SIZE - len,
"rx_op: %03X %-5s ",
seq_printf(m, "rx_op: %03X %-5s ",
op->can_id, bcm_proc_getifname(op->ifindex));
len += snprintf(page + len, PAGE_SIZE - len, "[%d]%c ",
op->nframes,
seq_printf(m, "[%d]%c ", op->nframes,
(op->flags & RX_CHECK_DLC)?'d':' ');
if (op->kt_ival1.tv64)
len += snprintf(page + len, PAGE_SIZE - len,
"timeo=%lld ",
seq_printf(m, "timeo=%lld ",
(long long)
ktime_to_us(op->kt_ival1));
if (op->kt_ival2.tv64)
len += snprintf(page + len, PAGE_SIZE - len,
"thr=%lld ",
seq_printf(m, "thr=%lld ",
(long long)
ktime_to_us(op->kt_ival2));
len += snprintf(page + len, PAGE_SIZE - len,
"# recv %ld (%ld) => reduction: ",
seq_printf(m, "# recv %ld (%ld) => reduction: ",
op->frames_filtered, op->frames_abs);
reduction = 100 - (op->frames_filtered * 100) / op->frames_abs;
len += snprintf(page + len, PAGE_SIZE - len, "%s%ld%%\n",
seq_printf(m, "%s%ld%%\n",
(reduction == 100)?"near ":"", reduction);
if (len > PAGE_SIZE - 200) {
/* mark output cut off */
len += snprintf(page + len, PAGE_SIZE - len, "(..)\n");
break;
}
}
list_for_each_entry(op, &bo->tx_ops, list) {
len += snprintf(page + len, PAGE_SIZE - len,
"tx_op: %03X %s [%d] ",
seq_printf(m, "tx_op: %03X %s [%d] ",
op->can_id, bcm_proc_getifname(op->ifindex),
op->nframes);
if (op->kt_ival1.tv64)
len += snprintf(page + len, PAGE_SIZE - len, "t1=%lld ",
seq_printf(m, "t1=%lld ",
(long long) ktime_to_us(op->kt_ival1));
if (op->kt_ival2.tv64)
len += snprintf(page + len, PAGE_SIZE - len, "t2=%lld ",
seq_printf(m, "t2=%lld ",
(long long) ktime_to_us(op->kt_ival2));
len += snprintf(page + len, PAGE_SIZE - len, "# sent %ld\n",
op->frames_abs);
if (len > PAGE_SIZE - 100) {
/* mark output cut off */
len += snprintf(page + len, PAGE_SIZE - len, "(..)\n");
break;
}
seq_printf(m, "# sent %ld\n", op->frames_abs);
}
seq_putc(m, '\n');
return 0;
}
len += snprintf(page + len, PAGE_SIZE - len, "\n");
*eof = 1;
return len;
static int bcm_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, bcm_proc_show, PDE(inode)->data);
}
static const struct file_operations bcm_proc_fops = {
.owner = THIS_MODULE,
.open = bcm_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/*
* bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface
* of the given bcm tx op
......@@ -1515,9 +1502,9 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
if (proc_dir) {
/* unique socket address as filename */
sprintf(bo->procname, "%p", sock);
bo->bcm_proc_read = create_proc_read_entry(bo->procname, 0644,
proc_dir,
bcm_read_proc, sk);
bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
proc_dir,
&bcm_proc_fops, sk);
}
return 0;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment