diff mbox

RDMA/cxgb4: use simple_read_from_buffer() for debugfs handlers.

Message ID 20100929182133.30260.84058.stgit@build.ogc.int (mailing list archive)
State Accepted
Headers show

Commit Message

Steve Wise Sept. 29, 2010, 6:21 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index b254357..22a290d 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -68,32 +68,8 @@  static ssize_t debugfs_read(struct file *file, char __user *buf, size_t count,
 			    loff_t *ppos)
 {
 	struct c4iw_debugfs_data *d = file->private_data;
-	loff_t pos = *ppos;
-	loff_t avail = d->pos;
 
-	if (pos < 0)
-		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;
+	return simple_read_from_buffer(buf, count, ppos, d->buf, d->pos);
 }
 
 static int dump_qp(int id, void *p, void *data)