public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [patch -v3 05/22] s390/vmcp: use simple_read_from_buffer
       [not found] <20080604115633.116832712@gmail.com>
@ 2008-06-04 11:56 ` Akinobu Mita
  2008-06-04 11:56 ` [patch -v3 06/22] s390: " Akinobu Mita
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ 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] 4+ messages in thread

* [patch -v3 06/22] s390: use simple_read_from_buffer
       [not found] <20080604115633.116832712@gmail.com>
  2008-06-04 11:56 ` [patch -v3 05/22] s390/vmcp: use simple_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
  2008-06-04 11:56 ` [patch -v3 19/22] s390/cio: use memory_read_from_buffer Akinobu Mita
  2008-06-04 11:56 ` [patch -v3 20/22] s390: " Akinobu Mita
  3 siblings, 0 replies; 4+ 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] 4+ messages in thread

* [patch -v3 19/22] s390/cio: use memory_read_from_buffer
       [not found] <20080604115633.116832712@gmail.com>
  2008-06-04 11:56 ` [patch -v3 05/22] s390/vmcp: use simple_read_from_buffer Akinobu Mita
  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 20/22] s390: " Akinobu Mita
  3 siblings, 0 replies; 4+ 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] 4+ messages in thread

* [patch -v3 20/22] s390: use memory_read_from_buffer
       [not found] <20080604115633.116832712@gmail.com>
                   ` (2 preceding siblings ...)
  2008-06-04 11:56 ` [patch -v3 19/22] s390/cio: use memory_read_from_buffer Akinobu Mita
@ 2008-06-04 11:56 ` Akinobu Mita
  3 siblings, 0 replies; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2008-06-04 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20080604115633.116832712@gmail.com>
2008-06-04 11:56 ` [patch -v3 05/22] s390/vmcp: use simple_read_from_buffer Akinobu Mita
2008-06-04 11:56 ` [patch -v3 06/22] s390: " Akinobu Mita
2008-06-04 11:56 ` [patch -v3 19/22] s390/cio: use memory_read_from_buffer Akinobu Mita
2008-06-04 11:56 ` [patch -v3 20/22] s390: " Akinobu Mita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox