Commit 4f046e7b authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: enable adding more IOCTL handlers

Handle ioctls in a switch statement so we can
add more commands easily
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bae1cc7d
...@@ -523,8 +523,6 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) ...@@ -523,8 +523,6 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
struct mei_connect_client_data *connect_data = NULL; struct mei_connect_client_data *connect_data = NULL;
int rets; int rets;
if (cmd != IOCTL_MEI_CONNECT_CLIENT)
return -EINVAL;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return -ENODEV; return -ENODEV;
...@@ -539,34 +537,39 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) ...@@ -539,34 +537,39 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
goto out; goto out;
} }
dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); switch (cmd) {
case IOCTL_MEI_CONNECT_CLIENT:
connect_data = kzalloc(sizeof(struct mei_connect_client_data), dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
connect_data = kzalloc(sizeof(struct mei_connect_client_data),
GFP_KERNEL); GFP_KERNEL);
if (!connect_data) { if (!connect_data) {
rets = -ENOMEM; rets = -ENOMEM;
goto out; goto out;
} }
dev_dbg(&dev->pdev->dev, "copy connect data from user\n");
if (copy_from_user(connect_data, (char __user *)data,
sizeof(struct mei_connect_client_data))) {
dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
rets = -EFAULT;
goto out;
}
rets = mei_ioctl_connect_client(file, connect_data); if (copy_from_user(connect_data, (char __user *)data,
sizeof(struct mei_connect_client_data))) {
dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
rets = -EFAULT;
goto out;
}
/* if all is ok, copying the data back to user. */ rets = mei_ioctl_connect_client(file, connect_data);
if (rets) if (rets)
goto out; goto out;
dev_dbg(&dev->pdev->dev, "copy connect data to user\n"); /* if all is ok, copying the data back to user. */
if (copy_to_user((char __user *)data, connect_data, if (copy_to_user((char __user *)data, connect_data,
sizeof(struct mei_connect_client_data))) { sizeof(struct mei_connect_client_data))) {
dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n"); dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
rets = -EFAULT; rets = -EFAULT;
goto out; goto out;
}
break;
default:
dev_err(&dev->pdev->dev, ": unsupported ioctl %d.\n", cmd);
rets = -ENOIOCTLCMD;
} }
out: out:
......
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