From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 13/14] mei: enable adding more IOCTL handlers
Date: Thu, 21 Aug 2014 14:29:22 +0300 [thread overview]
Message-ID: <1408620563-25834-13-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1408620563-25834-1-git-send-email-tomas.winkler@intel.com>
Handle ioctls in a switch statement so we can
add more commands easily
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/main.c | 53 ++++++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 25 deletions(-)
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 957f44a..2f80c77 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:
--
1.9.3
next prev parent reply other threads:[~2014-08-21 11:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 11:29 [char-misc-next 01/14] mei: use consistently me_addr in the hbm structures Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 02/14] mei: use wrapper for simple hbm client message Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 03/14] mei: me_client lookup function to return me_client object Tomas Winkler
2014-08-21 12:32 ` Josh Boyer
2014-08-21 13:14 ` Winkler, Tomas
2014-08-21 11:29 ` [char-misc-next 04/14] mei: use list for me clients book keeping Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 05/14] mei: add me client remove functions Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 06/14] mei: add mei_me_cl_by_uuid_id function Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 07/14] mei: add hbm commands return status values Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 08/14] mei: use disconnect name consistently Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 09/14] mei: revamp connect and disconnect response handling Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 10/14] mei: wait for hbm start non-interruptible Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 11/14] mei: simplify handling of hbm client events Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 12/14] mei: extract supported features from the hbm version Tomas Winkler
2014-08-21 11:29 ` Tomas Winkler [this message]
2014-08-21 11:29 ` [char-misc-next 14/14] mei: use connect_data on the stack Tomas Winkler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408620563-25834-13-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®