* [patch -v3 01/22] binfmt_misc: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 02/22] ocfs2: " Akinobu Mita
` (20 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
[-- Attachment #1: binfmt-misc-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1220 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
fs/binfmt_misc.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
Index: 2.6-git/fs/binfmt_misc.c
===================================================================
--- 2.6-git.orig/fs/binfmt_misc.c
+++ 2.6-git/fs/binfmt_misc.c
@@ -27,6 +27,7 @@
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/syscalls.h>
+#include <linux/fs.h>
#include <asm/uaccess.h>
@@ -535,31 +536,16 @@ static ssize_t
bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
{
Node *e = file->f_path.dentry->d_inode->i_private;
- loff_t pos = *ppos;
ssize_t res;
char *page;
- int len;
if (!(page = (char*) __get_free_page(GFP_KERNEL)))
return -ENOMEM;
entry_status(e, page);
- len = strlen(page);
- res = -EINVAL;
- if (pos < 0)
- goto out;
- res = 0;
- if (pos >= len)
- goto out;
- if (len < pos + nbytes)
- nbytes = len - pos;
- res = -EFAULT;
- if (copy_to_user(buf, page + pos, nbytes))
- goto out;
- *ppos = pos + nbytes;
- res = nbytes;
-out:
+ res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page));
+
free_page((unsigned long) page);
return res;
}
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 02/22] ocfs2: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
2008-06-04 11:56 ` [patch -v3 01/22] binfmt_misc: use simple_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-06 22:46 ` Joel Becker
2008-06-04 11:56 ` [patch -v3 03/22] ipc: " Akinobu Mita
` (19 subsequent siblings)
21 siblings, 1 reply; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Mark Fasheh, Joel Becker, ocfs2-devel
[-- Attachment #1: ocfs2-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1323 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <joel.becker@oracle.com>
Cc: ocfs2-devel@oss.oracle.com
---
fs/ocfs2/stack_user.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
Index: 2.6-git/fs/ocfs2/stack_user.c
===================================================================
--- 2.6-git.orig/fs/ocfs2/stack_user.c
+++ 2.6-git/fs/ocfs2/stack_user.c
@@ -549,26 +549,17 @@ static ssize_t ocfs2_control_read(struct
size_t count,
loff_t *ppos)
{
- char *proto_string = OCFS2_CONTROL_PROTO;
- size_t to_write = 0;
+ ssize_t ret;
- if (*ppos >= OCFS2_CONTROL_PROTO_LEN)
- return 0;
-
- to_write = OCFS2_CONTROL_PROTO_LEN - *ppos;
- if (to_write > count)
- to_write = count;
- if (copy_to_user(buf, proto_string + *ppos, to_write))
- return -EFAULT;
-
- *ppos += to_write;
+ ret = simple_read_from_buffer(buf, count, ppos,
+ OCFS2_CONTROL_PROTO, OCFS2_CONTROL_PROTO_LEN);
/* Have we read the whole protocol list? */
- if (*ppos >= OCFS2_CONTROL_PROTO_LEN)
+ if (ret > 0 && *ppos >= OCFS2_CONTROL_PROTO_LEN)
ocfs2_control_set_handshake_state(file,
OCFS2_CONTROL_HANDSHAKE_READ);
- return to_write;
+ return ret;
}
static int ocfs2_control_release(struct inode *inode, struct file *file)
--
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: [patch -v3 02/22] ocfs2: use simple_read_from_buffer
2008-06-04 11:56 ` [patch -v3 02/22] ocfs2: " Akinobu Mita
@ 2008-06-06 22:46 ` Joel Becker
0 siblings, 0 replies; 27+ messages in thread
From: Joel Becker @ 2008-06-06 22:46 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, akpm, Mark Fasheh, ocfs2-devel
On Wed, Jun 04, 2008 at 08:56:35PM +0900, Akinobu Mita wrote:
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Mark Fasheh <mfasheh@suse.com>
> Cc: Joel Becker <joel.becker@oracle.com>
> Cc: ocfs2-devel@oss.oracle.com
Acked-by: Joel Becker <joel.becker@oracle.com>
--
"Heav'n hath no rage like love to hatred turn'd, nor Hell a fury,
like a woman scorn'd."
- William Congreve
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch -v3 03/22] ipc: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
2008-06-04 11:56 ` [patch -v3 01/22] binfmt_misc: use simple_read_from_buffer Akinobu Mita
2008-06-04 11:56 ` [patch -v3 02/22] ocfs2: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 04/22] isdn: " Akinobu Mita
` (18 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
[-- Attachment #1: mqueue-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1516 bytes --]
Also this patch kills unneccesary trailing NULL character.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
ipc/mqueue.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
Index: 2.6-git/ipc/mqueue.c
===================================================================
--- 2.6-git.orig/ipc/mqueue.c
+++ 2.6-git/ipc/mqueue.c
@@ -314,15 +314,11 @@ static int mqueue_unlink(struct inode *d
* through std routines)
*/
static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
- size_t count, loff_t * off)
+ size_t count, loff_t *off)
{
struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode);
char buffer[FILENT_SIZE];
- size_t slen;
- loff_t o;
-
- if (!count)
- return 0;
+ ssize_t ret;
spin_lock(&info->lock);
snprintf(buffer, sizeof(buffer),
@@ -335,21 +331,14 @@ static ssize_t mqueue_read_file(struct f
pid_vnr(info->notify_owner));
spin_unlock(&info->lock);
buffer[sizeof(buffer)-1] = '\0';
- slen = strlen(buffer)+1;
-
- o = *off;
- if (o > slen)
- return 0;
-
- if (o + count > slen)
- count = slen - o;
- if (copy_to_user(u_data, buffer + o, count))
- return -EFAULT;
+ ret = simple_read_from_buffer(u_data, count, off, buffer,
+ strlen(buffer));
+ if (ret <= 0)
+ return ret;
- *off = o + count;
filp->f_path.dentry->d_inode->i_atime = filp->f_path.dentry->d_inode->i_ctime = CURRENT_TIME;
- return count;
+ return ret;
}
static int mqueue_flush_file(struct file *filp, fl_owner_t id)
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 04/22] isdn: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (2 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 03/22] ipc: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 05/22] s390/vmcp: " Akinobu Mita
` (17 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Karsten Keil
[-- Attachment #1: isdn-hysdn-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1671 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Karsten Keil <kkeil@suse.de>
---
drivers/isdn/hysdn/hysdn_procconf.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
Index: 2.6-git/drivers/isdn/hysdn/hysdn_procconf.c
===================================================================
--- 2.6-git.orig/drivers/isdn/hysdn/hysdn_procconf.c
+++ 2.6-git/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 */
/******************/
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 05/22] s390/vmcp: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (3 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 04/22] isdn: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 06/22] s390: " Akinobu Mita
` (16 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Christian Borntraeger, Martin Schwidefsky, Heiko Carstens,
linux390, linux-s390
[-- Attachment #1: s390-vmcp-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1619 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
drivers/s390/char/vmcp.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
Index: 2.6-git/drivers/s390/char/vmcp.c
===================================================================
--- 2.6-git.orig/drivers/s390/char/vmcp.c
+++ 2.6-git/drivers/s390/char/vmcp.c
@@ -61,30 +61,24 @@ static int vmcp_release(struct inode *in
static ssize_t
vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
{
- size_t tocopy;
+ ssize_t ret;
+ size_t size;
struct vmcp_session *session;
- session = (struct vmcp_session *)file->private_data;
+ session = file->private_data;
if (mutex_lock_interruptible(&session->mutex))
return -ERESTARTSYS;
if (!session->response) {
mutex_unlock(&session->mutex);
return 0;
}
- if (*ppos > session->resp_size) {
- mutex_unlock(&session->mutex);
- return 0;
- }
- tocopy = min(session->resp_size - (size_t) (*ppos), count);
- tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
+ size = min_t(size_t, session->resp_size, session->bufsize);
+ ret = simple_read_from_buffer(buff, count, ppos,
+ session->response, size);
- if (copy_to_user(buff, session->response + (*ppos), tocopy)) {
- mutex_unlock(&session->mutex);
- return -EFAULT;
- }
mutex_unlock(&session->mutex);
- *ppos += tocopy;
- return tocopy;
+
+ return ret;
}
static ssize_t
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 06/22] s390: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (4 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 05/22] s390/vmcp: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 07/22] nwflash: " Akinobu Mita
` (15 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: hypfs-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1487 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
arch/s390/hypfs/inode.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
Index: 2.6-git/arch/s390/hypfs/inode.c
===================================================================
--- 2.6-git.orig/arch/s390/hypfs/inode.c
+++ 2.6-git/arch/s390/hypfs/inode.c
@@ -150,33 +150,24 @@ static ssize_t hypfs_aio_read(struct kio
unsigned long nr_segs, loff_t offset)
{
char *data;
- size_t len;
+ ssize_t ret;
struct file *filp = iocb->ki_filp;
/* XXX: temporary */
char __user *buf = iov[0].iov_base;
size_t count = iov[0].iov_len;
- if (nr_segs != 1) {
- count = -EINVAL;
- goto out;
- }
+ if (nr_segs != 1)
+ return -EINVAL;
data = filp->private_data;
- len = strlen(data);
- if (offset > len) {
- count = 0;
- goto out;
- }
- if (count > len - offset)
- count = len - offset;
- if (copy_to_user(buf, data + offset, count)) {
- count = -EFAULT;
- goto out;
- }
- iocb->ki_pos += count;
+ ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data));
+ if (ret <= 0)
+ return ret;
+
+ iocb->ki_pos += ret;
file_accessed(filp);
-out:
- return count;
+
+ return ret;
}
static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t offset)
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 07/22] nwflash: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (5 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 06/22] s390: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 08/22] usbmon: " Akinobu Mita
` (14 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Russell King
[-- Attachment #1: nwflash-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1486 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
drivers/char/nwflash.c | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
Index: 2.6-git/drivers/char/nwflash.c
===================================================================
--- 2.6-git.orig/drivers/char/nwflash.c
+++ 2.6-git/drivers/char/nwflash.c
@@ -122,35 +122,20 @@ static int flash_ioctl(struct inode *ino
static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
loff_t *ppos)
{
- unsigned long p = *ppos;
- unsigned int count = size;
- int ret = 0;
+ ssize_t ret;
if (flashdebug)
printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, "
"buffer=%p, count=0x%X.\n", p, buf, count);
+ /*
+ * We now lock against reads and writes. --rmk
+ */
+ if (mutex_lock_interruptible(&nwflash_mutex))
+ return -ERESTARTSYS;
- if (count)
- ret = -ENXIO;
+ ret = simple_read_from_buffer(buf, size, ppos, FLASH_BASE, gbFlashSize);
+ mutex_unlock(&nwflash_mutex);
- if (p < gbFlashSize) {
- if (count > gbFlashSize - p)
- count = gbFlashSize - p;
-
- /*
- * We now lock against reads and writes. --rmk
- */
- if (mutex_lock_interruptible(&nwflash_mutex))
- return -ERESTARTSYS;
-
- ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
- if (ret == 0) {
- ret = count;
- *ppos += count;
- } else
- ret = -EFAULT;
- mutex_unlock(&nwflash_mutex);
- }
return ret;
}
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 08/22] usbmon: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (6 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 07/22] nwflash: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 09/22] ttusb: use simple_read_from_buffer() Akinobu Mita
` (13 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Greg Kroah-Hartman
[-- Attachment #1: mon-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1090 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <greg@kroah.com>
---
drivers/usb/mon/mon_stat.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
Index: 2.6-git/drivers/usb/mon/mon_stat.c
===================================================================
--- 2.6-git.orig/drivers/usb/mon/mon_stat.c
+++ 2.6-git/drivers/usb/mon/mon_stat.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/usb.h>
+#include <linux/fs.h>
#include <asm/uaccess.h>
#include "usb_mon.h"
@@ -42,19 +43,8 @@ static ssize_t mon_stat_read(struct file
size_t nbytes, loff_t *ppos)
{
struct snap *sp = file->private_data;
- loff_t pos = *ppos;
- int cnt;
- if (pos < 0 || pos >= sp->slen)
- return 0;
- if (nbytes == 0)
- return 0;
- if ((cnt = sp->slen - pos) > nbytes)
- cnt = nbytes;
- if (copy_to_user(buf, sp->str + pos, cnt))
- return -EFAULT;
- *ppos = pos + cnt;
- return cnt;
+ return simple_read_from_buffer(buf, nbytes, ppos, sp->str, sp->slen);
}
static int mon_stat_release(struct inode *inode, struct file *file)
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 09/22] ttusb: use simple_read_from_buffer()
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (7 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 08/22] usbmon: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 10/22] airo: use simple_read_from_buffer Akinobu Mita
` (12 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: v4l-dvb-maintainer
[-- Attachment #1: ttusb-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1191 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: v4l-dvb-maintainer@linuxtv.org
---
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
Index: 2.6-git/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
===================================================================
--- 2.6-git.orig/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ 2.6-git/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -19,6 +19,7 @@
#include <linux/errno.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
+#include <linux/fs.h>
#include "dvb_frontend.h"
#include "dmxdev.h"
@@ -983,22 +984,9 @@ static int stc_open(struct inode *inode,
}
static ssize_t stc_read(struct file *file, char *buf, size_t count,
- loff_t * offset)
+ loff_t *offset)
{
- int tc = count;
-
- if ((tc + *offset) > 8192)
- tc = 8192 - *offset;
-
- if (tc < 0)
- return 0;
-
- if (copy_to_user(buf, stc_firmware + *offset, tc))
- return -EFAULT;
-
- *offset += tc;
-
- return tc;
+ return simple_read_from_buffer(buf, count, offset, stc_firmware, 8192);
}
static int stc_release(struct inode *inode, struct file *file)
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 10/22] airo: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (8 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 09/22] ttusb: use simple_read_from_buffer() Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 11/22] cris: " Akinobu Mita
` (11 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: John W. Linville, netdev, linux-wireless
[-- Attachment #1: airo-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1108 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: netdev@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
---
drivers/net/wireless/airo.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
Index: 2.6-git/drivers/net/wireless/airo.c
===================================================================
--- 2.6-git.orig/drivers/net/wireless/airo.c
+++ 2.6-git/drivers/net/wireless/airo.c
@@ -4560,22 +4560,13 @@ static ssize_t proc_read( struct file *f
size_t len,
loff_t *offset )
{
- loff_t pos = *offset;
- struct proc_data *priv = (struct proc_data*)file->private_data;
+ struct proc_data *priv = file->private_data;
if (!priv->rbuffer)
return -EINVAL;
- if (pos < 0)
- return -EINVAL;
- if (pos >= priv->readlen)
- return 0;
- if (len > priv->readlen - pos)
- len = priv->readlen - pos;
- if (copy_to_user(buffer, priv->rbuffer + pos, len))
- return -EFAULT;
- *offset = pos + len;
- return len;
+ return simple_read_from_buffer(buffer, len, offset, priv->rbuffer,
+ priv->readlen);
}
/*
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 11/22] cris: use simple_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (9 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 10/22] airo: use simple_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 12/22] introduce memory_read_from_buffer Akinobu Mita
` (10 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Mikael Starvik, Jesper Nilsson, dev-etrax
[-- Attachment #1: cris-profile-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1065 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: dev-etrax@axis.com
---
arch/cris/kernel/profile.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
Index: 2.6-git/arch/cris/kernel/profile.c
===================================================================
--- 2.6-git.orig/arch/cris/kernel/profile.c
+++ 2.6-git/arch/cris/kernel/profile.c
@@ -35,19 +35,16 @@ read_cris_profile(struct file *file, cha
size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
+ ssize_t ret;
- if (p > SAMPLE_BUFFER_SIZE)
- return 0;
+ ret = simple_read_from_buffer(buf, count, ppos, sample_buffer,
+ SAMPLE_BUFFER_SIZE);
+ if (ret < 0)
+ return ret;
- if (p + count > SAMPLE_BUFFER_SIZE)
- count = SAMPLE_BUFFER_SIZE - p;
- if (copy_to_user(buf, sample_buffer + p,count))
- return -EFAULT;
+ memset(sample_buffer + p, 0, ret);
- memset(sample_buffer + p, 0, count);
- *ppos += count;
-
- return count;
+ return ret;
}
static ssize_t
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 12/22] introduce memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (10 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 11/22] cris: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 13/22] dcdbas: use memory_read_from_buffer Akinobu Mita
` (9 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
[-- Attachment #1: memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 2295 bytes --]
This patch introduces memory_read_from_buffer.
The only difference between memory_read_from_buffer and simple_read_from_buffer
is which address space the function copies to.
simple_read_from_buffer copies to user space memory.
memory_read_from_buffer copies to normal memory.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
fs/libfs.c | 18 ++++++++++++++++++
include/linux/fs.h | 5 ++++-
2 files changed, 22 insertions(+), 1 deletion(-)
Index: 2.6-git/fs/libfs.c
===================================================================
--- 2.6-git.orig/fs/libfs.c
+++ 2.6-git/fs/libfs.c
@@ -528,6 +528,23 @@ ssize_t simple_read_from_buffer(void __u
return count;
}
+ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
+ const void *from, size_t available)
+{
+ loff_t pos = *ppos;
+
+ if (pos < 0)
+ return -EINVAL;
+ if (pos >= available)
+ return 0;
+ if (count > available - pos)
+ count = available - pos;
+ memcpy(to, from + pos, count);
+ *ppos = pos + count;
+
+ return count;
+}
+
/*
* Transaction based IO.
* The file expects a single write which triggers the transaction, and then
@@ -800,6 +817,7 @@ EXPORT_SYMBOL(simple_statfs);
EXPORT_SYMBOL(simple_sync_file);
EXPORT_SYMBOL(simple_unlink);
EXPORT_SYMBOL(simple_read_from_buffer);
+EXPORT_SYMBOL(memory_read_from_buffer);
EXPORT_SYMBOL(simple_transaction_get);
EXPORT_SYMBOL(simple_transaction_read);
EXPORT_SYMBOL(simple_transaction_release);
Index: 2.6-git/include/linux/fs.h
===================================================================
--- 2.6-git.orig/include/linux/fs.h
+++ 2.6-git/include/linux/fs.h
@@ -2000,7 +2000,10 @@ extern int simple_fill_super(struct supe
extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
extern void simple_release_fs(struct vfsmount **mount, int *count);
-extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
+extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
+ loff_t *ppos, const void *from, size_t available);
+extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
+ const void *from, size_t available);
#ifdef CONFIG_MIGRATION
extern int buffer_migrate_page(struct address_space *,
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 13/22] dcdbas: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (11 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 12/22] introduce memory_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 14/22] dell_rbu: " Akinobu Mita
` (8 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Doug Warzecha
[-- Attachment #1: dcdbas-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1101 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Doug Warzecha <Douglas_Warzecha@dell.com>
---
drivers/firmware/dcdbas.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
Index: 2.6-git/drivers/firmware/dcdbas.c
===================================================================
--- 2.6-git.orig/drivers/firmware/dcdbas.c
+++ 2.6-git/drivers/firmware/dcdbas.c
@@ -34,6 +34,7 @@
#include <linux/string.h>
#include <linux/types.h>
#include <linux/mutex.h>
+#include <linux/fs.h>
#include <asm/io.h>
#include "dcdbas.h"
@@ -152,20 +153,11 @@ static ssize_t smi_data_read(struct kobj
struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t count)
{
- size_t max_read;
ssize_t ret;
mutex_lock(&smi_data_lock);
-
- if (pos >= smi_data_buf_size) {
- ret = 0;
- goto out;
- }
-
- max_read = smi_data_buf_size - pos;
- ret = min(max_read, count);
- memcpy(buf, smi_data_buf + pos, ret);
-out:
+ ret = memory_read_from_buffer(buf, count, &pos, smi_data_buf,
+ smi_data_buf_size);
mutex_unlock(&smi_data_lock);
return ret;
}
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 14/22] dell_rbu: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (12 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 13/22] dcdbas: use memory_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 15/22] firmware: " Akinobu Mita
` (7 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Abhay Salunke
[-- Attachment #1: dell_rbu-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1930 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Abhay Salunke <abhay_salunke@dell.com>
---
drivers/firmware/dell_rbu.c | 29 ++++-------------------------
1 file changed, 4 insertions(+), 25 deletions(-)
Index: 2.6-git/drivers/firmware/dell_rbu.c
===================================================================
--- 2.6-git.orig/drivers/firmware/dell_rbu.c
+++ 2.6-git/drivers/firmware/dell_rbu.c
@@ -44,6 +44,7 @@
#include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <linux/dma-mapping.h>
+#include <linux/fs.h>
MODULE_AUTHOR("Abhay Salunke <abhay_salunke@dell.com>");
MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems");
@@ -507,11 +508,6 @@ static ssize_t read_packet_data(char *bu
static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count)
{
- unsigned char *ptemp = NULL;
- size_t bytes_left = 0;
- size_t data_length = 0;
- ssize_t ret_count = 0;
-
/* check to see if we have something to return */
if ((rbu_data.image_update_buffer == NULL) ||
(rbu_data.bios_image_size == 0)) {
@@ -519,28 +515,11 @@ static ssize_t read_rbu_mono_data(char *
"bios_image_size %lu\n",
rbu_data.image_update_buffer,
rbu_data.bios_image_size);
- ret_count = -ENOMEM;
- goto read_rbu_data_exit;
- }
-
- if (pos > rbu_data.bios_image_size) {
- ret_count = 0;
- goto read_rbu_data_exit;
+ return -ENOMEM;
}
- bytes_left = rbu_data.bios_image_size - pos;
- data_length = min(bytes_left, count);
-
- ptemp = rbu_data.image_update_buffer;
- memcpy(buffer, (ptemp + pos), data_length);
-
- if ((pos + count) > rbu_data.bios_image_size)
- /* this was the last copy */
- ret_count = bytes_left;
- else
- ret_count = count;
- read_rbu_data_exit:
- return ret_count;
+ return memory_read_from_buffer(buffer, count, &pos,
+ rbu_data.image_update_buffer, rbu_data.bios_image_size);
}
static ssize_t read_rbu_data(struct kobject *kobj,
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 15/22] firmware: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (13 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 14/22] dell_rbu: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 16/22] acpi: " Akinobu Mita
` (6 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Greg Kroah-Hartman
[-- Attachment #1: firmware-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1279 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <greg@kroah.com>
---
drivers/base/firmware_class.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
Index: 2.6-git/drivers/base/firmware_class.c
===================================================================
--- 2.6-git.orig/drivers/base/firmware_class.c
+++ 2.6-git/drivers/base/firmware_class.c
@@ -17,6 +17,7 @@
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/kthread.h>
+#include <linux/fs.h>
#include <linux/firmware.h>
#include "base.h"
@@ -176,7 +177,7 @@ firmware_data_read(struct kobject *kobj,
struct device *dev = to_dev(kobj);
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
struct firmware *fw;
- ssize_t ret_count = count;
+ ssize_t ret_count;
mutex_lock(&fw_lock);
fw = fw_priv->fw;
@@ -184,14 +185,8 @@ firmware_data_read(struct kobject *kobj,
ret_count = -ENODEV;
goto out;
}
- if (offset > fw->size) {
- ret_count = 0;
- goto out;
- }
- if (offset + ret_count > fw->size)
- ret_count = fw->size - offset;
-
- memcpy(buffer, fw->data + offset, ret_count);
+ ret_count = memory_read_from_buffer(buffer, count, &offset,
+ fw->data, fw->size);
out:
mutex_unlock(&fw_lock);
return ret_count;
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 16/22] acpi: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (14 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 15/22] firmware: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-05 1:21 ` Zhao Yakui
2008-06-04 11:56 ` [patch -v3 17/22] aty: " Akinobu Mita
` (5 subsequent siblings)
21 siblings, 1 reply; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Len Brown, linux-acpi
[-- Attachment #1: acpi-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1245 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: linux-acpi@vger.kernel.org
---
drivers/acpi/system.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
Index: 2.6-git/drivers/acpi/system.c
===================================================================
--- 2.6-git.orig/drivers/acpi/system.c
+++ 2.6-git/drivers/acpi/system.c
@@ -77,7 +77,6 @@ static ssize_t acpi_table_show(struct ko
container_of(bin_attr, struct acpi_table_attr, attr);
struct acpi_table_header *table_header = NULL;
acpi_status status;
- ssize_t ret_count = count;
status =
acpi_get_table(table_attr->name, table_attr->instance,
@@ -85,18 +84,8 @@ static ssize_t acpi_table_show(struct ko
if (ACPI_FAILURE(status))
return -ENODEV;
- if (offset >= table_header->length) {
- ret_count = 0;
- goto end;
- }
-
- if (offset + ret_count > table_header->length)
- ret_count = table_header->length - offset;
-
- memcpy(buf, ((char *)table_header) + offset, ret_count);
-
- end:
- return ret_count;
+ return memory_read_from_buffer(buf, count, &offset,
+ table_header, table_header->length);
}
static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
--
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: [patch -v3 16/22] acpi: use memory_read_from_buffer
2008-06-04 11:56 ` [patch -v3 16/22] acpi: " Akinobu Mita
@ 2008-06-05 1:21 ` Zhao Yakui
2008-06-05 1:29 ` Andrew Morton
0 siblings, 1 reply; 27+ messages in thread
From: Zhao Yakui @ 2008-06-05 1:21 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, akpm, Len Brown, linux-acpi
On Wed, 2008-06-04 at 20:56 +0900, Akinobu Mita wrote:
> plain text document attachment
> (acpi-use-memory-read-from-buffer.patch)
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Len Brown <len.brown@intel.com>
> Cc: linux-acpi@vger.kernel.org
> ---
> drivers/acpi/system.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> Index: 2.6-git/drivers/acpi/system.c
> ===================================================================
> --- 2.6-git.orig/drivers/acpi/system.c
> +++ 2.6-git/drivers/acpi/system.c
> @@ -77,7 +77,6 @@ static ssize_t acpi_table_show(struct ko
> container_of(bin_attr, struct acpi_table_attr, attr);
> struct acpi_table_header *table_header = NULL;
> acpi_status status;
> - ssize_t ret_count = count;
>
> status =
> acpi_get_table(table_attr->name, table_attr->instance,
> @@ -85,18 +84,8 @@ static ssize_t acpi_table_show(struct ko
> if (ACPI_FAILURE(status))
> return -ENODEV;
>
> - if (offset >= table_header->length) {
> - ret_count = 0;
> - goto end;
> - }
> -
> - if (offset + ret_count > table_header->length)
> - ret_count = table_header->length - offset;
> -
> - memcpy(buf, ((char *)table_header) + offset, ret_count);
> -
> - end:
> - return ret_count;
> + return memory_read_from_buffer(buf, count, &offset,
> + table_header, table_header->length);
> }
it seems that there is no definition of memory_read_from_buffer.
Where is the function of memory_read_from_buffer defined?
Is there a bug about the current function of acpi_table_show?
Thanks.
>
> static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
>
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: [patch -v3 16/22] acpi: use memory_read_from_buffer
2008-06-05 1:21 ` Zhao Yakui
@ 2008-06-05 1:29 ` Andrew Morton
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Morton @ 2008-06-05 1:29 UTC (permalink / raw)
To: Zhao Yakui; +Cc: Akinobu Mita, linux-kernel, Len Brown, linux-acpi
On Thu, 05 Jun 2008 09:21:26 +0800 Zhao Yakui <yakui.zhao@intel.com> wrote:
> On Wed, 2008-06-04 at 20:56 +0900, Akinobu Mita wrote:
> > plain text document attachment
> > (acpi-use-memory-read-from-buffer.patch)
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: linux-acpi@vger.kernel.org
> > ---
> > drivers/acpi/system.c | 15 ++-------------
> > 1 file changed, 2 insertions(+), 13 deletions(-)
> >
> > Index: 2.6-git/drivers/acpi/system.c
> > ===================================================================
> > --- 2.6-git.orig/drivers/acpi/system.c
> > +++ 2.6-git/drivers/acpi/system.c
> > @@ -77,7 +77,6 @@ static ssize_t acpi_table_show(struct ko
> > container_of(bin_attr, struct acpi_table_attr, attr);
> > struct acpi_table_header *table_header = NULL;
> > acpi_status status;
> > - ssize_t ret_count = count;
> >
> > status =
> > acpi_get_table(table_attr->name, table_attr->instance,
> > @@ -85,18 +84,8 @@ static ssize_t acpi_table_show(struct ko
> > if (ACPI_FAILURE(status))
> > return -ENODEV;
> >
> > - if (offset >= table_header->length) {
> > - ret_count = 0;
> > - goto end;
> > - }
> > -
> > - if (offset + ret_count > table_header->length)
> > - ret_count = table_header->length - offset;
> > -
> > - memcpy(buf, ((char *)table_header) + offset, ret_count);
> > -
> > - end:
> > - return ret_count;
> > + return memory_read_from_buffer(buf, count, &offset,
> > + table_header, table_header->length);
> > }
> it seems that there is no definition of memory_read_from_buffer.
> Where is the function of memory_read_from_buffer defined?
Earlier in the patch series. (The "16/22" is a hint!)
> Is there a bug about the current function of acpi_table_show?
No, it's just a cleanup.
From: Akinobu Mita <akinobu.mita@gmail.com>
This patch introduces memory_read_from_buffer().
The only difference between memory_read_from_buffer() and
simple_read_from_buffer() is which address space the function copies to.
simple_read_from_buffer copies to user space memory.
memory_read_from_buffer copies to normal memory.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Doug Warzecha <Douglas_Warzecha@dell.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Abhay Salunke <Abhay_Salunke@dell.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Markus Rechberger <markus.rechberger@amd.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Bob Moore <robert.moore@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Len Brown <lenb@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Cc: Michael Holzheu <holzheu@de.ibm.com>
Cc: Brian King <brking@us.ibm.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Andrew Vasquez <linux-driver@qlogic.com>
Cc: Seokmann Ju <seokmann.ju@qlogic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/libfs.c | 18 ++++++++++++++++++
include/linux/fs.h | 5 ++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff -puN fs/libfs.c~introduce-memory_read_from_buffer fs/libfs.c
--- a/fs/libfs.c~introduce-memory_read_from_buffer
+++ a/fs/libfs.c
@@ -528,6 +528,23 @@ ssize_t simple_read_from_buffer(void __u
return count;
}
+ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
+ const void *from, size_t available)
+{
+ loff_t pos = *ppos;
+
+ if (pos < 0)
+ return -EINVAL;
+ if (pos >= available)
+ return 0;
+ if (count > available - pos)
+ count = available - pos;
+ memcpy(to, from + pos, count);
+ *ppos = pos + count;
+
+ return count;
+}
+
/*
* Transaction based IO.
* The file expects a single write which triggers the transaction, and then
@@ -800,6 +817,7 @@ EXPORT_SYMBOL(simple_statfs);
EXPORT_SYMBOL(simple_sync_file);
EXPORT_SYMBOL(simple_unlink);
EXPORT_SYMBOL(simple_read_from_buffer);
+EXPORT_SYMBOL(memory_read_from_buffer);
EXPORT_SYMBOL(simple_transaction_get);
EXPORT_SYMBOL(simple_transaction_read);
EXPORT_SYMBOL(simple_transaction_release);
diff -puN include/linux/fs.h~introduce-memory_read_from_buffer include/linux/fs.h
--- a/include/linux/fs.h~introduce-memory_read_from_buffer
+++ a/include/linux/fs.h
@@ -2025,7 +2025,10 @@ extern int simple_fill_super(struct supe
extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
extern void simple_release_fs(struct vfsmount **mount, int *count);
-extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
+extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
+ loff_t *ppos, const void *from, size_t available);
+extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
+ const void *from, size_t available);
#ifdef CONFIG_MIGRATION
extern int buffer_migrate_page(struct address_space *,
_
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch -v3 17/22] aty: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (15 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 16/22] acpi: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 18/22] zorro: " Akinobu Mita
` (4 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Benjamin Herrenschmidt, linux-fbdev-devel
[-- Attachment #1: aty-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1035 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-fbdev-devel@lists.sourceforge.net
---
drivers/video/aty/radeon_base.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
Index: 2.6-git/drivers/video/aty/radeon_base.c
===================================================================
--- 2.6-git.orig/drivers/video/aty/radeon_base.c
+++ 2.6-git/drivers/video/aty/radeon_base.c
@@ -70,6 +70,7 @@
#include <linux/pci.h>
#include <linux/vmalloc.h>
#include <linux/device.h>
+#include <linux/fs.h>
#include <asm/io.h>
#include <linux/uaccess.h>
@@ -2098,15 +2099,7 @@ static void radeon_identify_vram(struct
static ssize_t radeon_show_one_edid(char *buf, loff_t off, size_t count, const u8 *edid)
{
- if (off > EDID_LENGTH)
- return 0;
-
- if (off + count > EDID_LENGTH)
- count = EDID_LENGTH - off;
-
- memcpy(buf, edid + off, count);
-
- return count;
+ return memory_read_from_buffer(buf, count, &off, edid, EDID_LENGTH);
}
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 18/22] zorro: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (16 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 17/22] aty: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 19/22] s390/cio: " Akinobu Mita
` (3 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Geert Uytterhoeven
[-- Attachment #1: zorro-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1232 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/zorro/zorro-sysfs.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
Index: 2.6-git/drivers/zorro/zorro-sysfs.c
===================================================================
--- 2.6-git.orig/drivers/zorro/zorro-sysfs.c
+++ 2.6-git/drivers/zorro/zorro-sysfs.c
@@ -15,6 +15,7 @@
#include <linux/zorro.h>
#include <linux/stat.h>
#include <linux/string.h>
+#include <linux/fs.h>
#include "zorro.h"
@@ -56,12 +57,6 @@ static ssize_t zorro_read_config(struct
struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
kobj));
struct ConfigDev cd;
- unsigned int size = sizeof(cd);
-
- if (off > size)
- return 0;
- if (off+count > size)
- count = size-off;
/* Construct a ConfigDev */
memset(&cd, 0, sizeof(cd));
@@ -71,8 +66,7 @@ static ssize_t zorro_read_config(struct
cd.cd_BoardAddr = (void *)zorro_resource_start(z);
cd.cd_BoardSize = zorro_resource_len(z);
- memcpy(buf, (void *)&cd+off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
}
static struct bin_attribute zorro_config_attr = {
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 19/22] s390/cio: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (17 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 18/22] zorro: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 20/22] s390: " Akinobu Mita
` (2 subsequent siblings)
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: cio-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1259 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
drivers/s390/cio/chp.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
Index: 2.6-git/drivers/s390/cio/chp.c
===================================================================
--- 2.6-git.orig/drivers/s390/cio/chp.c
+++ 2.6-git/drivers/s390/cio/chp.c
@@ -15,6 +15,7 @@
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/errno.h>
+#include <linux/fs.h>
#include <asm/chpid.h>
#include <asm/sclp.h>
@@ -141,21 +142,14 @@ static ssize_t chp_measurement_chars_rea
{
struct channel_path *chp;
struct device *device;
- unsigned int size;
device = container_of(kobj, struct device, kobj);
chp = to_channelpath(device);
if (!chp->cmg_chars)
return 0;
- size = sizeof(struct cmg_chars);
-
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, chp->cmg_chars + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off,
+ chp->cmg_chars, sizeof(struct cmg_chars));
}
static struct bin_attribute chp_measurement_chars_attr = {
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 20/22] s390: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (18 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 19/22] s390/cio: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 21/22] ipr: " Akinobu Mita
2008-06-04 11:56 ` [patch -v3 22/22] qla2xxx: " Akinobu Mita
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: s390-ipl-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1685 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
arch/s390/kernel/ipl.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
Index: 2.6-git/arch/s390/kernel/ipl.c
===================================================================
--- 2.6-git.orig/arch/s390/kernel/ipl.c
+++ 2.6-git/arch/s390/kernel/ipl.c
@@ -14,6 +14,7 @@
#include <linux/delay.h>
#include <linux/reboot.h>
#include <linux/ctype.h>
+#include <linux/fs.h>
#include <asm/ipl.h>
#include <asm/smp.h>
#include <asm/setup.h>
@@ -285,14 +286,8 @@ static struct kobj_attribute sys_ipl_dev
static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
- unsigned int size = IPL_PARMBLOCK_SIZE;
-
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START,
+ IPL_PARMBLOCK_SIZE);
}
static struct bin_attribute ipl_parameter_attr = {
@@ -310,12 +305,7 @@ static ssize_t ipl_scp_data_read(struct
unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, scp_data + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, scp_data, size);
}
static struct bin_attribute ipl_scp_data_attr = {
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 21/22] ipr: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (19 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 20/22] s390: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-04 11:56 ` [patch -v3 22/22] qla2xxx: " Akinobu Mita
21 siblings, 0 replies; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Brian King, James E.J. Bottomley, linux-scsi
[-- Attachment #1: scsi-ipr-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1185 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian King <brking@us.ibm.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/ipr.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
Index: 2.6-git/drivers/scsi/ipr.c
===================================================================
--- 2.6-git.orig/drivers/scsi/ipr.c
+++ 2.6-git/drivers/scsi/ipr.c
@@ -2455,20 +2455,14 @@ static ssize_t ipr_read_trace(struct kob
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
- int size = IPR_TRACE_SIZE;
- char *src = (char *)ioa_cfg->trace;
-
- if (off > size)
- return 0;
- if (off + count > size) {
- size -= off;
- count = size;
- }
+ ssize_t ret;
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
- memcpy(buf, &src[off], count);
+ ret = memory_read_from_buffer(buf, count, &off, ioa_cfg->trace,
+ IPR_TRACE_SIZE);
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
- return count;
+
+ return ret;
}
static struct bin_attribute ipr_trace_attr = {
--
^ permalink raw reply [flat|nested] 27+ messages in thread* [patch -v3 22/22] qla2xxx: use memory_read_from_buffer
2008-06-04 11:56 [patch -v3 00/22] use simple_read_from_buffer and memory_read_from_buffer Akinobu Mita
` (20 preceding siblings ...)
2008-06-04 11:56 ` [patch -v3 21/22] ipr: " Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
2008-06-06 17:06 ` Andrew Vasquez
21 siblings, 1 reply; 27+ messages in thread
From: Akinobu Mita @ 2008-06-04 11:56 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Andrew Vasquez, James E.J. Bottomley, linux-scsi
[-- Attachment #1: scsi-qla2xxx-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 2893 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Andrew Vasquez <linux-driver@qlogic.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/qla2xxx/qla_attr.c | 45 ++++++++--------------------------------
1 file changed, 10 insertions(+), 35 deletions(-)
Index: 2.6-git/drivers/scsi/qla2xxx/qla_attr.c
===================================================================
--- 2.6-git.orig/drivers/scsi/qla2xxx/qla_attr.c
+++ 2.6-git/drivers/scsi/qla2xxx/qla_attr.c
@@ -8,6 +8,7 @@
#include <linux/kthread.h>
#include <linux/vmalloc.h>
+#include <linux/fs.h>
static int qla24xx_vport_disable(struct fc_vport *, bool);
@@ -20,18 +21,12 @@ qla2x00_sysfs_read_fw_dump(struct kobjec
{
struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
struct device, kobj)));
- char *rbuf = (char *)ha->fw_dump;
if (ha->fw_dump_reading == 0)
return 0;
- if (off > ha->fw_dump_len)
- return 0;
- if (off + count > ha->fw_dump_len)
- count = ha->fw_dump_len - off;
- memcpy(buf, &rbuf[off], count);
-
- return (count);
+ return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
+ ha->fw_dump_len);
}
static ssize_t
@@ -91,20 +86,13 @@ qla2x00_sysfs_read_nvram(struct kobject
{
struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
struct device, kobj)));
- int size = ha->nvram_size;
- char *nvram_cache = ha->nvram;
- if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
+ if (!capable(CAP_SYS_ADMIN))
return 0;
- if (off + count > size) {
- size -= off;
- count = size;
- }
/* Read NVRAM data from cache. */
- memcpy(buf, &nvram_cache[off], count);
-
- return count;
+ return memory_read_from_buffer(buf, count, &off, ha->nvram,
+ ha->nvram_size);
}
static ssize_t
@@ -172,14 +160,9 @@ qla2x00_sysfs_read_optrom(struct kobject
if (ha->optrom_state != QLA_SREADING)
return 0;
- if (off > ha->optrom_region_size)
- return 0;
- if (off + count > ha->optrom_region_size)
- count = ha->optrom_region_size - off;
- memcpy(buf, &ha->optrom_buffer[off], count);
-
- return count;
+ return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
+ ha->optrom_region_size);
}
static ssize_t
@@ -371,20 +354,12 @@ qla2x00_sysfs_read_vpd(struct kobject *k
{
struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
struct device, kobj)));
- int size = ha->vpd_size;
- char *vpd_cache = ha->vpd;
- if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
+ if (!capable(CAP_SYS_ADMIN))
return 0;
- if (off + count > size) {
- size -= off;
- count = size;
- }
/* Read NVRAM data from cache. */
- memcpy(buf, &vpd_cache[off], count);
-
- return count;
+ return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
}
static ssize_t
--
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: [patch -v3 22/22] qla2xxx: use memory_read_from_buffer
2008-06-04 11:56 ` [patch -v3 22/22] qla2xxx: " Akinobu Mita
@ 2008-06-06 17:06 ` Andrew Vasquez
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Vasquez @ 2008-06-06 17:06 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-kernel, akpm, Andrew Vasquez, James E.J. Bottomley,
linux-scsi
On Wed, 04 Jun 2008, Akinobu Mita wrote:
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Andrew Vasquez <linux-driver@qlogic.com>
> Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/qla2xxx/qla_attr.c | 45 ++++++++--------------------------------
> 1 file changed, 10 insertions(+), 35 deletions(-)
Basic testing looks good. Thanks.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
^ permalink raw reply [flat|nested] 27+ messages in thread