summaryrefslogtreecommitdiffstats
path: root/drivers/base/power/runtime.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/base/power/runtime.c
downloadop-kernel-dev-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.zip
op-kernel-dev-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.gz
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/base/power/runtime.c')
-rw-r--r--drivers/base/power/runtime.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
new file mode 100644
index 0000000..325962d
--- /dev/null
+++ b/drivers/base/power/runtime.c
@@ -0,0 +1,81 @@
+/*
+ * drivers/base/power/runtime.c - Handling dynamic device power management.
+ *
+ * Copyright (c) 2003 Patrick Mochel
+ * Copyright (c) 2003 Open Source Development Lab
+ *
+ */
+
+#include <linux/device.h>
+#include "power.h"
+
+
+static void runtime_resume(struct device * dev)
+{
+ dev_dbg(dev, "resuming\n");
+ if (!dev->power.power_state)
+ return;
+ if (!resume_device(dev))
+ dev->power.power_state = 0;
+}
+
+
+/**
+ * dpm_runtime_resume - Power one device back on.
+ * @dev: Device.
+ *
+ * Bring one device back to the on state by first powering it
+ * on, then restoring state. We only operate on devices that aren't
+ * already on.
+ * FIXME: We need to handle devices that are in an unknown state.
+ */
+
+void dpm_runtime_resume(struct device * dev)
+{
+ down(&dpm_sem);
+ runtime_resume(dev);
+ up(&dpm_sem);
+}
+
+
+/**
+ * dpm_runtime_suspend - Put one device in low-power state.
+ * @dev: Device.
+ * @state: State to enter.
+ */
+
+int dpm_runtime_suspend(struct device * dev, pm_message_t state)
+{
+ int error = 0;
+
+ down(&dpm_sem);
+ if (dev->power.power_state == state)
+ goto Done;
+
+ if (dev->power.power_state)
+ runtime_resume(dev);
+
+ if (!(error = suspend_device(dev, state)))
+ dev->power.power_state = state;
+ Done:
+ up(&dpm_sem);
+ return error;
+}
+
+
+/**
+ * dpm_set_power_state - Update power_state field.
+ * @dev: Device.
+ * @state: Power state device is in.
+ *
+ * This is an update mechanism for drivers to notify the core
+ * what power state a device is in. Device probing code may not
+ * always be able to tell, but we need accurate information to
+ * work reliably.
+ */
+void dpm_set_power_state(struct device * dev, pm_message_t state)
+{
+ down(&dpm_sem);
+ dev->power.power_state = state;
+ up(&dpm_sem);
+}
OpenPOWER on IntegriCloud