RDMA/cxgb4: Use simple_read_from_buffer() for debugfs handlers
We can replace our equivalent open-coded version. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
Родитель
8bbac892fb
Коммит
3160977a6e
|
@ -68,32 +68,8 @@ static ssize_t debugfs_read(struct file *file, char __user *buf, size_t count,
|
||||||
loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct c4iw_debugfs_data *d = file->private_data;
|
struct c4iw_debugfs_data *d = file->private_data;
|
||||||
loff_t pos = *ppos;
|
|
||||||
loff_t avail = d->pos;
|
|
||||||
|
|
||||||
if (pos < 0)
|
return simple_read_from_buffer(buf, count, ppos, d->buf, d->pos);
|
||||||
return -EINVAL;
|
|
||||||
if (pos >= avail)
|
|
||||||
return 0;
|
|
||||||
if (count > avail - pos)
|
|
||||||
count = avail - pos;
|
|
||||||
|
|
||||||
while (count) {
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
len = min((int)count, (int)d->pos - (int)pos);
|
|
||||||
if (copy_to_user(buf, d->buf + pos, len))
|
|
||||||
return -EFAULT;
|
|
||||||
if (len == 0)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
buf += len;
|
|
||||||
pos += len;
|
|
||||||
count -= len;
|
|
||||||
}
|
|
||||||
count = pos - *ppos;
|
|
||||||
*ppos = pos;
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_qp(int id, void *p, void *data)
|
static int dump_qp(int id, void *p, void *data)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче