diff options
| author | H. Peter Anvin <hpa@zytor.com> | 2008-08-26 01:45:37 -0400 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2008-08-26 01:45:37 -0400 |
| commit | 94d4ac2f4a58c6e37876827c6688c61cef21290c (patch) | |
| tree | 732f4e4794f3c116041242f69754637f75c0dd57 /drivers/base | |
| parent | ed21763e7b0b3fb50e4efd9d4bc17ef5b035d304 (diff) | |
| parent | 08970fc4e0385790a7b093adfaa4165a189f9eb0 (diff) | |
Merge branch 'x86/urgent' into x86/cleanups
Diffstat (limited to 'drivers/base')
| -rw-r--r-- | drivers/base/class.c | 11 | ||||
| -rw-r--r-- | drivers/base/core.c | 31 | ||||
| -rw-r--r-- | drivers/base/driver.c | 3 | ||||
| -rw-r--r-- | drivers/base/power/main.c | 19 | ||||
| -rw-r--r-- | drivers/base/power/power.h | 9 |
5 files changed, 43 insertions, 30 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 5667c2f02c51..cc5e28c8885c 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
| @@ -295,6 +295,12 @@ int class_for_each_device(struct class *class, struct device *start, | |||
| 295 | 295 | ||
| 296 | if (!class) | 296 | if (!class) |
| 297 | return -EINVAL; | 297 | return -EINVAL; |
| 298 | if (!class->p) { | ||
| 299 | WARN(1, "%s called for class '%s' before it was initialized", | ||
| 300 | __func__, class->name); | ||
| 301 | return -EINVAL; | ||
| 302 | } | ||
| 303 | |||
| 298 | mutex_lock(&class->p->class_mutex); | 304 | mutex_lock(&class->p->class_mutex); |
| 299 | list_for_each_entry(dev, &class->p->class_devices, node) { | 305 | list_for_each_entry(dev, &class->p->class_devices, node) { |
| 300 | if (start) { | 306 | if (start) { |
| @@ -344,6 +350,11 @@ struct device *class_find_device(struct class *class, struct device *start, | |||
| 344 | 350 | ||
| 345 | if (!class) | 351 | if (!class) |
| 346 | return NULL; | 352 | return NULL; |
| 353 | if (!class->p) { | ||
| 354 | WARN(1, "%s called for class '%s' before it was initialized", | ||
| 355 | __func__, class->name); | ||
| 356 | return NULL; | ||
| 357 | } | ||
| 347 | 358 | ||
| 348 | mutex_lock(&class->p->class_mutex); | 359 | mutex_lock(&class->p->class_mutex); |
| 349 | list_for_each_entry(dev, &class->p->class_devices, node) { | 360 | list_for_each_entry(dev, &class->p->class_devices, node) { |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 068aa1c9538c..d021c98605b3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
| @@ -53,7 +53,7 @@ static inline int device_is_not_partition(struct device *dev) | |||
| 53 | * it is attached to. If it is not attached to a bus either, an empty | 53 | * it is attached to. If it is not attached to a bus either, an empty |
| 54 | * string will be returned. | 54 | * string will be returned. |
| 55 | */ | 55 | */ |
| 56 | const char *dev_driver_string(struct device *dev) | 56 | const char *dev_driver_string(const struct device *dev) |
| 57 | { | 57 | { |
| 58 | return dev->driver ? dev->driver->name : | 58 | return dev->driver ? dev->driver->name : |
| 59 | (dev->bus ? dev->bus->name : | 59 | (dev->bus ? dev->bus->name : |
| @@ -541,6 +541,7 @@ void device_initialize(struct device *dev) | |||
| 541 | spin_lock_init(&dev->devres_lock); | 541 | spin_lock_init(&dev->devres_lock); |
| 542 | INIT_LIST_HEAD(&dev->devres_head); | 542 | INIT_LIST_HEAD(&dev->devres_head); |
| 543 | device_init_wakeup(dev, 0); | 543 | device_init_wakeup(dev, 0); |
| 544 | device_pm_init(dev); | ||
| 544 | set_dev_node(dev, -1); | 545 | set_dev_node(dev, -1); |
| 545 | } | 546 | } |
| 546 | 547 | ||
| @@ -843,13 +844,19 @@ int device_add(struct device *dev) | |||
| 843 | { | 844 | { |
| 844 | struct device *parent = NULL; | 845 | struct device *parent = NULL; |
| 845 | struct class_interface *class_intf; | 846 | struct class_interface *class_intf; |
| 846 | int error; | 847 | int error = -EINVAL; |
| 847 | 848 | ||
| 848 | dev = get_device(dev); | 849 | dev = get_device(dev); |
| 849 | if (!dev || !strlen(dev->bus_id)) { | 850 | if (!dev) |
| 850 | error = -EINVAL; | 851 | goto done; |
| 851 | goto Done; | 852 | |
| 852 | } | 853 | /* Temporarily support init_name if it is set. |
| 854 | * It will override bus_id for now */ | ||
| 855 | if (dev->init_name) | ||
| 856 | dev_set_name(dev, "%s", dev->init_name); | ||
| 857 | |||
| 858 | if (!strlen(dev->bus_id)) | ||
| 859 | goto done; | ||
| 853 | 860 | ||
| 854 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); | 861 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
| 855 | 862 | ||
| @@ -897,9 +904,10 @@ int device_add(struct device *dev) | |||
| 897 | error = bus_add_device(dev); | 904 | error = bus_add_device(dev); |
| 898 | if (error) | 905 | if (error) |
| 899 | goto BusError; | 906 | goto BusError; |
| 900 | error = device_pm_add(dev); | 907 | error = dpm_sysfs_add(dev); |
| 901 | if (error) | 908 | if (error) |
| 902 | goto PMError; | 909 | goto DPMError; |
| 910 | device_pm_add(dev); | ||
| 903 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 911 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
| 904 | bus_attach_device(dev); | 912 | bus_attach_device(dev); |
| 905 | if (parent) | 913 | if (parent) |
| @@ -917,10 +925,10 @@ int device_add(struct device *dev) | |||
| 917 | class_intf->add_dev(dev, class_intf); | 925 | class_intf->add_dev(dev, class_intf); |
| 918 | mutex_unlock(&dev->class->p->class_mutex); | 926 | mutex_unlock(&dev->class->p->class_mutex); |
| 919 | } | 927 | } |
| 920 | Done: | 928 | done: |
| 921 | put_device(dev); | 929 | put_device(dev); |
| 922 | return error; | 930 | return error; |
| 923 | PMError: | 931 | DPMError: |
| 924 | bus_remove_device(dev); | 932 | bus_remove_device(dev); |
| 925 | BusError: | 933 | BusError: |
| 926 | if (dev->bus) | 934 | if (dev->bus) |
| @@ -944,7 +952,7 @@ int device_add(struct device *dev) | |||
| 944 | cleanup_device_parent(dev); | 952 | cleanup_device_parent(dev); |
| 945 | if (parent) | 953 | if (parent) |
| 946 | put_device(parent); | 954 | put_device(parent); |
| 947 | goto Done; | 955 | goto done; |
| 948 | } | 956 | } |
| 949 | 957 | ||
| 950 | /** | 958 | /** |
| @@ -1007,6 +1015,7 @@ void device_del(struct device *dev) | |||
| 1007 | struct class_interface *class_intf; | 1015 | struct class_interface *class_intf; |
| 1008 | 1016 | ||
| 1009 | device_pm_remove(dev); | 1017 | device_pm_remove(dev); |
| 1018 | dpm_sysfs_remove(dev); | ||
| 1010 | if (parent) | 1019 | if (parent) |
| 1011 | klist_del(&dev->knode_parent); | 1020 | klist_del(&dev->knode_parent); |
| 1012 | if (MAJOR(dev->devt)) { | 1021 | if (MAJOR(dev->devt)) { |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 2ef5acf4368b..1e2bda780e48 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
| @@ -16,9 +16,6 @@ | |||
| 16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
| 17 | #include "base.h" | 17 | #include "base.h" |
| 18 | 18 | ||
| 19 | #define to_dev(node) container_of(node, struct device, driver_list) | ||
| 20 | |||
| 21 | |||
| 22 | static struct device *next_device(struct klist_iter *i) | 19 | static struct device *next_device(struct klist_iter *i) |
| 23 | { | 20 | { |
| 24 | struct klist_node *n = klist_next(i); | 21 | struct klist_node *n = klist_next(i); |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 3250c5257b74..273a944d4040 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
| @@ -67,20 +67,16 @@ void device_pm_unlock(void) | |||
| 67 | * device_pm_add - add a device to the list of active devices | 67 | * device_pm_add - add a device to the list of active devices |
| 68 | * @dev: Device to be added to the list | 68 | * @dev: Device to be added to the list |
| 69 | */ | 69 | */ |
| 70 | int device_pm_add(struct device *dev) | 70 | void device_pm_add(struct device *dev) |
| 71 | { | 71 | { |
| 72 | int error; | ||
| 73 | |||
| 74 | pr_debug("PM: Adding info for %s:%s\n", | 72 | pr_debug("PM: Adding info for %s:%s\n", |
| 75 | dev->bus ? dev->bus->name : "No Bus", | 73 | dev->bus ? dev->bus->name : "No Bus", |
| 76 | kobject_name(&dev->kobj)); | 74 | kobject_name(&dev->kobj)); |
| 77 | mutex_lock(&dpm_list_mtx); | 75 | mutex_lock(&dpm_list_mtx); |
| 78 | if (dev->parent) { | 76 | if (dev->parent) { |
| 79 | if (dev->parent->power.status >= DPM_SUSPENDING) { | 77 | if (dev->parent->power.status >= DPM_SUSPENDING) |
| 80 | dev_warn(dev, "parent %s is sleeping, will not add\n", | 78 | dev_warn(dev, "parent %s should not be sleeping\n", |
| 81 | dev->parent->bus_id); | 79 | dev->parent->bus_id); |
| 82 | WARN_ON(true); | ||
| 83 | } | ||
| 84 | } else if (transition_started) { | 80 | } else if (transition_started) { |
| 85 | /* | 81 | /* |
| 86 | * We refuse to register parentless devices while a PM | 82 | * We refuse to register parentless devices while a PM |
| @@ -89,13 +85,9 @@ int device_pm_add(struct device *dev) | |||
| 89 | */ | 85 | */ |
| 90 | WARN_ON(true); | 86 | WARN_ON(true); |
| 91 | } | 87 | } |
| 92 | error = dpm_sysfs_add(dev); | 88 | |
| 93 | if (!error) { | 89 | list_add_tail(&dev->power.entry, &dpm_list); |
| 94 | dev->power.status = DPM_ON; | ||
| 95 | list_add_tail(&dev->power.entry, &dpm_list); | ||
| 96 | } | ||
| 97 | mutex_unlock(&dpm_list_mtx); | 90 | mutex_unlock(&dpm_list_mtx); |
| 98 | return error; | ||
| 99 | } | 91 | } |
| 100 | 92 | ||
| 101 | /** | 93 | /** |
| @@ -110,7 +102,6 @@ void device_pm_remove(struct device *dev) | |||
| 110 | dev->bus ? dev->bus->name : "No Bus", | 102 | dev->bus ? dev->bus->name : "No Bus", |
| 111 | kobject_name(&dev->kobj)); | 103 | kobject_name(&dev->kobj)); |
| 112 | mutex_lock(&dpm_list_mtx); | 104 | mutex_lock(&dpm_list_mtx); |
| 113 | dpm_sysfs_remove(dev); | ||
| 114 | list_del_init(&dev->power.entry); | 105 | list_del_init(&dev->power.entry); |
| 115 | mutex_unlock(&dpm_list_mtx); | 106 | mutex_unlock(&dpm_list_mtx); |
| 116 | } | 107 | } |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index a3252c0e2887..41f51fae042f 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | static inline void device_pm_init(struct device *dev) | ||
| 2 | { | ||
| 3 | dev->power.status = DPM_ON; | ||
| 4 | } | ||
| 5 | |||
| 1 | #ifdef CONFIG_PM_SLEEP | 6 | #ifdef CONFIG_PM_SLEEP |
| 2 | 7 | ||
| 3 | /* | 8 | /* |
| @@ -11,12 +16,12 @@ static inline struct device *to_device(struct list_head *entry) | |||
| 11 | return container_of(entry, struct device, power.entry); | 16 | return container_of(entry, struct device, power.entry); |
| 12 | } | 17 | } |
| 13 | 18 | ||
| 14 | extern int device_pm_add(struct device *); | 19 | extern void device_pm_add(struct device *); |
| 15 | extern void device_pm_remove(struct device *); | 20 | extern void device_pm_remove(struct device *); |
| 16 | 21 | ||
| 17 | #else /* CONFIG_PM_SLEEP */ | 22 | #else /* CONFIG_PM_SLEEP */ |
| 18 | 23 | ||
| 19 | static inline int device_pm_add(struct device *dev) { return 0; } | 24 | static inline void device_pm_add(struct device *dev) {} |
| 20 | static inline void device_pm_remove(struct device *dev) {} | 25 | static inline void device_pm_remove(struct device *dev) {} |
| 21 | 26 | ||
| 22 | #endif | 27 | #endif |
