Commit 7f821556 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: allow marking serio ports (in addition to serio drivers)

       as manual bind only, export the flag through sysfs

           echo -n "manual" > /sys/bus/serio/devices/serio0/bind_mode
           echo -n "auto" > /sys/bus/serio/drivers/serio_raw/bind_mode
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 26ecd16b
...@@ -283,9 +283,33 @@ static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t c ...@@ -283,9 +283,33 @@ static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t c
return retval; return retval;
} }
static ssize_t serio_show_bind_mode(struct device *dev, char *buf)
{
struct serio *serio = to_serio_port(dev);
return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
}
static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t count)
{
struct serio *serio = to_serio_port(dev);
int retval;
retval = count;
if (!strncmp(buf, "manual", count)) {
serio->manual_bind = 1;
} else if (!strncmp(buf, "auto", count)) {
serio->manual_bind = 0;
} else {
retval = -EINVAL;
}
return retval;
}
static struct device_attribute serio_device_attrs[] = { static struct device_attribute serio_device_attrs[] = {
__ATTR(description, S_IRUGO, serio_show_description, NULL), __ATTR(description, S_IRUGO, serio_show_description, NULL),
__ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver), __ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver),
__ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
__ATTR_NULL __ATTR_NULL
}; };
...@@ -353,7 +377,7 @@ static void serio_connect_port(struct serio *serio, struct serio_driver *drv) ...@@ -353,7 +377,7 @@ static void serio_connect_port(struct serio *serio, struct serio_driver *drv)
if (drv) if (drv)
serio_bind_driver(serio, drv); serio_bind_driver(serio, drv);
else else if (!serio->manual_bind)
serio_find_driver(serio); serio_find_driver(serio);
/* Ok, now bind children, if any */ /* Ok, now bind children, if any */
...@@ -365,13 +389,15 @@ static void serio_connect_port(struct serio *serio, struct serio_driver *drv) ...@@ -365,13 +389,15 @@ static void serio_connect_port(struct serio *serio, struct serio_driver *drv)
serio_create_port(serio); serio_create_port(serio);
/* if (!serio->manual_bind) {
* With children we just _prefer_ passed in driver, /*
* but we will try other options in case preferred * With children we just _prefer_ passed in driver,
* is not the one * but we will try other options in case preferred
*/ * is not the one
if (!drv || !serio_bind_driver(serio, drv)) */
serio_find_driver(serio); if (!drv || !serio_bind_driver(serio, drv))
serio_find_driver(serio);
}
} }
} }
...@@ -485,8 +511,34 @@ static ssize_t serio_driver_show_description(struct device_driver *drv, char *bu ...@@ -485,8 +511,34 @@ static ssize_t serio_driver_show_description(struct device_driver *drv, char *bu
return sprintf(buf, "%s\n", driver->description ? driver->description : "(none)"); return sprintf(buf, "%s\n", driver->description ? driver->description : "(none)");
} }
static ssize_t serio_driver_show_bind_mode(struct device_driver *drv, char *buf)
{
struct serio_driver *serio_drv = to_serio_driver(drv);
return sprintf(buf, "%s\n", serio_drv->manual_bind ? "manual" : "auto");
}
static ssize_t serio_driver_set_bind_mode(struct device_driver *drv, const char *buf, size_t count)
{
struct serio_driver *serio_drv = to_serio_driver(drv);
int retval;
retval = count;
if (!strncmp(buf, "manual", count)) {
serio_drv->manual_bind = 1;
} else if (!strncmp(buf, "auto", count)) {
serio_drv->manual_bind = 0;
} else {
retval = -EINVAL;
}
return retval;
}
static struct driver_attribute serio_driver_attrs[] = { static struct driver_attribute serio_driver_attrs[] = {
__ATTR(description, S_IRUGO, serio_driver_show_description, NULL), __ATTR(description, S_IRUGO, serio_driver_show_description, NULL),
__ATTR(bind_mode, S_IWUSR | S_IRUGO,
serio_driver_show_bind_mode, serio_driver_set_bind_mode),
__ATTR_NULL __ATTR_NULL
}; };
......
...@@ -27,6 +27,8 @@ struct serio { ...@@ -27,6 +27,8 @@ struct serio {
char name[32]; char name[32];
char phys[32]; char phys[32];
unsigned int manual_bind;
unsigned short idbus; unsigned short idbus;
unsigned short idvendor; unsigned short idvendor;
unsigned short idproduct; unsigned short idproduct;
...@@ -55,7 +57,7 @@ struct serio_driver { ...@@ -55,7 +57,7 @@ struct serio_driver {
void *private; void *private;
char *description; char *description;
int manual_bind; unsigned int manual_bind;
void (*write_wakeup)(struct serio *); void (*write_wakeup)(struct serio *);
irqreturn_t (*interrupt)(struct serio *, unsigned char, irqreturn_t (*interrupt)(struct serio *, unsigned char,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment