提交 70f256fd 编写于 作者: D Dmitry Torokhov 提交者: Greg Kroah-Hartman

Input: serio - do not touch bus's rwsem

The subsystem rwsem is not used by the driver core at all, so there is
no point in trying to access it.
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 75f1115c
...@@ -115,18 +115,18 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser ...@@ -115,18 +115,18 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser
* Basic serio -> driver core mappings * Basic serio -> driver core mappings
*/ */
static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
{ {
int error; int error;
down_write(&serio_bus.subsys.rwsem);
if (serio_match_port(drv->id_table, serio)) { if (serio_match_port(drv->id_table, serio)) {
serio->dev.driver = &drv->driver; serio->dev.driver = &drv->driver;
if (serio_connect_driver(serio, drv)) { if (serio_connect_driver(serio, drv)) {
serio->dev.driver = NULL; serio->dev.driver = NULL;
goto out; return -ENODEV;
} }
error = device_bind_driver(&serio->dev); error = device_bind_driver(&serio->dev);
if (error) { if (error) {
printk(KERN_WARNING printk(KERN_WARNING
...@@ -136,31 +136,21 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) ...@@ -136,31 +136,21 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
drv->description, error); drv->description, error);
serio_disconnect_driver(serio); serio_disconnect_driver(serio);
serio->dev.driver = NULL; serio->dev.driver = NULL;
goto out; return error;
} }
} }
out: return 0;
up_write(&serio_bus.subsys.rwsem);
}
static void serio_release_driver(struct serio *serio)
{
down_write(&serio_bus.subsys.rwsem);
device_release_driver(&serio->dev);
up_write(&serio_bus.subsys.rwsem);
} }
static void serio_find_driver(struct serio *serio) static void serio_find_driver(struct serio *serio)
{ {
int error; int error;
down_write(&serio_bus.subsys.rwsem);
error = device_attach(&serio->dev); error = device_attach(&serio->dev);
if (error < 0) if (error < 0)
printk(KERN_WARNING printk(KERN_WARNING
"serio: device_attach() failed for %s (%s), error: %d\n", "serio: device_attach() failed for %s (%s), error: %d\n",
serio->phys, serio->name, error); serio->phys, serio->name, error);
up_write(&serio_bus.subsys.rwsem);
} }
...@@ -470,13 +460,12 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * ...@@ -470,13 +460,12 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
{ {
struct serio *serio = to_serio_port(dev); struct serio *serio = to_serio_port(dev);
struct device_driver *drv; struct device_driver *drv;
int retval; int error;
retval = mutex_lock_interruptible(&serio_mutex); error = mutex_lock_interruptible(&serio_mutex);
if (retval) if (error)
return retval; return error;
retval = count;
if (!strncmp(buf, "none", count)) { if (!strncmp(buf, "none", count)) {
serio_disconnect_port(serio); serio_disconnect_port(serio);
} else if (!strncmp(buf, "reconnect", count)) { } else if (!strncmp(buf, "reconnect", count)) {
...@@ -486,15 +475,15 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * ...@@ -486,15 +475,15 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
serio_find_driver(serio); serio_find_driver(serio);
} else if ((drv = driver_find(buf, &serio_bus)) != NULL) { } else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
serio_disconnect_port(serio); serio_disconnect_port(serio);
serio_bind_driver(serio, to_serio_driver(drv)); error = serio_bind_driver(serio, to_serio_driver(drv));
put_driver(drv); put_driver(drv);
} else { } else {
retval = -EINVAL; error = -EINVAL;
} }
mutex_unlock(&serio_mutex); mutex_unlock(&serio_mutex);
return retval; return error ? error : count;
} }
static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -665,7 +654,7 @@ static void serio_disconnect_port(struct serio *serio) ...@@ -665,7 +654,7 @@ static void serio_disconnect_port(struct serio *serio)
do { do {
parent = s->parent; parent = s->parent;
serio_release_driver(s); device_release_driver(&s->dev);
serio_destroy_port(s); serio_destroy_port(s);
} while ((s = parent) != serio); } while ((s = parent) != serio);
} }
...@@ -673,7 +662,7 @@ static void serio_disconnect_port(struct serio *serio) ...@@ -673,7 +662,7 @@ static void serio_disconnect_port(struct serio *serio)
/* /*
* Ok, no children left, now disconnect this port * Ok, no children left, now disconnect this port
*/ */
serio_release_driver(serio); device_release_driver(&serio->dev);
} }
void serio_rescan(struct serio *serio) void serio_rescan(struct serio *serio)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册