Skip to contentSkip to conversation

Driver core fixes for 2.6.21-rc3

PATCH New Greg KH 1 participant 6 messages Mar 10, 2007

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 Driver core fixes for 2.6.21-rc3

Here are some driver core fixes for 2.6.21-rc3.

They fix the following thing:
- fix reference counting bug when removing any driver module from the system by reverting a previous "fix".
- allow older versions of HAL to find network devices even if CONFIG_SYSFS_DEPRECATED is disabled.
- fix an oops when moving kobjects to the same destination location as they currently are caused by the bluetooth layer.
- export a symbol to allow the wireless core to be built as a module - remove the devfs entry in the MAINTAINERS file.

All of these have been in the -mm tree.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

Patches will be sent as a follow-on to this message to lkml for people to see.

thanks,

greg k-h

 MAINTAINERS         |    3 ---
 drivers/base/core.c |   23 ++++++++++++++---------
 kernel/module.c     |    6 ------
 lib/kobject.c       |    2 ++
 4 files changed, 16 insertions(+), 18 deletions(-)

---------------

Dmitriy Monakhov (1):

      kobject: new_device->kref wasn't putted after error in kobject_move()

Greg Kroah-Hartman (2):
Revert "driver core: refcounting fix" Driver core: add device symlink back to sysfs

Johannes Berg (1):
driver core: export device_rename

Jörn Engel (1):
Remove devfs from MAINTAINERS

#1 lore raw

PATCH 1/5 Revert "driver core: refcounting fix"

This reverts commit 63ce18cfe685115ff8d341bae4c9204a79043cf0.

It was the incorrect fix and causes a reference counting bug whenever any driver module is removed from the system. Mike Galbraith <[email protected]> is looking for the real fix for his problem.

---
 kernel/module.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
kernel/module.c +0 -6
index f77e893..fbc51de 100644
@@ -2419,12 +2419,6 @@ void module_remove_driver(struct device_driver *drv)
 			kfree(driver_name);
 		}
 	}
-	/*
-	 * Undo the additional reference we added in module_add_driver()
-	 * via kset_find_obj()
-	 */
-	if (drv->mod_name)
-		kobject_put(&drv->kobj);
 }
 EXPORT_SYMBOL(module_remove_driver);
 #endif
Signature · 1 line
1.5.0.2
#2 lore raw

PATCH 2/5 Driver core: add device symlink back to sysfs

This moves the device symlink back to sysfs even if CONFIG_SYSFS_DEPRECATED is enabled as too many userspace programs (well, HAL), still rely on this link to be present.

I will rework the ability for sysfs to change layouts like this in the future, but for now, this patch should fix people's network connections.

---
 drivers/base/core.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
drivers/base/core.c +13 -8
index 89ebe36..fb16f29 100644
@@ -584,17 +584,17 @@ int device_add(struct device *dev)
 		if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
 			sysfs_create_link(&dev->class->subsys.kset.kobj,
 					  &dev->kobj, dev->bus_id);
-#ifdef CONFIG_SYSFS_DEPRECATED
 		if (parent) {
 			sysfs_create_link(&dev->kobj, &dev->parent->kobj,
 							"device");
+#ifdef CONFIG_SYSFS_DEPRECATED
 			class_name = make_class_name(dev->class->name,
 							&dev->kobj);
 			if (class_name)
 				sysfs_create_link(&dev->parent->kobj,
 						  &dev->kobj, class_name);
-		}
 #endif
+		}
 	}
 
 	if ((error = device_add_attrs(dev)))
@@ -651,17 +651,17 @@ int device_add(struct device *dev)
 		if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
 			sysfs_remove_link(&dev->class->subsys.kset.kobj,
 					  dev->bus_id);
-#ifdef CONFIG_SYSFS_DEPRECATED
 		if (parent) {
+#ifdef CONFIG_SYSFS_DEPRECATED
 			char *class_name = make_class_name(dev->class->name,
 							   &dev->kobj);
 			if (class_name)
 				sysfs_remove_link(&dev->parent->kobj,
 						  class_name);
 			kfree(class_name);
+#endif
 			sysfs_remove_link(&dev->kobj, "device");
 		}
