Re: 2.6.19-rc3-mm1 -- missing network adaptors

Cornelia Huck
2006-10-31T08:02:41Z

On Mon, 30 Oct 2006 21:14:32 +0100,
Cornelia Huck <cornelia.huck@de.ibm.com> wrote:

> With CONFIG_SYSFS_DEPRECATED set, you'll get errors for devices which
> have no parent set. The kobject's parent is set to the class
> subsystem's kobject, meaning there is a child with name bus_id (e.
> g. /sys/class/net/lo). Unfortunately, we also try to create a link
> named bus_id in /sys/class/<foo>, which will fail with -EEXIST... We
> should probably drop that link if we have no parent.

You can use the following as a band-aid (everything looks sane on my
system), although you will still have problems if your setup tools
can't cope with symlinks :/ (a link is still created for devices with
real parents).

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

---
drivers/base/core.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)

--- linux-2.6-CH.orig/drivers/base/core.c
+++ linux-2.6-CH/drivers/base/core.c
@@ -368,6 +368,12 @@ static void klist_children_put(struct kl
static int device_add_class_symlinks(struct device *dev)
{
int error;
+ int create_link =
+#ifdef CONFIG_SYSFS_DEPRECATED
+ dev->parent ? 1 : 0;
+#else
+ 1;
+#endif

if (!dev->class)
return 0;
@@ -375,10 +381,12 @@ static int device_add_class_symlinks(str
"subsystem");
if (error)
goto out;
- error = sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj,
- dev->bus_id);
- if (error)
- goto out_subsys;
+ if (create_link) {
+ error = sysfs_create_link(&dev->class->subsys.kset.kobj,
+ &dev->kobj, dev->bus_id);
+ if (error)
+ goto out_subsys;
+ }
#ifdef CONFIG_SYSFS_DEPRECATED
if (dev->parent) {
char *class_name;
@@ -407,7 +415,8 @@ out_device:
sysfs_remove_link(&dev->kobj, "device");
out_busid:
#endif
- sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
+ if (create_link)
+ sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
out_subsys:
sysfs_remove_link(&dev->kobj, "subsystem");