lkml.org 
[lkml]   [2011]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 07/11] KBUS add ability to add devices at runtime
    Date
    Users do not always know how many KBUS devices will be needed when
    the system starts. This allows a normal user to request an extra
    device.

    Signed-off-by: Tony Ibbs <tibs@tonyibbs.co.uk>
    ---
    include/linux/kbus_defns.h | 12 +++++++++++-
    ipc/kbus_main.c | 17 +++++++++++++++++
    2 files changed, 28 insertions(+), 1 deletions(-)

    diff --git a/include/linux/kbus_defns.h b/include/linux/kbus_defns.h
    index 9da72e4..4d3fcd5 100644
    --- a/include/linux/kbus_defns.h
    +++ b/include/linux/kbus_defns.h
    @@ -611,8 +611,18 @@ struct kbus_replier_bind_event_data {
    */
    #define KBUS_IOC_VERBOSE _IOWR(KBUS_IOC_MAGIC, 15, char *)

    +/*
    + * NEWDEVICE - request another KBUS device (/dev/kbus<n>).
    + *
    + * The next device number (up to a maximum of 255) will be allocated.
    + *
    + * arg(out): __u32, the new device number (<n>)
    + * retval: 0 for success, negative for failure
    + */
    +#define KBUS_IOC_NEWDEVICE _IOR(KBUS_IOC_MAGIC, 16, char *)
    +
    /* If adding another IOCTL, remember to increment the next number! */
    -#define KBUS_IOC_MAXNR 15
    +#define KBUS_IOC_MAXNR 16

    #if !__KERNEL__ && defined(__cplusplus)
    }
    diff --git a/ipc/kbus_main.c b/ipc/kbus_main.c
    index a75d2e1..48ba4b2 100644
    --- a/ipc/kbus_main.c
    +++ b/ipc/kbus_main.c
    @@ -3532,6 +3532,23 @@ static long kbus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
    retval = kbus_set_verbosity(priv, arg);
    break;

    + case KBUS_IOC_NEWDEVICE:
    + /*
    + * Request a new device
    + *
    + * arg out: the new device number
    + * return: 0 means OK, otherwise not OK.
    + */
    + kbus_maybe_dbg(priv->dev, "%u NEWDEVICE %d\n",
    + id, kbus_num_devices);
    + retval = kbus_setup_new_device(kbus_num_devices);
    + if (retval > 0) {
    + kbus_num_devices++;
    + retval = __put_user(kbus_num_devices - 1,
    + (u32 __user *) arg);
    + }
    + break;
    +
    default:
    /* *Should* be redundant, if we got our range checks right */
    retval = -ENOTTY;
    --
    1.7.4.1


    \
     
     \ /
      Last update: 2011-03-18 18:49    [W:2.517 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site