[PATCH 24/46] Input: serio - do not touch bus's rwsem

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Dmitry Torokhov <dtor@...>, Dmitry Torokhov <dtor@...>, Greg Kroah-Hartman <gregkh@...>
Date: Friday, April 27, 2007 - 2:53 pm

From: Dmitry Torokhov <dtor@insightbb.com>

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>
---
 drivers/input/serio/serio.c |   41 +++++++++++++++--------------------------
 1 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index a15e531..5895202 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -115,18 +115,18 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser
  * 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;
 
-	down_write(&serio_bus.subsys.rwsem);
-
 	if (serio_match_port(drv->id_table, serio)) {
+
 		serio->dev.driver = &drv->driver;
 		if (serio_connect_driver(serio, drv)) {
 			serio->dev.driver = NULL;
-			goto out;
+			return -ENODEV;
 		}
+
 		error = device_bind_driver(&serio->dev);
 		if (error) {
 			printk(KERN_WARNING
@@ -136,31 +136,21 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
 				drv->description, error);
 			serio_disconnect_driver(serio);
 			serio->dev.driver = NULL;
-			goto out;
+			return error;
 		}
 	}
- out:
-	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);
+	return 0;
 }
 
 static void serio_find_driver(struct serio *serio)
 {
 	int error;
 
-	down_write(&serio_bus.subsys.rwsem);
 	error = device_attach(&serio->dev);
 	if (error < 0)
 		printk(KERN_WARNING
 			"serio: device_attach() failed for %s (%s), error: %d\n",
 			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 *
 {
 	struct serio *serio = to_serio_port(dev);
 	struct device_driver *drv;
-	int retval;
+	int error;
 
-	retval = mutex_lock_interruptible(&serio_mutex);
-	if (retval)
-		return retval;
+	error = mutex_lock_interruptible(&serio_mutex);
+	if (error)
+		return error;
 
-	retval = count;
 	if (!strncmp(buf, "none", count)) {
 		serio_disconnect_port(serio);
 	} else if (!strncmp(buf, "reconnect", count)) {
@@ -486,15 +475,15 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
 		serio_find_driver(serio);
 	} else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
 		serio_disconnect_port(serio);
-		serio_bind_driver(serio, to_serio_driver(drv));
+		error = serio_bind_driver(serio, to_serio_driver(drv));
 		put_driver(drv);
 	} else {
-		retval = -EINVAL;
+		error = -EINVAL;
 	}
 
 	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)
@@ -665,7 +654,7 @@ static void serio_disconnect_port(struct serio *serio)
 		do {
 			parent = s->parent;
 
-			serio_release_driver(s);
+			device_release_driver(&s->dev);
 			serio_destroy_port(s);
 		} while ((s = parent) != serio);
 	}
@@ -673,7 +662,7 @@ static void serio_disconnect_port(struct serio *serio)
 	/*
 	 * Ok, no children left, now disconnect this port
 	 */
-	serio_release_driver(serio);
+	device_release_driver(&serio->dev);
 }
 
 void serio_rescan(struct serio *serio)
-- 
1.5.1.2

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 13/46] Driver core: notify userspace of network devic..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 14/46] Driver core: suppress uevents via filter, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 15/46] Driver core: switch firmware_class to uevent_s..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 16/46] uevent: use add_uevent_var() instead of open c..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 17/46] Driver core: add suspend() and resume() to str..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 18/46] Kobject: kobject_uevent.c: Collapse unnecessar..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 19/46] kobject: kobject_add() reference leak, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 20/46] Driver core: remove use of rwsem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 21/46] SCSI: use the proper semaphore to protect the ..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 22/46] USB: remove use of the bus rwsem, as it doesn'..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 23/46] PNP: stop using the subsystem rwsem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 24/46] Input: serio - do not touch bus's rwsem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 25/46] Input: gameport - do not touch bus's rwsem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 26/46] IDE: remove rwsem use from ide-proc core, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 27/46] IEEE1394: remove rwsem use from ieee1394 core, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 28/46] PHY: remove rwsem use from phy core, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
Re: [PATCH 28/46] PHY: remove rwsem use from phy core, Andy Fleming, (Fri Apr 27, 5:11 pm)
[PATCH 29/46] qeth: Remove usage of subsys.rwsem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 30/46] kobject core: remove rwsem from struct subsystem, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 31/46] Driver core: make uevent-environment available..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 32/46] Driver core: warn when userspace writes to the..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 33/46] kobject: Comment and warning fixes to kobject.c, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 34/46] the overdue removal of the mount/umount uevents, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 35/46] debugfs: Add debugfs_create_u64(), Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 36/46] driver core: bus_add_driver should return an e..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 37/46] Driver core: use mutex instead of semaphore in..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 38/46] sysfs: bin.c printk fix, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 39/46] s390: cio: Delay uevents for subchannels, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 40/46] device_schedule_callback() needs a module refe..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 41/46] security: prevent permission checking of file ..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 42/46] define platform wakeup hook, use in pci_enable..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 43/46] s2ram: add arch irq disable/enable hooks, Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 44/46] mod_sysfs_setup() doesn't return errno when ko..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 45/46] drivers/base/attribute_container.c: use mutex ..., Greg Kroah-Hartman, (Fri Apr 27, 2:53 pm)
[PATCH 46/46] dev_dbg: check dev_dbg() arguments, Greg Kroah-Hartman, (Fri Apr 27, 2:54 pm)