ret = update_resource_attrs(res);
if (ret < 0)
_E("failed to update resource attributes (name:%s,id:%d)\n",
- res->name, res->id);
+ get_resource_name(res),
+ get_resource_id(res));
}
static void
register_resource_to_client(struct request_client *client, struct resource *res)
{
- g_hash_table_insert(client->resource_table, GINT_TO_POINTER(res->id),
- (gpointer)res);
+ g_hash_table_insert(client->resource_table,
+ GINT_TO_POINTER(get_resource_id(res)),
+ (gpointer)res);
+}
static void
unregister_resource_from_client(struct request_client *client, int resource_id)
register_resource_to_client(client, res);
- return res->id;
+ return get_resource_id(res);
}
static int handle_request_delete_resource(struct request_client *client, char *args)
if (!res)
return -EINVAL;
- *start = res->ts_start;
- *end = res->ts_end;
+ get_resource_ts(res, start, end);
return 0;
}
void *data)
{
struct bus_context *ctx;
+ int type;
int *val = (int *)data;
int _val;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n", res->name);
+ _E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
+ type = get_resource_type(res);
+
switch (attr->id) {
case BUS_ATTR_CUR_FREQ:
- _val = hal_power_dvfs_get_curr_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_curr_freq(type, ctx->device_name);
break;
case BUS_ATTR_MIN_FREQ:
- _val = hal_power_dvfs_get_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_min_freq(type, ctx->device_name);
break;
case BUS_ATTR_MAX_FREQ:
- _val = hal_power_dvfs_get_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_max_freq(type, ctx->device_name);
break;
case BUS_ATTR_AVAILABLE_MIN_FREQ:
- _val = hal_power_dvfs_get_available_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_min_freq(type, ctx->device_name);
break;
case BUS_ATTR_AVAILABLE_MAX_FREQ:
- _val = hal_power_dvfs_get_available_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_max_freq(type, ctx->device_name);
break;
default:
return -EINVAL;
const struct resource_attribute *attr,
void *data)
{
- struct bus_context *ctx;
+ struct bus_context *ctx;;
char *buf = (char *)data;
int val;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n", res->name);
+ _E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(res->type, ctx->device_name, buf);
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
if (val < 0)
return -EINVAL;
const struct resource_device *device;
int device_id = (int)(intptr_t)data;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
+ return -EINVAL;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
return -EINVAL;
- device = find_resource_device(res->type, device_id);
+ device = find_resource_device(get_resource_type(res), device_id);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- res->name, device_id);
+ get_resource_name(res), device_id);
return -EINVAL;
}
- ctx = res->priv;
-
if (ctx->device_name)
free(ctx->device_name);
if (!ctx)
return -ENOMEM;
- res->priv = ctx;
+ set_resource_privdata(res, ctx);
return 0;
}
{
struct bus_context *ctx;
- if (res && res->priv) {
- ctx = res->priv;
- if (ctx->device_name) {
- free(ctx->device_name);
- ctx->device_name = NULL;
- }
- free(ctx);
- res->priv = NULL;
+ if (!res)
+ return;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return;
+
+ if (ctx->device_name) {
+ free(ctx->device_name);
+ ctx->device_name = NULL;
}
+ free(ctx);
+ set_resource_privdata(res, NULL);
}
static const struct resource_driver bus_resource_driver = {
},
};
RESOURCE_DRIVER_REGISTER(&bus_resource_driver)
-
{
struct cpu_context *ctx;
int *val = (int *)data;
- int _val;
+ int _val, type;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n", res->name);
+ _E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
+ type = get_resource_type(res);
+
switch (attr->id) {
case CPU_ATTR_CUR_FREQ:
- _val = hal_power_dvfs_get_curr_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_curr_freq(type, ctx->device_name);
break;
case CPU_ATTR_MIN_FREQ:
- _val = hal_power_dvfs_get_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_min_freq(type, ctx->device_name);
break;
case CPU_ATTR_MAX_FREQ:
- _val = hal_power_dvfs_get_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_max_freq(type, ctx->device_name);
break;
case CPU_ATTR_AVAILABLE_MIN_FREQ:
- _val = hal_power_dvfs_get_available_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_min_freq(type, ctx->device_name);
break;
case CPU_ATTR_AVAILABLE_MAX_FREQ:
- _val = hal_power_dvfs_get_available_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_max_freq(type, ctx->device_name);
break;
default:
return -EINVAL;
char *buf = (char *)data;
int val;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n", res->name);
+ _E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(res->type, ctx->device_name, buf);
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
if (val < 0)
return -EINVAL;
const struct resource_device *device;
int resource_index = (int)(intptr_t)data;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
+ return -EINVAL;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
return -EINVAL;
- device = find_resource_device(res->type, resource_index);
+ device = find_resource_device(get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- res->name, resource_index);
+ get_resource_name(res), resource_index);
return -EINVAL;
}
- ctx = res->priv;
-
if (ctx->device_name)
free(ctx->device_name);
static int cpu_init(struct resource *res)
{
- struct cpu_context *ctx;
+ struct cpu_context *ctx = get_resource_privdata(res);
ctx = calloc(1, sizeof(struct cpu_context));
if (!ctx)
return -ENOMEM;
- res->priv = ctx;
+ set_resource_privdata(res, ctx);
return 0;
}
{
struct cpu_context *ctx;
- if (res && res->priv) {
- ctx = res->priv;
- if (ctx->device_name) {
- free(ctx->device_name);
- ctx->device_name = NULL;
- }
- free(ctx);
- res->priv = NULL;
+ if (!res)
+ return;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return;
+
+ if (ctx->device_name) {
+ free(ctx->device_name);
+ ctx->device_name = NULL;
}
+
+ free(ctx);
+ set_resource_privdata(res, NULL);
}
static const struct resource_driver cpu_resource_driver = {
double *fps = (double *)data;
int ret = 0;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- disp_id = res->priv;
+ disp_id = get_resource_privdata(res);
+ if (!disp_id)
+ return -EINVAL;
if (*disp_id < 0) {
- _E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n", res->name);
+ _E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
const struct resource_control *ctrl,
const void *data)
{
- int *disp_id;
+ int *disp_id = NULL;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
return -EINVAL;
- disp_id = res->priv;
+ disp_id = get_resource_privdata(res);
+ if (!disp_id)
+ return -EINVAL;
*disp_id = (int)(intptr_t)data;
+ set_resource_privdata(res, disp_id);
+
return 0;
}
*disp_id = -1;
- res->priv = disp_id;
+ set_resource_privdata(res, disp_id);
return 0;
}
static void display_exit(struct resource *res)
{
- if (res && res->priv)
- free(res->priv);
+ int *disp_id;
+
+ if (!res)
+ return;
+
+ disp_id = get_resource_privdata(res);
+ if (!disp_id)
+ return;
+
+ free(disp_id);
+ set_resource_privdata(res, NULL);
}
+
static const struct resource_driver display_resource_driver = {
.name = "DISPLAY",
.type = RESOURCE_TYPE_DISPLAY,
void *data)
{
struct gpu_context *ctx;
+ int type;
int *val = (int *)data;
int _val;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n", res->name);
+ _E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
+ type = get_resource_type(res);
+
switch (attr->id) {
case GPU_ATTR_CUR_FREQ:
- _val = hal_power_dvfs_get_curr_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_curr_freq(type, ctx->device_name);
break;
case GPU_ATTR_MIN_FREQ:
- _val = hal_power_dvfs_get_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_min_freq(type, ctx->device_name);
break;
case GPU_ATTR_MAX_FREQ:
- _val = hal_power_dvfs_get_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_max_freq(type, ctx->device_name);
break;
case GPU_ATTR_AVAILABLE_MIN_FREQ:
- _val = hal_power_dvfs_get_available_min_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_min_freq(type, ctx->device_name);
break;
case GPU_ATTR_AVAILABLE_MAX_FREQ:
- _val = hal_power_dvfs_get_available_max_freq(res->type, ctx->device_name);
+ _val = hal_power_dvfs_get_available_max_freq(type, ctx->device_name);
break;
default:
return -EINVAL;
char *buf = (char *)data;
int val;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->device_name) {
- _E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n", res->name);
+ _E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(res->type, ctx->device_name, buf);
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
if (val < 0)
return -EINVAL;
const struct resource_device *device;
int resource_index = (int)(intptr_t)data;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
+ return -EINVAL;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
return -EINVAL;
- device = find_resource_device(res->type, resource_index);
+ device = find_resource_device(get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- res->name, resource_index);
+ get_resource_name(res), resource_index);
return -EINVAL;
}
- ctx = res->priv;
-
if (ctx->device_name)
free(ctx->device_name);
if (!ctx)
return -ENOMEM;
- res->priv = ctx;
+ set_resource_privdata(res, ctx);
return 0;
}
{
struct gpu_context *ctx;
- if (res && res->priv) {
- ctx = res->priv;
- if (ctx->device_name) {
- free(ctx->device_name);
- ctx->device_name = NULL;
- }
- free(ctx);
- res->priv = NULL;
+ if (!res)
+ return;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return;
+
+ if (ctx->device_name) {
+ free(ctx->device_name);
+ ctx->device_name = NULL;
}
+ free(ctx);
+ set_resource_privdata(res, NULL);
}
static const struct resource_driver gpu_resource_driver = {
int *data_array;
int i = 0;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->pi_map)
return -EINVAL;
char **data_array;
int i = 0;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->pi_map)
return -EINVAL;
struct process_group_context *ctx;
double *util = (double *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->pi_map || ctx->pid < 0)
return -EINVAL;
struct process_group_context *ctx;
u_int64_t *mem = (u_int64_t *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->pi_map || ctx->pid < 0)
return -EINVAL;
struct process_group_context *ctx;
u_int32_t *bps = (u_int32_t *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->pi_map || ctx->pid < 0)
return -EINVAL;
int target_pid;
int ret;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
target_pid = (int)(intptr_t)data;
int ret = 0;
pid_t tgid;
- if (!res || !res->priv)
+ if (!res)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
task_dir = opendir(PROC_DIR_PATH);
if (!task_dir)
ctx->pid = -1;
ctx->pi_map = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_node);
- res->priv = ctx;
+ set_resource_privdata(res, ctx);
return 0;
}
{
struct process_group_context *ctx;
- if (res && res->priv) {
- ctx = res->priv;
+ if (!res)
+ return;
- if (ctx->pi_map) {
- g_hash_table_destroy(ctx->pi_map);
- ctx->pi_map = NULL;
- }
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return;
- free(res->priv);
+ if (ctx->pi_map) {
+ g_hash_table_destroy(ctx->pi_map);
+ ctx->pi_map = NULL;
}
+
+ free(ctx);
+ set_resource_privdata(res, NULL);
}
static const struct resource_driver process_group_driver = {
struct taskstats *prev, *curr;
double *util = (double *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->tgid) {
- _E("resource %s is not yet initialized\n", res->name);
+ _E("resource %s is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
struct taskstats *curr;
u_int64_t *mem = (u_int64_t *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->tgid) {
- _E("resource %s is not yet initialized\n", res->name);
+ _E("resource %s is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
u_int64_t period;
u_int32_t *bps = (u_int32_t *)data;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->tgid) {
- _E("resource %s is not yet initialized\n", res->name);
+ _E("resource %s is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
{
struct process_context *ctx;
- if (!res || !res->priv || !attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
if (!ctx->tgid) {
- _E("resource %s is not yet initialized\n", res->name);
+ _E("resource %s is not yet initialized\n",
+ get_resource_name(res));
return -EINVAL;
}
struct process_context *ctx;
u_int64_t total_memory;
int ret;
- bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
+ bool include_gpu_mem;
- if (!res || !res->priv || !ctrl)
+ if (!res || !ctrl)
return -EINVAL;
- ctx = res->priv;
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
+ include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
total_memory = ctx->total_memory;
memset(ctx, 0, sizeof(*ctx));
static int process_prepare_update(struct resource *res)
{
- struct process_context *ctx = res->priv;
+ struct process_context *ctx;
u_int64_t total_time;
int ret, online;
- bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
+ bool include_gpu_mem;
+
+ if (!res)
+ return -EINVAL;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
+
+ include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
memcpy(&ctx->prev, &ctx->curr, sizeof(struct taskstats));
return -EINVAL;
}
- res->priv = ctx;
+ set_resource_privdata(res, ctx);
return 0;
}
{
struct process_context *ctx;
- if (res->priv) {
- ctx = res->priv;
- free(ctx);
- res->priv = NULL;
- }
+ if (!res)
+ return;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return;
+
+ free(ctx);
+ set_resource_privdata(res, NULL);
}
static const struct resource_driver process_resource_driver = {
struct system_resouce_data *sysdata;
double *util = (double *)data;
- if (!res || !res->priv ||!attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- sysdata = (struct system_resouce_data *)res->priv;
+ sysdata = get_resource_privdata(res);
+ if (!sysdata)
+ return -EINVAL;
*util = __calculate_cpu_util(attr->id, &sysdata->prev_avg, &sysdata->curr_avg);
if (*util < 0) {
- _W("failed to calculate average cpu util (%s: %s)\n", res->name, attr->name);
+ _W("failed to calculate average cpu util (%s: %s)\n",
+ get_resource_name(res), attr->name);
*util = 0.0;
}
double *utils;
int i;
- if (!res || !res->priv ||!attr || !data)
+ if (!res || !attr || !data)
return -EINVAL;
- sysdata = (struct system_resouce_data *)res->priv;
+ sysdata = get_resource_privdata(res);
+ if (!sysdata)
+ return -EINVAL;
array->type = DATA_TYPE_DOUBLE;
array->length = sysdata->num_possible_cpus;
&sysdata->prev_cpus[i],
&sysdata->curr_cpus[i]);
if (utils[i] < 0) {
- _W("failed to calculate per-cpu util (%s: %s)\n", res->name, attr->name);
+ _W("failed to calculate per-cpu util (%s: %s)\n",
+ get_resource_name(res), attr->name);
utils[i] = 0;
}
}
static int system_driver_init(struct resource *res)
{
struct system_resouce_data *sysdata;
+ const char *res_name = get_resource_name(res);
int ret;
sysdata = calloc(1, sizeof(struct system_resouce_data));
ret = kernel_get_possible_cpu_num();
if (ret < 0) {
- _I("failed to get possible cpu on system driver (%s)\n", res->name);
+ _I("failed to get possible cpu on system driver (%s)\n", res_name);
goto err;
}
sysdata->num_possible_cpus = ret;
sysdata->prev_cpus = calloc(sysdata->num_possible_cpus,
sizeof(struct cpu_stat));
if (!sysdata->prev_cpus) {
- _I("failed to allocate memory of prev_cpus (%s)\n", res->name);
+ _I("failed to allocate memory of prev_cpus (%s)\n", res_name);
ret = -ENOMEM;
goto err;
}
sysdata->curr_cpus = calloc(sysdata->num_possible_cpus,
sizeof(struct cpu_stat));
if (!sysdata->curr_cpus) {
- _I("failed to allocate memory of curr_cpus (%s)\n", res->name);
+ _I("failed to allocate memory of curr_cpus (%s)\n", res_name);
ret = -ENOMEM;
goto err_prev_cpus;
}
- res->priv = (void *)sysdata;
+ set_resource_privdata(res, (void *)sysdata);
return 0;
static void system_driver_exit(struct resource *res)
{
- struct system_resouce_data *sysdata
- = (struct system_resouce_data *)res->priv;
+ struct system_resouce_data *sysdata;
+
+ if (!res)
+ return;
+
+ sysdata = get_resource_privdata(res);
+ if (!sysdata)
+ return;
free(sysdata->prev_cpus);
free(sysdata->curr_cpus);
free(sysdata);
- res->priv = NULL;
+ set_resource_privdata(res, NULL);
}
static int system_driver_prepare_update(struct resource *res)
{
- struct system_resouce_data *sysdata
- = (struct system_resouce_data *)res->priv;
+ struct system_resouce_data *sysdata = get_resource_privdata(res);
+ const char *res_name = get_resource_name(res);
int ret;
/* Get the average cpu utilization of all cpus */
memcpy(&sysdata->prev_avg, &sysdata->curr_avg, sizeof(sysdata->prev_avg));
ret = kernel_get_total_cpu_stat(&sysdata->curr_avg);
if (ret < 0) {
- _I("failed to calculate average cpu util (%s)\n", res->name);
+ _I("failed to calculate average cpu util (%s)\n", res_name);
return ret;
}
sysdata->num_possible_cpus,
&sysdata->num_online_cpus);
if (ret < 0) {
- _I("failed to calculate per-cpu util (%s)\n", res->name);
+ _I("failed to calculate per-cpu util (%s)\n", res_name);
return ret;
}