[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160831072853.27822-44-dwalter@sigma-star.at>
Date: Wed, 31 Aug 2016 09:28:50 +0200
From: Daniel Walter <dwalter@...ma-star.at>
To: linux-mtd@...ts.infradead.org
Cc: Richard Weinberger <richard@....at>, linux-kernel@...r.kernel.org
Subject: [PATCH 43/46] mtd: nandsim: Wire up NANDSIM_IOC_NEW_INSTANCE
From: Richard Weinberger <richard@....at>
Since we have now all what we need we can arm NANDSIM_IOC_NEW_INSTANCE.
Signed-off-by: Richard Weinberger <richard@....at>
---
drivers/mtd/nand/nandsim.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 34b0c24..4145ab6 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -2900,10 +2900,35 @@ out:
static long ns_ctrl_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
- if (!capable(CAP_SYS_RESOURCE))
- return -EPERM;
+ int ret;
+ void __user *argp = (void __user *)arg;
+
+ if (!capable(CAP_SYS_RESOURCE)) {
+ ret = -EPERM;
+ goto out;
+ }
+
+ switch (cmd) {
+ case NANDSIM_IOC_NEW_INSTANCE:
+ {
+ struct ns_new_instance_req req;
+
+ ret = copy_from_user(&req, argp, sizeof(struct ns_new_instance_req));
+ if (ret) {
+ ret = -EFAULT;
+ goto out;
+ }
- return -ENOTTY;
+ ret = ns_ctrl_new_instance(&req, argp + sizeof(req));
+ break;
+ }
+
+ default:
+ ret = -ENOTTY;
+ }
+
+out:
+ return ret;
}
#ifdef CONFIG_COMPAT
--
2.8.3
Powered by blists - more mailing lists