]> err.no Git - linux-2.6/blobdiff - drivers/isdn/hysdn/hysdn_procconf.c
Merge branch 'davem-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6] / drivers / isdn / hysdn / hysdn_procconf.c
index 877be9922c3d24de4480d77dc25f017e86548092..484299b031f82d49b91dfeb303099a1920824933 100644 (file)
@@ -207,30 +207,17 @@ hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t
 /* 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 */
-
-       return (i);
+       if (!(file->f_mode & FMODE_READ))
+               return -EPERM;  /* no permission to read */
+
+       if (!(cp = file->private_data))
+               return -EFAULT; /* should never happen */
+
+       return simple_read_from_buffer(buf, count, off, cp, strlen(cp));
 }                              /* hysdn_conf_read */
 
 /******************/
@@ -405,7 +392,8 @@ hysdn_procconf_init(void)
                sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
                if ((card->procconf = (void *) proc_create(conf_name,
                                                S_IFREG | S_IRUGO | S_IWUSR,
-                                               hysdn_proc_entry)) != NULL) {
+                                               hysdn_proc_entry,
+                                               &conf_fops)) != NULL) {
                        hysdn_proclog_init(card);       /* init the log file entry */
                }
                card = card->next;      /* next entry */