Skip to content

Commit ea23ec2

Browse files
mitadavem330
authored andcommitted
isdn: use simple_read_from_buffer()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 495b36b commit ea23ec2

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

drivers/isdn/hysdn/hysdn_procconf.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -207,30 +207,17 @@ hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t
207207
/* read conf file -> output card info data */
208208
/*******************************************/
209209
static ssize_t
210-
hysdn_conf_read(struct file *file, char __user *buf, size_t count, loff_t * off)
210+
hysdn_conf_read(struct file *file, char __user *buf, size_t count, loff_t *off)
211211
{
212212
char *cp;
213-
int i;
214213

215-
if (file->f_mode & FMODE_READ) {
216-
if (!(cp = file->private_data))
217-
return (-EFAULT); /* should never happen */
218-
i = strlen(cp); /* get total string length */
219-
if (*off < i) {
220-
/* still bytes to transfer */
221-
cp += *off; /* point to desired data offset */
222-
i -= *off; /* remaining length */
223-
if (i > count)
224-
i = count; /* limit length to transfer */
225-
if (copy_to_user(buf, cp, i))
226-
return (-EFAULT); /* copy error */
227-
*off += i; /* adjust offset */
228-
} else
229-
return (0);
230-
} else
231-
return (-EPERM); /* no permission to read */
232-
233-
return (i);
214+
if (!(file->f_mode & FMODE_READ))
215+
return -EPERM; /* no permission to read */
216+
217+
if (!(cp = file->private_data))
218+
return -EFAULT; /* should never happen */
219+
220+
return simple_read_from_buffer(buf, count, off, cp, strlen(cp));
234221
} /* hysdn_conf_read */
235222

236223
/******************/

0 commit comments

Comments
 (0)