Commit b876ead9 authored by Ramesh Gupta's avatar Ramesh Gupta Committed by Hari Kanigeri

Cleanup for ducati ioctl

removed osStatus and optimized the code.
Signed-off-by: default avatarRamesh Gupta G <grgupta@ti.com>
parent c7d8ba68
......@@ -102,8 +102,7 @@ static int drvducati_ioctl(struct inode *inode,
unsigned long args)
{
int status = 0;
int osStatus = 0;
int retVal = 0;
int retval = 0;
struct notify_ducatidrv_cmdargs *cmd_args =
(struct notify_ducatidrv_cmdargs *) args;
struct notify_ducatidrv_cmdargs common_args;
......@@ -115,13 +114,13 @@ static int drvducati_ioctl(struct inode *inode,
struct notify_ducatidrv_config cfg;
notify_ducatidrv_getconfig(&cfg);
if (osStatus == 0) {
retVal = copy_to_user((void *)(src_args->cfg),
retval = copy_to_user((void *)(src_args->cfg),
(const void *) &cfg,
sizeof(struct notify_ducatidrv_config));
if (retVal != 0)
osStatus = -EFAULT;
}
if (WARN_ON(retval != 0))
goto func_end;
}
break;
......@@ -129,17 +128,16 @@ static int drvducati_ioctl(struct inode *inode,
struct notify_ducatidrv_cmdargs_setup *src_args =
(struct notify_ducatidrv_cmdargs_setup *) args;
struct notify_ducatidrv_config cfg;
retVal = copy_from_user((void *) &cfg,
retval = copy_from_user((void *) &cfg,
(const void *)(src_args->cfg),
sizeof(struct notify_ducatidrv_config));
if (retVal != 0) {
osStatus = -EFAULT;
} else {
if (WARN_ON(retval != 0))
goto func_end;
status = notify_ducatidrv_setup(&cfg);
if (status < 0)
printk(KERN_ERR "FAIL: notify_ducatidrv_setup\n");
}
}
break;
case CMD_NOTIFYDRIVERSHM_DESTROY: {
......@@ -153,33 +151,29 @@ static int drvducati_ioctl(struct inode *inode,
case CMD_NOTIFYDRIVERSHM_PARAMS_INIT: {
struct notify_ducatidrv_cmdargs_paramsinit src_args;
struct notify_ducatidrv_params params;
retVal = copy_from_user((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(
struct notify_ducatidrv_cmdargs_paramsinit));
if (retVal != 0)
osStatus = -EFAULT;
else
if (WARN_ON(retval != 0))
goto func_end;
notify_ducatidrv_params_init(src_args.handle, &params);
if (osStatus == 0) {
retVal = copy_to_user((void *)(src_args.params),
retval = copy_to_user((void *)(src_args.params),
(const void *) &params,
sizeof(struct notify_ducatidrv_params));
if (retVal != 0)
osStatus = -EFAULT;
}
if (WARN_ON(retval != 0))
goto func_end;
}
break;
case CMD_NOTIFYDRIVERSHM_CREATE: {
struct notify_ducatidrv_cmdargs_create src_args;
retVal = copy_from_user((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_ducatidrv_cmdargs_create));
if (retVal != 0)
osStatus = -EFAULT;
else {
if (WARN_ON(retval != 0))
goto func_end;
src_args.handle = notify_ducatidrv_create(
src_args.driverName,
&(src_args.params));
......@@ -189,104 +183,89 @@ static int drvducati_ioctl(struct inode *inode,
"NotifyDriverShm_create failed",
status);
}
}
if (osStatus == 0) {
retVal = copy_to_user((void *)(args),
retval = copy_to_user((void *)(args),
(const void *) &src_args,
sizeof(struct notify_ducatidrv_cmdargs_create));
if (retVal != 0)
osStatus = -EFAULT;
}
if (WARN_ON(retval != 0))
goto func_end;
}
break;
case CMD_NOTIFYDRIVERSHM_DELETE: {
struct notify_ducatidrv_cmdargs_delete src_args;
retVal = copy_from_user((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_ducatidrv_cmdargs_delete));
if (WARN_ON(retval != 0))
goto func_end;
if (retVal != 0)
osStatus = -EFAULT;
else {
status = notify_ducatidrv_delete(&(src_args.handle));
if (status < 0)
printk(KERN_ERR "drvducati_ioctl:"
" notify_ducatidrv_delete failed"
" status = %d\n", status);
}
}
break;
case CMD_NOTIFYDRIVERSHM_OPEN: {
struct notify_ducatidrv_cmdargs_open src_args;
retVal = copy_from_user((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_ducatidrv_cmdargs_open));
if (retVal != 0) {
osStatus = -EFAULT;
} else {
if (WARN_ON(retval != 0))
goto func_end;
status = notify_ducatidrv_open(src_args.driverName,
&(src_args.handle));
if (status < 0)
printk(KERN_ERR "drvducati_ioctl:"
" notify_ducatidrv_open failed"
" status = %d\n", status);
}
if (osStatus == 0) {
retVal = copy_to_user((void *)(args),
retval = copy_to_user((void *)(args),
(const void *) &src_args,
sizeof(
struct notify_ducatidrv_cmdargs_open));
if (retVal != 0)
osStatus = -EFAULT;
}
sizeof(struct notify_ducatidrv_cmdargs_open));
if (WARN_ON(retval != 0))
goto func_end;
}
break;
case CMD_NOTIFYDRIVERSHM_CLOSE: {
struct notify_ducatidrv_cmdargs_close src_args;
retVal = copy_from_user((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_ducatidrv_cmdargs_close));
if (retVal != 0) {
osStatus = -EFAULT;
} else {
if (WARN_ON(retval != 0))
goto func_end;
status = notify_ducatidrv_close(&(src_args.handle));
if (status < 0)
printk(KERN_ERR "drvducati_ioctl:"
" notify_ducatidrv_close"
" failed status = %d\n", status);
}
}
break;
default: {
status = -EINVAL;
osStatus = -EINVAL;
printk(KERN_ERR "drivducati_ioctl:Unsupported"
" ioctl command specified");
}
break;
}
func_end:
/* Set the status and copy the common args to user-side. */
common_args.api_status = status;
retVal = copy_to_user((void *) cmd_args,
status = copy_to_user((void *) cmd_args,
(const void *) &common_args,
sizeof(struct notify_ducatidrv_cmdargs));
if (retVal != 0) {
osStatus = -EFAULT;
} else {
if (status == -ERESTARTSYS)
osStatus = -ERESTARTSYS;
}
if (status < 0)
retval = -EFAULT;
return osStatus;
return retval;
}
......
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