Input: gameport - 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: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Dmitry Torokhov 2007-04-10 00:40:48 -04:00 committed by Greg Kroah-Hartman
parent 70f256fda1
commit 79580057de

View File

@ -190,16 +190,14 @@ static void gameport_run_poll_handler(unsigned long d)
* Basic gameport -> driver core mappings * Basic gameport -> driver core mappings
*/ */
static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv) static int gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
{ {
int error; int error;
down_write(&gameport_bus.subsys.rwsem);
gameport->dev.driver = &drv->driver; gameport->dev.driver = &drv->driver;
if (drv->connect(gameport, drv)) { if (drv->connect(gameport, drv)) {
gameport->dev.driver = NULL; gameport->dev.driver = NULL;
goto out; return -ENODEV;
} }
error = device_bind_driver(&gameport->dev); error = device_bind_driver(&gameport->dev);
@ -211,31 +209,21 @@ static void gameport_bind_driver(struct gameport *gameport, struct gameport_driv
drv->description, error); drv->description, error);
drv->disconnect(gameport); drv->disconnect(gameport);
gameport->dev.driver = NULL; gameport->dev.driver = NULL;
goto out; return error;
} }
out: return 0;
up_write(&gameport_bus.subsys.rwsem);
}
static void gameport_release_driver(struct gameport *gameport)
{
down_write(&gameport_bus.subsys.rwsem);
device_release_driver(&gameport->dev);
up_write(&gameport_bus.subsys.rwsem);
} }
static void gameport_find_driver(struct gameport *gameport) static void gameport_find_driver(struct gameport *gameport)
{ {
int error; int error;
down_write(&gameport_bus.subsys.rwsem);
error = device_attach(&gameport->dev); error = device_attach(&gameport->dev);
if (error < 0) if (error < 0)
printk(KERN_WARNING printk(KERN_WARNING
"gameport: device_attach() failed for %s (%s), error: %d\n", "gameport: device_attach() failed for %s (%s), error: %d\n",
gameport->phys, gameport->name, error); gameport->phys, gameport->name, error);
up_write(&gameport_bus.subsys.rwsem);
} }
@ -483,13 +471,12 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
{ {
struct gameport *gameport = to_gameport_port(dev); struct gameport *gameport = to_gameport_port(dev);
struct device_driver *drv; struct device_driver *drv;
int retval; int error;
retval = mutex_lock_interruptible(&gameport_mutex); error = mutex_lock_interruptible(&gameport_mutex);
if (retval) if (error)
return retval; return error;
retval = count;
if (!strncmp(buf, "none", count)) { if (!strncmp(buf, "none", count)) {
gameport_disconnect_port(gameport); gameport_disconnect_port(gameport);
} else if (!strncmp(buf, "reconnect", count)) { } else if (!strncmp(buf, "reconnect", count)) {
@ -499,15 +486,15 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
gameport_find_driver(gameport); gameport_find_driver(gameport);
} else if ((drv = driver_find(buf, &gameport_bus)) != NULL) { } else if ((drv = driver_find(buf, &gameport_bus)) != NULL) {
gameport_disconnect_port(gameport); gameport_disconnect_port(gameport);
gameport_bind_driver(gameport, to_gameport_driver(drv)); error = gameport_bind_driver(gameport, to_gameport_driver(drv));
put_driver(drv); put_driver(drv);
} else { } else {
retval = -EINVAL; error = -EINVAL;
} }
mutex_unlock(&gameport_mutex); mutex_unlock(&gameport_mutex);
return retval; return error ? error : count;
} }
static struct device_attribute gameport_device_attrs[] = { static struct device_attribute gameport_device_attrs[] = {
@ -655,7 +642,7 @@ static void gameport_disconnect_port(struct gameport *gameport)
do { do {
parent = s->parent; parent = s->parent;
gameport_release_driver(s); device_release_driver(&s->dev);
gameport_destroy_port(s); gameport_destroy_port(s);
} while ((s = parent) != gameport); } while ((s = parent) != gameport);
} }
@ -663,7 +650,7 @@ static void gameport_disconnect_port(struct gameport *gameport)
/* /*
* Ok, no children left, now disconnect this port * Ok, no children left, now disconnect this port
*/ */
gameport_release_driver(gameport); device_release_driver(&gameport->dev);
} }
void gameport_rescan(struct gameport *gameport) void gameport_rescan(struct gameport *gameport)