lkml.org 
[lkml]   [2016]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 43/46] mtd: nandsim: Wire up NANDSIM_IOC_NEW_INSTANCE
    Date
    From: Richard Weinberger <richard@nod.at>

    Since we have now all what we need we can arm NANDSIM_IOC_NEW_INSTANCE.

    Signed-off-by: Richard Weinberger <richard@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
    \
     
     \ /
      Last update: 2016-09-22 23:58    [W:2.518 / U:0.640 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site