[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <6038dbd7e203bc102bd5d33ad9f1aa4f204a3a2e.1300450604.git.tibs@tonyibbs.co.uk>
Date: Fri, 18 Mar 2011 17:21:16 +0000
From: Tony Ibbs <tibs@...yibbs.co.uk>
To: lkml <linux-kernel@...r.kernel.org>
Cc: Linux-embedded <linux-embedded@...r.kernel.org>,
Tibs at Kynesim <tibs@...esim.co.uk>,
Richard Watts <rrw@...esim.co.uk>,
Grant Likely <grant.likely@...retlab.ca>,
Tony Ibbs <tibs@...yibbs.co.uk>
Subject: [PATCH 07/11] KBUS add ability to add devices at runtime
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@...yibbs.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists