From: Richard Weinberger <rich...@nod.at> Since we have now all what we need we can arm NANDSIM_IOC_NEW_INSTANCE.
Signed-off-by: Richard Weinberger <rich...@nod.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