Commit 307957b6 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390/vmcp: simplify vmcp_ioctl()

vmcp_ioctl() has many different return statements and duplicates a lot
of mutex_unlock() calls. Simplify this so that only one return
statement and one mutex_unlock() call is left.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 4ae48c04
...@@ -199,8 +199,8 @@ vmcp_write(struct file *file, const char __user *buff, size_t count, ...@@ -199,8 +199,8 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ {
struct vmcp_session *session; struct vmcp_session *session;
int ret = -ENOTTY;
int __user *argp; int __user *argp;
int temp;
session = file->private_data; session = file->private_data;
if (is_compat_task()) if (is_compat_task())
...@@ -211,28 +211,26 @@ static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -211,28 +211,26 @@ static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -ERESTARTSYS; return -ERESTARTSYS;
switch (cmd) { switch (cmd) {
case VMCP_GETCODE: case VMCP_GETCODE:
temp = session->resp_code; ret = put_user(session->resp_code, argp);
mutex_unlock(&session->mutex); break;
return put_user(temp, argp);
case VMCP_SETBUF: case VMCP_SETBUF:
vmcp_response_free(session); vmcp_response_free(session);
temp = get_user(session->bufsize, argp); ret = get_user(session->bufsize, argp);
if (temp) if (ret)
session->bufsize = PAGE_SIZE; session->bufsize = PAGE_SIZE;
if (!session->bufsize || get_order(session->bufsize) > 8) { if (!session->bufsize || get_order(session->bufsize) > 8) {
session->bufsize = PAGE_SIZE; session->bufsize = PAGE_SIZE;
temp = -EINVAL; ret = -EINVAL;
} }
mutex_unlock(&session->mutex); break;
return temp;
case VMCP_GETSIZE: case VMCP_GETSIZE:
temp = session->resp_size; ret = put_user(session->resp_size, argp);
mutex_unlock(&session->mutex); break;
return put_user(temp, argp);
default: default:
mutex_unlock(&session->mutex); break;
return -ENOTTY;
} }
mutex_unlock(&session->mutex);
return ret;
} }
static const struct file_operations vmcp_fops = { static const struct file_operations vmcp_fops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment