sysfs: add copyrights
[linux-2.6/mini2440.git] / drivers / base / power / main.c
blobeb9f38d0aa58f3d13928923627d66512e3255c38
1 /*
2 * drivers/base/power/main.c - Where the driver meets power management.
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
7 * This file is released under the GPLv2
10 * The driver model core calls device_pm_add() when a device is registered.
11 * This will intialize the embedded device_pm_info object in the device
12 * and add it to the list of power-controlled devices. sysfs entries for
13 * controlling device power management will also be added.
15 * A different set of lists than the global subsystem list are used to
16 * keep track of power info because we use different lists to hold
17 * devices based on what stage of the power management process they
18 * are in. The power domain dependencies may also differ from the
19 * ancestral dependencies that the subsystem list maintains.
22 #include <linux/device.h>
23 #include <linux/mutex.h>
25 #include "power.h"
27 LIST_HEAD(dpm_active);
28 LIST_HEAD(dpm_off);
29 LIST_HEAD(dpm_off_irq);
31 DEFINE_MUTEX(dpm_mtx);
32 DEFINE_MUTEX(dpm_list_mtx);
34 int (*platform_enable_wakeup)(struct device *dev, int is_on);
36 int device_pm_add(struct device *dev)
38 int error;
40 pr_debug("PM: Adding info for %s:%s\n",
41 dev->bus ? dev->bus->name : "No Bus",
42 kobject_name(&dev->kobj));
43 mutex_lock(&dpm_list_mtx);
44 list_add_tail(&dev->power.entry, &dpm_active);
45 error = dpm_sysfs_add(dev);
46 if (error)
47 list_del(&dev->power.entry);
48 mutex_unlock(&dpm_list_mtx);
49 return error;
52 void device_pm_remove(struct device *dev)
54 pr_debug("PM: Removing info for %s:%s\n",
55 dev->bus ? dev->bus->name : "No Bus",
56 kobject_name(&dev->kobj));
57 mutex_lock(&dpm_list_mtx);
58 dpm_sysfs_remove(dev);
59 list_del_init(&dev->power.entry);
60 mutex_unlock(&dpm_list_mtx);