mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-29 11:54:38 +01:00
LinuxKPI: re-implement pm_runtime.h
The original implementation was based on OpenBSD under public domain but just defined the functions to void. FreeBSD later extended the file with more inline functions or dealing with differences in Linux versions. This rework tries to group some functions, adds properly typed arguments and return values in some cases. It further adjusts return values based on the !CONFIG_PM expectations. Lastly pr_debug() calls are added so we could see if/how much these functions are used in new/other works rather than code just compiling but the functions entirely being ignored without the knowledge of the person porting code. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D58169
This commit is contained in:
1 parent
53beb6950f
commit
863fe7ae51
1 file changed
+136
-32
@@ -1,60 +1,164 @@
|
||||
/* Public domain. */
|
||||
/*
|
||||
* Copyright (c) 2026 The FreeBSD Foundation
|
||||
*
|
||||
* Portions of this software were developed by Björn Zeeb
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifndef _LINUXKPI_LINUX_PM_RUNTIME_H_
|
||||
#define _LINUXKPI_LINUX_PM_RUNTIME_H_
|
||||
|
||||
#include <linux/kernel.h> /* pr_debug */
|
||||
#include <linux/device.h>
|
||||
#include <linux/pm.h>
|
||||
|
||||
#define pm_runtime_mark_last_busy(x) (void)(x)
|
||||
#define pm_runtime_use_autosuspend(x) (void)(x)
|
||||
#define pm_runtime_dont_use_autosuspend(x) (void)(x)
|
||||
#define pm_runtime_put_autosuspend(x) (void)(x)
|
||||
#define pm_runtime_set_autosuspend_delay(x, y) (void)(x); (void)(y)
|
||||
#define pm_runtime_set_active(x) (void)(x)
|
||||
#define pm_runtime_allow(x) (void)(x)
|
||||
#define pm_runtime_put_noidle(x) (void)(x)
|
||||
#define pm_runtime_forbid(x) (void)(x)
|
||||
#define pm_runtime_get_noresume(x) (void)(x)
|
||||
#define pm_runtime_put(x) (void)(x)
|
||||
#define pm_runtime_enable(x) (void)(x)
|
||||
#define pm_runtime_disable(x) (void)(x)
|
||||
#define pm_runtime_autosuspend(x) (void)(x)
|
||||
#define pm_runtime_resume(x) (void)(x)
|
||||
/*
|
||||
* Return values, where needed, are based on the !CONFIG_PM/!CONFIG_PM_SLEEP
|
||||
* assumption given we currently do not support anything in here.
|
||||
* We could #error in case CONFIG_PM or CONFIG_PM_SLEEP are set but that
|
||||
* would likely be too intrusive for now.
|
||||
*
|
||||
* We could likely use dev_dbg() in here instead of pr_debug() if the former
|
||||
* would be mapped to the latter with additional dev information.
|
||||
*/
|
||||
|
||||
static inline int
|
||||
pm_runtime_get_sync(struct device *dev)
|
||||
static inline void
|
||||
pm_runtime_enable(struct device *dev __unused)
|
||||
{
|
||||
return 0;
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_disable(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_allow(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_forbid(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
pm_runtime_mark_last_busy(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_get_noresume(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_put_noidle(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
pm_runtime_suspended(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (false);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_get_if_in_use(struct device *dev)
|
||||
pm_runtime_autosuspend(struct device *dev)
|
||||
{
|
||||
return 1;
|
||||
pm_runtime_mark_last_busy(dev);
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (-ENOSYS);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_use_autosuspend(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_dont_use_autosuspend(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_set_autosuspend_delay(struct device *dev __unused, int delay __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_put_autosuspend(struct device *dev)
|
||||
{
|
||||
pm_runtime_mark_last_busy(dev);
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (-ENOSYS);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_set_active(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pm_runtime_put(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_resume(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_get_sync(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_get_if_in_use(struct device *dev __unused)
|
||||
{
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (-EINVAL);
|
||||
}
|
||||
|
||||
#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION < 60900
|
||||
static inline int
|
||||
pm_runtime_get_if_active(struct device *dev, bool x)
|
||||
pm_runtime_get_if_active(struct device *dev __unused, bool x __unused)
|
||||
#else
|
||||
static inline int
|
||||
pm_runtime_get_if_active(struct device *dev)
|
||||
pm_runtime_get_if_active(struct device *dev __unused)
|
||||
#endif
|
||||
{
|
||||
return 1;
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (-EINVAL);
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_suspended(struct device *dev)
|
||||
pm_runtime_resume_and_get(struct device *dev __unused)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
pm_runtime_resume_and_get(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
pr_debug("%s TODO\n", __func__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
#endif /* _LINUXKPI_LINUX_PM_RUNTIME_H_ */
|
||||
Reference in new issue
Block a user