Skip to contentSkip to conversation

isdn: use simple_read_from_buffer()

PATCH Applied [email protected] 2 participants 2 messages Jun 9, 2008 – Jun 10, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 isdn: use simple_read_from_buffer()

From: Akinobu Mita <[email protected]>

---

 drivers/isdn/hysdn/hysdn_procconf.c |   27 ++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/isdn/hysdn/hysdn_procconf.c renamed from drivers/isdn/hysdn/hysdn_procconf.c~isdn-use-simple_read_from_buffer +7 -20
diff -puN drivers/isdn/hysdn/hysdn_procconf.c~isdn-use-simple_read_from_buffer drivers/isdn/hysdn/hysdn_procconf.c
@@ -207,30 +207,17 @@ hysdn_conf_write(struct file *file, cons
 /* read conf file -> output card info data */
 /*******************************************/
 static ssize_t
-hysdn_conf_read(struct file *file, char __user *buf, size_t count, loff_t * off)
+hysdn_conf_read(struct file *file, char __user *buf, size_t count, loff_t *off)
 {
 	char *cp;
-	int i;
 
-	if (file->f_mode & FMODE_READ) {
-		if (!(cp = file->private_data))
-			return (-EFAULT);	/* should never happen */
-		i = strlen(cp);	/* get total string length */
-		if (*off < i) {
-			/* still bytes to transfer */
-			cp += *off;	/* point to desired data offset */
-			i -= *off;	/* remaining length */
-			if (i > count)
-				i = count;	/* limit length to transfer */
-			if (copy_to_user(buf, cp, i))
-				return (-EFAULT);	/* copy error */
-			*off += i;	/* adjust offset */
-		} else
-			return (0);
-	} else
-		return (-EPERM);	/* no permission to read */
+	if (!(file->f_mode & FMODE_READ))
+		return -EPERM;	/* no permission to read */
 
-	return (i);
+	if (!(cp = file->private_data))
+		return -EFAULT;	/* should never happen */
+
+	return simple_read_from_buffer(buf, count, off, cp, strlen(cp));
 }				/* hysdn_conf_read */
 
 /******************/

_