summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-08-21 14:29:22 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-23 22:57:48 -0700
commit4f046e7b6f4f0d8c9504e22cf8eacfe5c78f0f01 (patch)
tree9dc8d85bb2b3cfbf6f64dc710cfcbdf161c5e934 /drivers/misc
parentbae1cc7d41fd3048f55c21a6e59c35a3f0abaafe (diff)
mei: enable adding more IOCTL handlers
Handle ioctls in a switch statement so we can add more commands easily Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/main.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 957f44aaa97..2f80c77629b 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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;
int rets;
- if (cmd != IOCTL_MEI_CONNECT_CLIENT)
- return -EINVAL;
if (WARN_ON(!cl || !cl->dev))
return -ENODEV;
@@ -539,34 +537,39 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
goto out;
}
- dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
-
- connect_data = kzalloc(sizeof(struct mei_connect_client_data),
+ switch (cmd) {
+ case IOCTL_MEI_CONNECT_CLIENT:
+ dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
+ connect_data = kzalloc(sizeof(struct mei_connect_client_data),
GFP_KERNEL);
- if (!connect_data) {
- rets = -ENOMEM;
- 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;
- }
+ if (!connect_data) {
+ rets = -ENOMEM;
+ 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. */
- if (rets)
- goto out;
+ rets = mei_ioctl_connect_client(file, connect_data);
+ if (rets)
+ goto out;
- dev_dbg(&dev->pdev->dev, "copy connect data to user\n");
- if (copy_to_user((char __user *)data, connect_data,
+ /* if all is ok, copying the data back to user. */
+ if (copy_to_user((char __user *)data, connect_data,
sizeof(struct mei_connect_client_data))) {
- dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
- rets = -EFAULT;
- goto out;
+ dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
+ rets = -EFAULT;
+ goto out;
+ }
+
+ break;
+ default:
+ dev_err(&dev->pdev->dev, ": unsupported ioctl %d.\n", cmd);
+ rets = -ENOIOCTLCMD;
}
out: