diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2017-08-07 15:16:16 +0200 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2017-08-09 09:09:39 -0400 |
commit | 307957b643493c1bc038d4e4b717871184f13ddf (patch) | |
tree | abca2d2a1d79b8879e73ac87995d68a7b7572dca /drivers/s390/char/vmcp.c | |
parent | 4ae48c046814d8b0386883aeb9060b08f46a2ec1 (diff) |
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: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/vmcp.c')
-rw-r--r-- | drivers/s390/char/vmcp.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c index 30fd474c86b3..0aa50afa5063 100644 --- a/drivers/s390/char/vmcp.c +++ b/drivers/s390/char/vmcp.c @@ -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) { struct vmcp_session *session; + int ret = -ENOTTY; int __user *argp; - int temp; session = file->private_data; if (is_compat_task()) @@ -211,28 +211,26 @@ static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -ERESTARTSYS; switch (cmd) { case VMCP_GETCODE: - temp = session->resp_code; - mutex_unlock(&session->mutex); - return put_user(temp, argp); + ret = put_user(session->resp_code, argp); + break; case VMCP_SETBUF: vmcp_response_free(session); - temp = get_user(session->bufsize, argp); - if (temp) + ret = get_user(session->bufsize, argp); + if (ret) session->bufsize = PAGE_SIZE; if (!session->bufsize || get_order(session->bufsize) > 8) { session->bufsize = PAGE_SIZE; - temp = -EINVAL; + ret = -EINVAL; } - mutex_unlock(&session->mutex); - return temp; + break; case VMCP_GETSIZE: - temp = session->resp_size; - mutex_unlock(&session->mutex); - return put_user(temp, argp); + ret = put_user(session->resp_size, argp); + break; default: - mutex_unlock(&session->mutex); - return -ENOTTY; + break; } + mutex_unlock(&session->mutex); + return ret; } static const struct file_operations vmcp_fops = { |