aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/sys.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
committerLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
commit478c6a43fcbc6c11609f8cee7c7b57223907754f (patch)
treea7f7952099da60d33032aed6de9c0c56c9f8779e /drivers/base/sys.c
parent8a3f257c704e02aee9869decd069a806b45be3f1 (diff)
parent6bb597507f9839b13498781e481f5458aea33620 (diff)
Merge branch 'linus' into release
Conflicts: arch/x86/kernel/cpu/cpufreq/longhaul.c Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/base/sys.c')
-rw-r--r--drivers/base/sys.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index b428c8c4bc64..3236b434b964 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -22,6 +22,7 @@
22#include <linux/pm.h> 22#include <linux/pm.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/interrupt.h>
25 26
26#include "base.h" 27#include "base.h"
27 28
@@ -30,10 +31,10 @@
30 31
31 32
32static ssize_t 33static ssize_t
33sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer) 34sysdev_show(struct kobject *kobj, struct attribute *attr, char *buffer)
34{ 35{
35 struct sys_device * sysdev = to_sysdev(kobj); 36 struct sys_device *sysdev = to_sysdev(kobj);
36 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 37 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
37 38
38 if (sysdev_attr->show) 39 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, sysdev_attr, buffer); 40 return sysdev_attr->show(sysdev, sysdev_attr, buffer);
@@ -42,11 +43,11 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
42 43
43 44
44static ssize_t 45static ssize_t
45sysdev_store(struct kobject * kobj, struct attribute * attr, 46sysdev_store(struct kobject *kobj, struct attribute *attr,
46 const char * buffer, size_t count) 47 const char *buffer, size_t count)
47{ 48{
48 struct sys_device * sysdev = to_sysdev(kobj); 49 struct sys_device *sysdev = to_sysdev(kobj);
49 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 50 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
50 51
51 if (sysdev_attr->store) 52 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count); 53 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
@@ -63,13 +64,13 @@ static struct kobj_type ktype_sysdev = {
63}; 64};
64 65
65 66
66int sysdev_create_file(struct sys_device * s, struct sysdev_attribute * a) 67int sysdev_create_file(struct sys_device *s, struct sysdev_attribute *a)
67{ 68{
68 return sysfs_create_file(&s->kobj, &a->attr); 69 return sysfs_create_file(&s->kobj, &a->attr);
69} 70}
70 71
71 72
72void sysdev_remove_file(struct sys_device * s, struct sysdev_attribute * a) 73void sysdev_remove_file(struct sys_device *s, struct sysdev_attribute *a)
73{ 74{
74 sysfs_remove_file(&s->kobj, &a->attr); 75 sysfs_remove_file(&s->kobj, &a->attr);
75} 76}
@@ -84,7 +85,7 @@ EXPORT_SYMBOL_GPL(sysdev_remove_file);
84static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr, 85static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
85 char *buffer) 86 char *buffer)
86{ 87{
87 struct sysdev_class * class = to_sysdev_class(kobj); 88 struct sysdev_class *class = to_sysdev_class(kobj);
88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 89 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
89 90
90 if (class_attr->show) 91 if (class_attr->show)
@@ -95,8 +96,8 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
95static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr, 96static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
96 const char *buffer, size_t count) 97 const char *buffer, size_t count)
97{ 98{
98 struct sysdev_class * class = to_sysdev_class(kobj); 99 struct sysdev_class *class = to_sysdev_class(kobj);
99 struct sysdev_class_attribute * class_attr = to_sysdev_class_attr(attr); 100 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
100 101
101 if (class_attr->store) 102 if (class_attr->store)
102 return class_attr->store(class, buffer, count); 103 return class_attr->store(class, buffer, count);
@@ -128,7 +129,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
128 129
129static struct kset *system_kset; 130static struct kset *system_kset;
130 131
131int sysdev_class_register(struct sysdev_class * cls) 132int sysdev_class_register(struct sysdev_class *cls)
132{ 133{
133 pr_debug("Registering sysdev class '%s'\n", cls->name); 134 pr_debug("Registering sysdev class '%s'\n", cls->name);
134 135
@@ -141,7 +142,7 @@ int sysdev_class_register(struct sysdev_class * cls)
141 return kset_register(&cls->kset); 142 return kset_register(&cls->kset);
142} 143}
143 144
144void sysdev_class_unregister(struct sysdev_class * cls) 145void sysdev_class_unregister(struct sysdev_class *cls)
145{ 146{
146 pr_debug("Unregistering sysdev class '%s'\n", 147 pr_debug("Unregistering sysdev class '%s'\n",
147 kobject_name(&cls->kset.kobj)); 148 kobject_name(&cls->kset.kobj));
@@ -203,8 +204,8 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
203 * @cls: Class driver belongs to. 204 * @cls: Class driver belongs to.
204 * @drv: Driver. 205 * @drv: Driver.
205 */ 206 */
206void sysdev_driver_unregister(struct sysdev_class * cls, 207void sysdev_driver_unregister(struct sysdev_class *cls,
207 struct sysdev_driver * drv) 208 struct sysdev_driver *drv)
208{ 209{
209 mutex_lock(&sysdev_drivers_lock); 210 mutex_lock(&sysdev_drivers_lock);
210 list_del_init(&drv->entry); 211 list_del_init(&drv->entry);
@@ -229,10 +230,10 @@ EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
229 * @sysdev: device in question 230 * @sysdev: device in question
230 * 231 *
231 */ 232 */
232int sysdev_register(struct sys_device * sysdev) 233int sysdev_register(struct sys_device *sysdev)
233{ 234{
234 int error; 235 int error;
235 struct sysdev_class * cls = sysdev->cls; 236 struct sysdev_class *cls = sysdev->cls;
236 237
237 if (!cls) 238 if (!cls)
238 return -EINVAL; 239 return -EINVAL;
@@ -252,7 +253,7 @@ int sysdev_register(struct sys_device * sysdev)
252 sysdev->id); 253 sysdev->id);
253 254
254 if (!error) { 255 if (!error) {
255 struct sysdev_driver * drv; 256 struct sysdev_driver *drv;
256 257
257 pr_debug("Registering sys device '%s'\n", 258 pr_debug("Registering sys device '%s'\n",
258 kobject_name(&sysdev->kobj)); 259 kobject_name(&sysdev->kobj));
@@ -274,9 +275,9 @@ int sysdev_register(struct sys_device * sysdev)
274 return error; 275 return error;
275} 276}
276 277
277void sysdev_unregister(struct sys_device * sysdev) 278void sysdev_unregister(struct sys_device *sysdev)
278{ 279{
279 struct sysdev_driver * drv; 280 struct sysdev_driver *drv;
280 281
281 mutex_lock(&sysdev_drivers_lock); 282 mutex_lock(&sysdev_drivers_lock);
282 list_for_each_entry(drv, &sysdev->cls->drivers, entry) { 283 list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
@@ -299,25 +300,25 @@ void sysdev_unregister(struct sys_device * sysdev)
299 * and the class driver. 300 * and the class driver.
300 * 301 *
301 * Note: The list is iterated in reverse order, so that we shut down 302 * Note: The list is iterated in reverse order, so that we shut down
302 * child devices before we shut down thier parents. The list ordering 303 * child devices before we shut down their parents. The list ordering
303 * is guaranteed by virtue of the fact that child devices are registered 304 * is guaranteed by virtue of the fact that child devices are registered
304 * after their parents. 305 * after their parents.
305 */ 306 */
306void sysdev_shutdown(void) 307void sysdev_shutdown(void)
307{ 308{
308 struct sysdev_class * cls; 309 struct sysdev_class *cls;
309 310
310 pr_debug("Shutting Down System Devices\n"); 311 pr_debug("Shutting Down System Devices\n");
311 312
312 mutex_lock(&sysdev_drivers_lock); 313 mutex_lock(&sysdev_drivers_lock);
313 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { 314 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
314 struct sys_device * sysdev; 315 struct sys_device *sysdev;
315 316
316 pr_debug("Shutting down type '%s':\n", 317 pr_debug("Shutting down type '%s':\n",
317 kobject_name(&cls->kset.kobj)); 318 kobject_name(&cls->kset.kobj));
318 319
319 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) { 320 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
320 struct sysdev_driver * drv; 321 struct sysdev_driver *drv;
321 pr_debug(" %s\n", kobject_name(&sysdev->kobj)); 322 pr_debug(" %s\n", kobject_name(&sysdev->kobj));
322 323
323 /* Call auxillary drivers first */ 324 /* Call auxillary drivers first */
@@ -364,11 +365,18 @@ static void __sysdev_resume(struct sys_device *dev)
364 */ 365 */
365int sysdev_suspend(pm_message_t state) 366int sysdev_suspend(pm_message_t state)
366{ 367{
367 struct sysdev_class * cls; 368 struct sysdev_class *cls;
368 struct sys_device *sysdev, *err_dev; 369 struct sys_device *sysdev, *err_dev;
369 struct sysdev_driver *drv, *err_drv; 370 struct sysdev_driver *drv, *err_drv;
370 int ret; 371 int ret;
371 372
373 pr_debug("Checking wake-up interrupts\n");
374
375 /* Return error code if there are any wake-up interrupts pending */
376 ret = check_wakeup_irqs();
377 if (ret)
378 return ret;
379
372 pr_debug("Suspending System Devices\n"); 380 pr_debug("Suspending System Devices\n");
373 381
374 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { 382 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
@@ -442,12 +450,12 @@ EXPORT_SYMBOL_GPL(sysdev_suspend);
442 */ 450 */
443int sysdev_resume(void) 451int sysdev_resume(void)
444{ 452{
445 struct sysdev_class * cls; 453 struct sysdev_class *cls;
446 454
447 pr_debug("Resuming System Devices\n"); 455 pr_debug("Resuming System Devices\n");
448 456
449 list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) { 457 list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
450 struct sys_device * sysdev; 458 struct sys_device *sysdev;
451 459
452 pr_debug("Resuming type '%s':\n", 460 pr_debug("Resuming type '%s':\n",
453 kobject_name(&cls->kset.kobj)); 461 kobject_name(&cls->kset.kobj));