pm: add type for device PM control callback
Add a type and documentation for the device PM control callback. This
way possible return codes and its meaning are documented.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
diff --git a/include/device.h b/include/device.h
index 7f93d26..53a245a 100644
--- a/include/device.h
+++ b/include/device.h
@@ -384,8 +384,7 @@
const device_handle_t *const handles;
#ifdef CONFIG_PM_DEVICE
/** Power Management function */
- int (*pm_control)(const struct device *dev,
- enum pm_device_state state);
+ pm_device_control_callback_t pm_control;
/** Pointer to device instance power management data */
struct pm_device * const pm;
#endif
diff --git a/include/pm/device.h b/include/pm/device.h
index 5a019e5..52c481b 100644
--- a/include/pm/device.h
+++ b/include/pm/device.h
@@ -94,6 +94,19 @@
};
/**
+ * @brief Device power management control function callback.
+ *
+ * @param dev Device instance.
+ * @param state Requested state.
+ *
+ * @retval 0 If successful.
+ * @retval -ENOTSUP If the requested state is not supported.
+ * @retval Errno Other negative errno on failure.
+ */
+typedef int (*pm_device_control_callback_t)(const struct device *dev,
+ enum pm_device_state state);
+
+/**
* @brief Get name of device PM state
*
* @param state State id which name should be returned