[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7c19d07912a8c93d2ea7fd9c7e3b08d704241b3c.1474450296.git.dwalter@sigma-star.at>
Date: Wed, 21 Sep 2016 11:57:17 +0200
From: Daniel Walter <dwalter@...ma-star.at>
To: linux-mtd@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org, computersforpeace@...il.com,
dwmw2@...radead.org, boris.brezillon@...e-electrons.com,
Richard Weinberger <richard@....at>
Subject: [PATCH v2 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 d0cc24d..bb30763 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