[PATCH 3/7] device: Add API to suspend/resume all devices in the system.
dirk.brandewie@...
From: Dirk Brandewie <dirk.j.brandewie(a)intel.com>
Change-Id: Iea0f97998bec4e2b0443a8fcc712dad71d42ae54
Signed-off-by: Dirk Brandewie <dirk.j.brandewie(a)intel.com>
---
include/device.h | 2 ++
kernel/nanokernel/device.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/include/device.h b/include/device.h
index 40adbe8..793b68f 100644
--- a/include/device.h
+++ b/include/device.h
@@ -260,6 +260,8 @@ struct device {
void _sys_device_do_config_level(int level);
struct device* device_get_binding(char *name);
+void device_suspend_all(void);
+void device_resume_all(void);
static inline int _null_suspend_resume(struct device *device)
{
diff --git a/kernel/nanokernel/device.c b/kernel/nanokernel/device.c
index f86f95f..e862ef8 100644
--- a/kernel/nanokernel/device.c
+++ b/kernel/nanokernel/device.c
@@ -42,6 +42,46 @@ void _sys_device_do_config_level(int level)
}
/**
+ * @brief Execute all the device suspend proceedures
+ *
+ * @details Invokes the suspend routine for each device object
+ * created by the SYS_DEFINE_DEVICE_PM().
+ * The linker script places the device objects in memory in the order
+ * required to maintain device dependencies.
+ *
+ */
+void device_suspend_all(void)
+{
+ struct device *info;
+
+ for (info = __device_init_end -1 ;
+ info > __device_init_start ; info--) {
+ struct device_config *device = info->config;
+ device->dev_ops->suspend(info);
+ }
+}
+
+/**
+ * @brief Execute all the device resume proceedures
+ *
+ * @details Invokes the resume routine for each device object
+ * created by the SYS_DEFINE_DEVICE_PM().
+ * The linker script places the device objects in memory in the order
+ * required to maintain device dependencies.
+ *
+ */
+void device_resume_all(void)
+{
+ struct device *info;
+
+ for (info = __device_init_start;
+ info < __device_init_end ; info++) {
+ struct device_config *device = info->config;
+ device->dev_ops->resume(info);
+ }
+}
+
+/**
* @brief Retrieve the device structure for a driver by name
*
* @details Device objects are created via the DEVICE_INIT() macro and
--
2.4.3
Change-Id: Iea0f97998bec4e2b0443a8fcc712dad71d42ae54
Signed-off-by: Dirk Brandewie <dirk.j.brandewie(a)intel.com>
---
include/device.h | 2 ++
kernel/nanokernel/device.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/include/device.h b/include/device.h
index 40adbe8..793b68f 100644
--- a/include/device.h
+++ b/include/device.h
@@ -260,6 +260,8 @@ struct device {
void _sys_device_do_config_level(int level);
struct device* device_get_binding(char *name);
+void device_suspend_all(void);
+void device_resume_all(void);
static inline int _null_suspend_resume(struct device *device)
{
diff --git a/kernel/nanokernel/device.c b/kernel/nanokernel/device.c
index f86f95f..e862ef8 100644
--- a/kernel/nanokernel/device.c
+++ b/kernel/nanokernel/device.c
@@ -42,6 +42,46 @@ void _sys_device_do_config_level(int level)
}
/**
+ * @brief Execute all the device suspend proceedures
+ *
+ * @details Invokes the suspend routine for each device object
+ * created by the SYS_DEFINE_DEVICE_PM().
+ * The linker script places the device objects in memory in the order
+ * required to maintain device dependencies.
+ *
+ */
+void device_suspend_all(void)
+{
+ struct device *info;
+
+ for (info = __device_init_end -1 ;
+ info > __device_init_start ; info--) {
+ struct device_config *device = info->config;
+ device->dev_ops->suspend(info);
+ }
+}
+
+/**
+ * @brief Execute all the device resume proceedures
+ *
+ * @details Invokes the resume routine for each device object
+ * created by the SYS_DEFINE_DEVICE_PM().
+ * The linker script places the device objects in memory in the order
+ * required to maintain device dependencies.
+ *
+ */
+void device_resume_all(void)
+{
+ struct device *info;
+
+ for (info = __device_init_start;
+ info < __device_init_end ; info++) {
+ struct device_config *device = info->config;
+ device->dev_ops->resume(info);
+ }
+}
+
+/**
* @brief Retrieve the device structure for a driver by name
*
* @details Device objects are created via the DEVICE_INIT() macro and
--
2.4.3