fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / kernel / power / pm.c
index d1bc943..c50d152 100644 (file)
@@ -23,7 +23,9 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/interrupt.h>
+#include <linux/mutex.h>
 
 int pm_active;
 
@@ -39,7 +41,7 @@ int pm_active;
  *     until a resume but that will be fine.
  */
  
-static DECLARE_MUTEX(pm_devs_lock);
+static DEFINE_MUTEX(pm_devs_lock);
 static LIST_HEAD(pm_devs);
 
 /**
@@ -60,75 +62,19 @@ struct pm_dev *pm_register(pm_dev_t type,
                           unsigned long id,
                           pm_callback callback)
 {
-       struct pm_dev *dev = kmalloc(sizeof(struct pm_dev), GFP_KERNEL);
+       struct pm_dev *dev = kzalloc(sizeof(struct pm_dev), GFP_KERNEL);
        if (dev) {
-               memset(dev, 0, sizeof(*dev));
                dev->type = type;
                dev->id = id;
                dev->callback = callback;
 
-               down(&pm_devs_lock);
+               mutex_lock(&pm_devs_lock);
                list_add(&dev->entry, &pm_devs);
-               up(&pm_devs_lock);
+               mutex_unlock(&pm_devs_lock);
        }
        return dev;
 }
 
-/**
- *     pm_unregister -  unregister a device with power management
- *     @dev: device to unregister
- *
- *     Remove a device from the power management notification lists. The
- *     dev passed must be a handle previously returned by pm_register.
- */
-void pm_unregister(struct pm_dev *dev)
-{
-       if (dev) {
-               down(&pm_devs_lock);
-               list_del(&dev->entry);
-               up(&pm_devs_lock);
-
-               kfree(dev);
-       }
-}
-
-static void __pm_unregister(struct pm_dev *dev)
-{
-       if (dev) {
-               list_del(&dev->entry);
-               kfree(dev);
-       }
-}
-
-/**
- *     pm_unregister_all - unregister all devices with matching callback
- *     @callback: callback function pointer
- *
- *     Unregister every device that would call the callback passed. This
- *     is primarily meant as a helper function for loadable modules. It
- *     enables a module to give up all its managed devices without keeping
- *     its own private list.
- */
-void pm_unregister_all(pm_callback callback)
-{
-       struct list_head *entry;
-
-       if (!callback)
-               return;
-
-       down(&pm_devs_lock);
-       entry = pm_devs.next;
-       while (entry != &pm_devs) {
-               struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
-               entry = entry->next;
-               if (dev->callback == callback)
-                       __pm_unregister(dev);
-       }
-       up(&pm_devs_lock);
-}
-
 /**
  *     pm_send - send request to a single device
  *     @dev: device to send to
@@ -151,7 +97,7 @@ void pm_unregister_all(pm_callback callback)
  *     execution and unload yourself.
  */
  
-int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
+static int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
 {
        int status = 0;
        unsigned long prev_state, next_state;
@@ -234,7 +180,7 @@ int pm_send_all(pm_request_t rqst, void *data)
 {
        struct list_head *entry;
        
-       down(&pm_devs_lock);
+       mutex_lock(&pm_devs_lock);
        entry = pm_devs.next;
        while (entry != &pm_devs) {
                struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
@@ -246,51 +192,18 @@ int pm_send_all(pm_request_t rqst, void *data)
                                 */
                                if (rqst == PM_SUSPEND)
                                        pm_undo_all(dev);
-                               up(&pm_devs_lock);
+                               mutex_unlock(&pm_devs_lock);
                                return status;
                        }
                }
                entry = entry->next;
        }
-       up(&pm_devs_lock);
+       mutex_unlock(&pm_devs_lock);
        return 0;
 }
 
-/**
- *     pm_find  - find a device
- *     @type: type of device
- *     @from: where to start looking
- *
- *     Scan the power management list for devices of a specific type. The
- *     return value for a matching device may be passed to further calls
- *     to this function to find further matches. A %NULL indicates the end
- *     of the list. 
- *
- *     To search from the beginning pass %NULL as the @from value.
- *
- *     The caller MUST hold the pm_devs_lock lock when calling this 
- *     function. The instant that the lock is dropped all pointers returned
- *     may become invalid.
- */
-struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
-{
-       struct list_head *entry = from ? from->entry.next:pm_devs.next;
-       while (entry != &pm_devs) {
-               struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
-               if (type == PM_UNKNOWN_DEV || dev->type == type)
-                       return dev;
-               entry = entry->next;
-       }
-       return NULL;
-}
-
 EXPORT_SYMBOL(pm_register);
-EXPORT_SYMBOL(pm_unregister);
-EXPORT_SYMBOL(pm_unregister_all);
-EXPORT_SYMBOL(pm_send);
 EXPORT_SYMBOL(pm_send_all);
-EXPORT_SYMBOL(pm_find);
 EXPORT_SYMBOL(pm_active);