]> err.no Git - linux-2.6/blobdiff - drivers/base/core.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6] / drivers / base / core.c
index d487c032dc4ad0f8b5dfb3fc691a632fd8226d71..2683eac30c68138220500217ddfdc550a7b24e81 100644 (file)
@@ -108,7 +108,7 @@ static void device_release(struct kobject * kobj)
        }
 }
 
-static struct kobj_type ktype_device = {
+static struct kobj_type device_ktype = {
        .release        = device_release,
        .sysfs_ops      = &dev_sysfs_ops,
 };
@@ -118,7 +118,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
 {
        struct kobj_type *ktype = get_ktype(kobj);
 
-       if (ktype == &ktype_device) {
+       if (ktype == &device_ktype) {
                struct device *dev = to_dev(kobj);
                if (dev->uevent_suppress)
                        return 0;
@@ -234,13 +234,11 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 
        /* search the kset, the device belongs to */
        top_kobj = &dev->kobj;
-       if (!top_kobj->kset && top_kobj->parent) {
-               do {
-                       top_kobj = top_kobj->parent;
-               } while (!top_kobj->kset && top_kobj->parent);
-       }
+       while (!top_kobj->kset && top_kobj->parent)
+               top_kobj = top_kobj->parent;
        if (!top_kobj->kset)
                goto out;
+
        kset = top_kobj->kset;
        if (!kset->uevent_ops || !kset->uevent_ops->uevent)
                goto out;
@@ -270,17 +268,9 @@ out:
 static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       size_t len = count;
        enum kobject_action action;
 
-       if (len && buf[len-1] == '\n')
-               len--;
-
-       for (action = 0; action < KOBJ_MAX; action++) {
-               if (strncmp(kobject_actions[action], buf, len) != 0)
-                       continue;
-               if (kobject_actions[action][len] != '\0')
-                       continue;
+       if (kobject_action_type(buf, count, &action) == 0) {
                kobject_uevent(&dev->kobj, action);
                goto out;
        }
@@ -415,7 +405,7 @@ static struct device_attribute devt_attr =
  *     devices_subsys - structure to be registered with kobject core.
  */
 
-decl_subsys(devices, &ktype_device, &device_uevent_ops);
+decl_subsys(devices, &device_ktype, &device_uevent_ops);
 
 
 /**
@@ -780,9 +770,10 @@ int device_add(struct device *dev)
        error = device_add_attrs(dev);
        if (error)
                goto AttrsError;
-       error = device_pm_add(dev);
+       error = dpm_sysfs_add(dev);
        if (error)
                goto PMError;
+       device_pm_add(dev);
        error = bus_add_device(dev);
        if (error)
                goto BusError;
@@ -807,6 +798,7 @@ int device_add(struct device *dev)
        return error;
  BusError:
        device_pm_remove(dev);
+       dpm_sysfs_remove(dev);
  PMError:
        if (dev->bus)
                blocking_notifier_call_chain(&dev->bus->bus_notifier,
@@ -1238,18 +1230,18 @@ int device_rename(struct device *dev, char *new_name)
                        sysfs_remove_link(&dev->parent->kobj, old_class_name);
                }
        }
-#endif
-
+#else
        if (dev->class) {
                sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
                error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
                                          dev->bus_id);
                if (error) {
-                       /* Uh... how to unravel this if restoring can fail? */
                        dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n",
                                __FUNCTION__, error);
                }
        }
+#endif
+
 out:
        put_device(dev);