-#endif
 
 		down(&dev->class->sem);
 		/* notify any interfaces that the device is now gone */
@@ -761,17 +761,17 @@ void device_del(struct device * dev)
 		if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
 			sysfs_remove_link(&dev->class->subsys.kset.kobj,
 					  dev->bus_id);
-#ifdef CONFIG_SYSFS_DEPRECATED
 		if (parent) {
+#ifdef CONFIG_SYSFS_DEPRECATED
 			char *class_name = make_class_name(dev->class->name,
 							   &dev->kobj);
 			if (class_name)
 				sysfs_remove_link(&dev->parent->kobj,
 						  class_name);
 			kfree(class_name);
+#endif
 			sysfs_remove_link(&dev->kobj, "device");
 		}
-#endif
 
 		down(&dev->class->sem);
 		/* notify any interfaces that the device is now gone */
@@ -1071,8 +1071,8 @@ static int device_move_class_links(struct device *dev,
 				   struct device *old_parent,
 				   struct device *new_parent)
 {
+	int error = 0;
 #ifdef CONFIG_SYSFS_DEPRECATED
-	int error;
 	char *class_name;
 
 	class_name = make_class_name(dev->class->name, &dev->kobj);
@@ -1100,7 +1100,12 @@ out:
 	kfree(class_name);
 	return error;
 #else
-	return 0;
+	if (old_parent)
+		sysfs_remove_link(&dev->kobj, "device");
+	if (new_parent)
+		error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
+					  "device");
+	return error;
 #endif
 }
 
Signature · 1 line
1.5.0.2
#5 lore raw

PATCH 5/5 kobject: new_device->kref wasn't putted after error in kobject_move()

In reply to Greg Kroah-Hartman

From: Dmitriy Monakhov <[email protected]>

If error happen we jump to "out" label, in this case new_device not yet became the parent but it wasn't putted.

---
 lib/kobject.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
lib/kobject.c +2 -0
index f4f6176..057921c 100644
@@ -385,9 +385,11 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
 		goto out;
 	old_parent = kobj->parent;
 	kobj->parent = new_parent;
+	new_parent = NULL;
 	kobject_put(old_parent);
 	kobject_uevent_env(kobj, KOBJ_MOVE, envp);
 out:
+	kobject_put(new_parent);
 	kobject_put(kobj);
 	kfree(devpath_string);
 	kfree(devpath);
Signature · 1 line
1.5.0.2
#3 lore raw

PATCH 3/5 Remove devfs from MAINTAINERS

In reply to Greg Kroah-Hartman

From: Jörn Engel <[email protected]>

Remove last remaining trace of devfs.

---
 MAINTAINERS |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
MAINTAINERS +0 -3
index 9993b90..17555bb 100644
@@ -1103,9 +1103,6 @@ W:	http://lanana.org/docs/device-list/index.html
 L:	[email protected]
 S:	Maintained
 
-DEVICE FILESYSTEM
-S:	Obsolete
-
 DIGI INTL. EPCA DRIVER
 P:	Digi International, Inc
 M:	[email protected]
Signature · 1 line
1.5.0.2
#4 lore raw

PATCH 4/5 driver core: export device_rename

From: Johannes Berg <[email protected]>

In wireless we'd like to allow renaming of the phy devices we surface in sysfs. The base wireless code, however, can be built modular and thus we need device_rename exported.

---
 drivers/base/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/core.c +1 -1
index fb16f29..f191afe 100644
@@ -1065,7 +1065,7 @@ int device_rename(struct device *dev, char *new_name)
 
 	return error;
 }
-
+EXPORT_SYMBOL_GPL(device_rename);
 
 static int device_move_class_links(struct device *dev,
 				   struct device *old_parent,
Signature · 1 line
1.5.0.2