public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Small fixups to driver core
@ 2005-11-17 20:04 Alan Stern
  2005-11-17 22:06 ` Patrick Mochel
  2005-11-17 23:36 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Alan Stern @ 2005-11-17 20:04 UTC (permalink / raw)
  To: Greg KH; +Cc: Patrick Mochel, Kernel development list

Greg:

This patch (as603) makes a few small fixes to the driver core:

	Change spin_lock_irq for a klist lock to spin_lock;

	Fix reference count leaks;

	Minor spelling and formatting changes.

Alan Stern



Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Greg, you originally write driver_bind and driver_unbind.  Shame on you
for messing up the refcounting!  :-)


Index: usb-2.6/drivers/base/bus.c
===================================================================
--- usb-2.6.orig/drivers/base/bus.c
+++ usb-2.6/drivers/base/bus.c
@@ -133,7 +133,7 @@ static struct kobj_type ktype_bus = {
 decl_subsys(bus, &ktype_bus, NULL);
 
 
-/* Manually detach a device from it's associated driver. */
+/* Manually detach a device from its associated driver. */
 static int driver_helper(struct device *dev, void *data)
 {
 	const char *name = data;
@@ -151,14 +151,13 @@ static ssize_t driver_unbind(struct devi
 	int err = -ENODEV;
 
 	dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
-	if ((dev) &&
-	    (dev->driver == drv)) {
+	if (dev && dev->driver == drv) {
 		device_release_driver(dev);
 		err = count;
 	}
-	if (err)
-		return err;
-	return count;
+	put_device(dev);
+	put_bus(bus);
+	return err;
 }
 static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
 
@@ -175,16 +174,14 @@ static ssize_t driver_bind(struct device
 	int err = -ENODEV;
 
 	dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
-	if ((dev) &&
-	    (dev->driver == NULL)) {
+	if (dev && dev->driver == NULL) {
 		down(&dev->sem);
 		err = driver_probe_device(drv, dev);
 		up(&dev->sem);
-		put_device(dev);
 	}
-	if (err)
-		return err;
-	return count;
+	put_device(dev);
+	put_bus(bus);
+	return err;
 }
 static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
 
Index: usb-2.6/drivers/base/dd.c
===================================================================
--- usb-2.6.orig/drivers/base/dd.c
+++ usb-2.6/drivers/base/dd.c
@@ -62,7 +62,6 @@ void device_bind_driver(struct device * 
  *	because we don't know the format of the ID structures, nor what
  *	is to be considered a match and what is not.
  *
- *
  *	This function returns 1 if a match is found, an error if one
  *	occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
  *
@@ -158,7 +157,6 @@ static int __driver_attach(struct device
 		driver_probe_device(drv, dev);
 	up(&dev->sem);
 
-
 	return 0;
 }
 
@@ -225,15 +223,15 @@ void driver_detach(struct device_driver 
 	struct device * dev;
 
 	for (;;) {
-		spin_lock_irq(&drv->klist_devices.k_lock);
+		spin_lock(&drv->klist_devices.k_lock);
 		if (list_empty(&drv->klist_devices.k_list)) {
-			spin_unlock_irq(&drv->klist_devices.k_lock);
+			spin_unlock(&drv->klist_devices.k_lock);
 			break;
 		}
 		dev = list_entry(drv->klist_devices.k_list.prev,
 				struct device, knode_driver.n_node);
 		get_device(dev);
-		spin_unlock_irq(&drv->klist_devices.k_lock);
+		spin_unlock(&drv->klist_devices.k_lock);
 
 		down(&dev->sem);
 		if (dev->driver == drv)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Small fixups to driver core
  2005-11-17 20:04 [PATCH] Small fixups to driver core Alan Stern
@ 2005-11-17 22:06 ` Patrick Mochel
  2005-11-17 23:36 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Mochel @ 2005-11-17 22:06 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg KH, Kernel development list


On Thu, 17 Nov 2005, Alan Stern wrote:

> Greg:
>
> This patch (as603) makes a few small fixes to the driver core:
>
> 	Change spin_lock_irq for a klist lock to spin_lock;
>
> 	Fix reference count leaks;
>
> 	Minor spelling and formatting changes.

> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

Acked-by Patrick Mochel <mochel@digitalimplant.org>


Thanks,


	Pat


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Small fixups to driver core
  2005-11-17 20:04 [PATCH] Small fixups to driver core Alan Stern
  2005-11-17 22:06 ` Patrick Mochel
@ 2005-11-17 23:36 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2005-11-17 23:36 UTC (permalink / raw)
  To: Alan Stern; +Cc: Patrick Mochel, Kernel development list

On Thu, Nov 17, 2005 at 03:04:42PM -0500, Alan Stern wrote:
> 
> Greg, you originally write driver_bind and driver_unbind.  Shame on you
> for messing up the refcounting!  :-)

Bleah, thanks for catching this, I've queued it to my tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-17 23:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-17 20:04 [PATCH] Small fixups to driver core Alan Stern
2005-11-17 22:06 ` Patrick Mochel
2005-11-17 23:36 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox