Skip to contentSkip to conversation

drivers/base: device_bind_driver() fix

PATCH Vitaly Bordug 2 participants 2 messages Jan 24, 2007 Driver core

lore
Share & tools
lore
#0 lore raw

Keeps sysfs from creating link if device is already bound to driver. Similar behavior was before the rework; now without this patch fixed PHY will complain about not been able to create file in sysfs.

---

 drivers/base/dd.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/base/dd.c +5 -3
index 510e788..6da3d01 100644
@@ -26,12 +26,12 @@
 #define to_drv(node) container_of(node, struct device_driver, kobj.entry)
 
 
-static void driver_bound(struct device *dev)
+static int driver_bound(struct device *dev)
 {
 	if (klist_node_attached(&dev->knode_driver)) {
 		printk(KERN_WARNING "%s: device %s already bound\n",
 			__FUNCTION__, kobject_name(&dev->kobj));
-		return;
+		return 0;
 	}
 
 	pr_debug("bound device '%s' to driver '%s'\n",
@@ -42,6 +42,7 @@ static void driver_bound(struct device *dev)
 					     BUS_NOTIFY_BOUND_DRIVER, dev);
 
 	klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
+	return 1;
 }
 
 static int driver_sysfs_add(struct device *dev)
@@ -86,7 +87,8 @@ static void driver_sysfs_remove(struct device *dev)
  */
 int device_bind_driver(struct device *dev)
 {
-	driver_bound(dev);
+	if (!driver_bound(dev))
+		return 0;
 	return driver_sysfs_add(dev);
 }
 
#1 lore raw
Quoted 3 lines · Vitaly Bordug

Keeps sysfs from creating link if device is already bound to driver. Similar behavior was before the rework;

Which "rework" caused this?

Quoted 2 lines

now without this patch fixed PHY will complain about not been able to create file in sysfs.

Which device is being bound to a driver before it is registered? I know the i2c layer does it, but I haven't had any people reporting issues there.

Quoted 26 lines

---

 drivers/base/dd.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/base/dd.c +2 -2
index 510e788..6da3d01 100644
@@ -26,12 +26,12 @@
 #define to_drv(node) container_of(node, struct device_driver, kobj.entry)
 
 
-static void driver_bound(struct device *dev)
+static int driver_bound(struct device *dev)
 {
 	if (klist_node_attached(&dev->knode_driver)) {
 		printk(KERN_WARNING "%s: device %s already bound\n",
 			__FUNCTION__, kobject_name(&dev->kobj));
-		return;
+		return 0;
 	}
 
 	pr_debug("bound device '%s' to driver '%s'\n",

drivers/base/dd.c static void driver_bound(struct device *dev) · line 45

Quoted 4 lines
drivers/base/dd.c +1 -0
@@ -42,6 +42,7 @@ static void driver_bound(struct device *dev)
 					     BUS_NOTIFY_BOUND_DRIVER, dev);
 
 	klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
+	return 1;

Please return 0 for "good" and -ERRORSOMETHING for a when a problem happens, like the rest of the kernel.

thanks,

greg k-h