[PATCH 38/47] allow users to manually rebind serio ports

From: Vojtech Pavlik
Date: Thu Jul 29 2004 - 14:17:52 EST


You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@xxxxxxxxxxxx, 2004-06-29 01:29:39-05:00, dtor_core@xxxxxxxxxxxxx
Input: allow users manually rebind serio ports, like this:
echo -n "psmouse" > /sys/bus/serio/devices/serio0/driver
echo -n "atkbd" > /sys/bus/serio/devices/serio1/driver
echo -n "none" > /sys/bus/serio/devices/serio1/driver
echo -n "reconnect" > /sys/bus/serio/devices/serio1/driver
echo -n "rescan" > /sys/bus/serio/devices/serio1/driver

Signed-off-by: Dmitry Torokhov <dtor@xxxxxxx>


serio.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletion(-)

===================================================================

diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c Thu Jul 29 14:39:12 2004
+++ b/drivers/input/serio/serio.c Thu Jul 29 14:39:12 2004
@@ -250,7 +250,39 @@
{
return sprintf(buf, "%s\n", dev->driver ? dev->driver->name : "(none)");
}
-static DEVICE_ATTR(driver, S_IRUGO, serio_show_driver, NULL);
+
+static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count)
+{
+ struct serio *serio = to_serio_port(dev);
+ struct device_driver *drv;
+ struct kobject *k;
+ int retval;
+
+ retval = down_interruptible(&serio_sem);
+ if (retval)
+ return retval;
+
+ retval = count;
+ if (!strncmp(buf, "none", count)) {
+ serio_disconnect_port(serio);
+ } else if (!strncmp(buf, "reconnect", count)) {
+ serio_reconnect_port(serio);
+ } else if (!strncmp(buf, "rescan", count)) {
+ serio_disconnect_port(serio);
+ serio_connect_port(serio, NULL);
+ } else if ((k = kset_find_obj(&serio_bus.drivers, buf)) != NULL) {
+ drv = container_of(k, struct device_driver, kobj);
+ serio_disconnect_port(serio);
+ serio_connect_port(serio, to_serio_driver(drv));
+ } else {
+ retval = -EINVAL;
+ }
+
+ up(&serio_sem);
+
+ return retval;
+}
+static DEVICE_ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver);

static void serio_release_port(struct device *dev)
{

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/