extern struct resmon_ops *resmon_get_ops(enum resmon_src_type src_type);
-/**
- * @brief Specify the supported sources of timer-based resource monitor
- * according the type of h/w resource.
- */
-uint64 available_resmon_timer[] = {
- [PASS_RESOURCE_UNKNOWN] = 0,
- [PASS_RESOURCE_CPU_ID] = RESMON_SRC_THERMAL
- | RESMON_SRC_CPUHP,
- [PASS_RESOURCE_BUS_ID] = 0,
- [PASS_RESOURCE_GPU_ID] = RESMON_SRC_THERMAL,
- [PASS_RESOURCE_MEMORY_ID] = 0,
- [PASS_RESOURCE_BATTERY_ID] = RESMON_SRC_THERMAL,
- [PASS_RESOURCE_NONSTANDARD_ID] = RESMON_SRC_THERMAL
-};
-
-/**
- * @brief Specify the supported sources of uevent-based resource monitor
- * according the type of h/w resource.
- */
-uint64 available_resmon_uevent[] = {
- [PASS_RESOURCE_UNKNOWN] = 0,
- [PASS_RESOURCE_CPU_ID] = RESMON_SRC_THERMAL,
- [PASS_RESOURCE_BUS_ID] = 0,
- [PASS_RESOURCE_GPU_ID] = RESMON_SRC_THERMAL,
- [PASS_RESOURCE_MEMORY_ID] = 0,
- [PASS_RESOURCE_BATTERY_ID] = RESMON_SRC_THERMAL,
- [PASS_RESOURCE_NONSTANDARD_ID] = RESMON_SRC_THERMAL
-};
-
-static bool resmon_is_supported(unsigned int res_type,
- enum resmon_type type,
- enum resmon_src_type src_type)
-{
- switch (type) {
- case RESMON_TIMER:
- return !!(available_resmon_timer[res_type] & src_type);
- case RESMON_UEVENT:
- return !!(available_resmon_uevent[res_type] & src_type);
- default:
- return false;
- }
-}
-
static bool resmon_is_created(struct pass_resmon *resmon,
enum resmon_type type,
enum resmon_src_type src_type)
return -EINVAL;
resmon = &res->resmon;
-
- /* Check whether the resource monitor is supported or not */
res_type = res->config_data.res_type;
- if (!resmon_is_supported(res_type, RESMON_TIMER, src_type)) {
- _E("invalid value (res_type: %d, src_type: 0x%x)\n",
- res_type, src_type);
- return -EINVAL;
- }
/* Prevent the monitoring of already required type */
if (resmon_is_created(resmon, RESMON_TIMER, src_type)) {
{
struct pass_resmon *resmon;
struct resmon *monitor;
- int res_type;
int ret;
if (!res || src_type == 0 || user_func == NULL) {
resmon = &res->resmon;
- /* Check whether the resource monitor is supported or not */
- res_type = res->config_data.res_type;
- if (!resmon_is_supported(res_type, RESMON_UEVENT, src_type)) {
- _E("src_type is not supported (res_name: %s, src_type: 0x%x)\n",
- res->config_data.res_name, src_type);
- return -EINVAL;
- }
-
/* Prevent the monitoring of already required type */
if (resmon_is_created(resmon, RESMON_UEVENT, src_type)) {
_E("uevent-based resmon is already created "\