[S390] s390/vmcp: use simple_read_from_buffer()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
3ca1c9907a
commit
7785857a5a
|
@ -61,30 +61,24 @@ static int vmcp_release(struct inode *inode, struct file *file)
|
||||||
static ssize_t
|
static ssize_t
|
||||||
vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
|
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;
|
struct vmcp_session *session;
|
||||||
|
|
||||||
session = (struct vmcp_session *)file->private_data;
|
session = file->private_data;
|
||||||
if (mutex_lock_interruptible(&session->mutex))
|
if (mutex_lock_interruptible(&session->mutex))
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
if (!session->response) {
|
if (!session->response) {
|
||||||
mutex_unlock(&session->mutex);
|
mutex_unlock(&session->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*ppos > session->resp_size) {
|
size = min_t(size_t, session->resp_size, session->bufsize);
|
||||||
mutex_unlock(&session->mutex);
|
ret = simple_read_from_buffer(buff, count, ppos,
|
||||||
return 0;
|
session->response, size);
|
||||||
}
|
|
||||||
tocopy = min(session->resp_size - (size_t) (*ppos), count);
|
|
||||||
tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
|
|
||||||
|
|
||||||
if (copy_to_user(buff, session->response + (*ppos), tocopy)) {
|
|
||||||
mutex_unlock(&session->mutex);
|
mutex_unlock(&session->mutex);
|
||||||
return -EFAULT;
|
|
||||||
}
|
return ret;
|
||||||
mutex_unlock(&session->mutex);
|
|
||||||
*ppos += tocopy;
|
|
||||||
return tocopy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
|
Loading…
Reference in New Issue