]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/core.c
[TCP] FRTO: Improve interoperability with other undo_marker users
[linux-2.6-omap-h63xx.git] / drivers / base / core.c
index 3599ab2506d269ee299b1b8e807746bcbca98391..ec86d6fc2360bbb3fa6286a1972a7f82f36c3699 100644 (file)
@@ -24,8 +24,6 @@
 #include "base.h"
 #include "power/power.h"
 
-extern const char *kobject_actions[];
-
 int (*platform_notify)(struct device * dev) = NULL;
 int (*platform_notify_remove)(struct device * dev) = NULL;
 
@@ -286,6 +284,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 
        /* let the kset specific function add its keys */
        pos = data;
+       memset(envp, 0, sizeof(envp));
        retval = kset->uevent_ops->uevent(kset, &dev->kobj,
                                          envp, ARRAY_SIZE(envp),
                                          pos, PAGE_SIZE);
@@ -587,9 +586,13 @@ void device_initialize(struct device *dev)
 static struct kobject * get_device_parent(struct device *dev,
                                          struct device *parent)
 {
-       /* Set the parent to the class, not the parent device */
-       /* this keeps sysfs from having a symlink to make old udevs happy */
-       if (dev->class)
+       /*
+        * Set the parent to the class, not the parent device
+        * for topmost devices in class hierarchy.
+        * This keeps sysfs from having a symlink to make old
+        * udevs happy
+        */
+       if (dev->class && (!parent || parent->class != dev->class))
                return &dev->class->subsys.kobj;
        else if (parent)
                return &parent->kobj;
@@ -680,16 +683,27 @@ static int device_add_class_symlinks(struct device *dev)
                if (error)
                        goto out_subsys;
        }
-       /* only bus-device parents get a "device"-link */
-       if (dev->parent && dev->parent->bus) {
-               error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
-                                         "device");
-               if (error)
-                       goto out_busid;
+       if (dev->parent) {
 #ifdef CONFIG_SYSFS_DEPRECATED
                {
-                       char * class_name = make_class_name(dev->class->name,
-                                                               &dev->kobj);
+                       struct device *parent = dev->parent;
+                       char *class_name;
+
+                       /*
+                        * In old sysfs stacked class devices had 'device'
+                        * link pointing to real device instead of parent
+                        */
+                       while (parent->class && !parent->bus && parent->parent)
+                               parent = parent->parent;
+
+                       error = sysfs_create_link(&dev->kobj,
+                                                 &parent->kobj,
+                                                 "device");
+                       if (error)
+                               goto out_busid;
+
+                       class_name = make_class_name(dev->class->name,
+                                                       &dev->kobj);
                        if (class_name)
                                error = sysfs_create_link(&dev->parent->kobj,
                                                        &dev->kobj, class_name);
@@ -697,6 +711,11 @@ static int device_add_class_symlinks(struct device *dev)
                        if (error)
                                goto out_device;
                }
+#else
+               error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
+                                         "device");
+               if (error)
+                       goto out_busid;
 #endif
        }
        return 0;