[PATCH 4/7] device: pm: Add API for power management entity to register pm callbacks


dirk.brandewie@...
 

From: Dirk Brandewie <dirk.j.brandewie(a)intel.com>

Provide a mechanism for the power management infrastructure to be
notified of power management events in the driver.

Change-Id: If78fe3610679ba82c52c1ef056781f8afd0be352
Signed-off-by: Dirk Brandewie <dirk.j.brandewie(a)intel.com>
---
include/device.h | 18 ++++++++++++++++++
include/pm.h | 25 +++++++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 include/pm.h

diff --git a/include/device.h b/include/device.h
index 793b68f..95fbcb4 100644
--- a/include/device.h
+++ b/include/device.h
@@ -33,6 +33,8 @@
extern "C" {
#endif

+#include <pm.h>
+
/**
* @def DEVICE_INIT
*
@@ -230,6 +232,8 @@ struct device;
struct device_ops {
int (*suspend)(struct device *device);
int (*resume)(struct device *device);
+ void (*register_pm_ops)(struct device *device,
+ struct pm_ops *pm_ops, void *context);
};

/**
@@ -278,6 +282,20 @@ static inline int device_resume(struct device *device)
return device->config->dev_ops->resume(device);
}

+static inline int _null_device_register_pm_ops(struct device *device,
+ struct pm_ops *pm_ops,
+ void *context)
+{
+ return 0;
+};
+
+static inline void device_register_pm_ops(struct device *device,
+ struct pm_ops *pm_ops,
+ void *context)
+{
+ device->config->dev_ops->register_pm_ops(device, pm_ops, context);
+}
+
/**
* Synchronous calls API
*/
diff --git a/include/pm.h b/include/pm.h
new file mode 100644
index 0000000..a63e693
--- /dev/null
+++ b/include/pm.h
@@ -0,0 +1,25 @@
+
+/*
+ * Copyright (c) 2015 Intel Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _PM_H_
+#define _PM_H_
+
+struct pm_ops {
+ void (*suspend)(void* context);
+ void (*resume)(void* context);
+};
+#endif /* _PM_H_ */
--
2.4.3