*/
static struct pmqos_scenario *g_pmqos = NULL;
-struct pmqos_cpu {
+struct pmqos_data {
char name[NAME_MAX];
int timeout;
};
guint g_unlock_timeout_id;
static struct timespec unlock_timer_start_st;
static struct timespec unlock_timer_end_st;
-static struct pmqos_cpu unlock_timer_owner = {"", 0};
+static struct pmqos_data unlock_timer_owner = {"", 0};
/******************************************************
* PMQOS callback functions for Init/Exit *
static int compare_timeout(const void *a, const void *b)
{
- const struct pmqos_cpu *pmqos_a = (const struct pmqos_cpu *)a;
- const struct pmqos_cpu *pmqos_b = (const struct pmqos_cpu *)b;
+ const struct pmqos_data *pmqos_a = (const struct pmqos_data *)a;
+ const struct pmqos_data *pmqos_b = (const struct pmqos_data *)b;
if (!pmqos_a)
return 1;
static void pmqos_unlock_timeout_update(void)
{
GList *elem, *next;
- struct pmqos_cpu *cpu;
+ struct pmqos_data *pmqos;
int delta = 0;
clock_gettime(CLOCK_REALTIME, &unlock_timer_end_st);
return;
for (elem = pmqos_head; elem != NULL; elem = elem->next) {
- cpu = elem->data;
- cpu->timeout -= delta;
+ pmqos = elem->data;
+ pmqos->timeout -= delta;
/*
* If timeout is INT_MAX, indicatte 'mode'.
* Don't need to update the timeout and cancel pmqos for mode
* until receiving the cancel request.
*/
- if (cpu->timeout == INT_MAX)
+ if (pmqos->timeout == INT_MAX)
continue;
- if (cpu->timeout < 0)
- cpu->timeout = 0;
- if (cpu->timeout > 0)
+ if (pmqos->timeout < 0)
+ pmqos->timeout = 0;
+ if (pmqos->timeout > 0)
continue;
- /* Set cpu unlock */
- set_pmqos(cpu->name, false);
+ /* Set pmqos unlock */
+ set_pmqos(pmqos->name, false);
}
/* Remove all the requests of which timeout are over from the list */
elem = pmqos_head;
while (elem != NULL) {
- cpu = elem->data;
+ pmqos = elem->data;
next = elem->next;
- if (cpu->timeout <= 0) {
+ if (pmqos->timeout <= 0) {
pmqos_head = g_list_remove(pmqos_head,
- (gconstpointer)cpu);
- free(cpu);
- cpu = NULL;
+ (gconstpointer)pmqos);
+ free(pmqos);
+ pmqos = NULL;
}
elem = next;
}
static int pmqos_cancel(const char *name)
{
GList *elem = NULL;
- struct pmqos_cpu *cpu;
+ struct pmqos_data *pmqos;
/* Find previous request */
for (elem = pmqos_head; elem != NULL; elem = elem->next) {
- cpu = elem->data;
- if (!strcmp(cpu->name, name))
+ pmqos = elem->data;
+ if (!strcmp(pmqos->name, name))
break;
}
if (!elem)
return 0;
- set_pmqos(cpu->name, false);
+ set_pmqos(pmqos->name, false);
- pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu);
- free(cpu);
+ pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos);
+ free(pmqos);
if (strcmp(unlock_timer_owner.name, name))
goto out;
{
int ret;
GList *elem;
- struct pmqos_cpu *cpu;
+ struct pmqos_data *pmqos;
if (g_unlock_timeout_id) {
g_source_remove(g_unlock_timeout_id);
return 0;
for (elem = pmqos_head; elem != NULL; elem = elem->next) {
- cpu = elem->data;
+ pmqos = elem->data;
/*
* If timeout is INT_MAX, indicate 'mode'.
* Don't need to add the timre for 'mode'.
*/
- if (cpu->timeout == INT_MAX)
+ if (pmqos->timeout == INT_MAX)
continue;
- if (cpu->timeout <= 0)
+ if (pmqos->timeout <= 0)
continue;
- memcpy(&unlock_timer_owner, cpu, sizeof(struct pmqos_cpu));
+ memcpy(&unlock_timer_owner, pmqos, sizeof(struct pmqos_data));
clock_gettime(CLOCK_REALTIME, &unlock_timer_start_st);
g_unlock_timeout_id = g_timeout_add(
/* FIXME: this is int to uint conversion. */
if (g_unlock_timeout_id)
break;
- _E("fail init pmqos unlock %s %d", cpu->name, cpu->timeout);
+ _E("fail init pmqos unlock %s %d", pmqos->name, pmqos->timeout);
return -EPERM;
}
return 0;
static int pmqos_request(const char *name, int val)
{
GList *elem;
- struct pmqos_cpu *cpu;
+ struct pmqos_data *pmqos;
int found = 0;
int ret;
for (elem = pmqos_head; elem != NULL; elem = elem->next) {
- cpu = elem->data;
- if (!strcmp(cpu->name, name)) {
- cpu->timeout = val;
+ pmqos = elem->data;
+ if (!strcmp(pmqos->name, name)) {
+ pmqos->timeout = val;
found = 1;
break;
}
}
if (!found) {
- cpu = calloc(1, sizeof(struct pmqos_cpu));
- if (!cpu)
+ pmqos = calloc(1, sizeof(struct pmqos_data));
+ if (!pmqos)
return -ENOMEM;
- snprintf(cpu->name, sizeof(cpu->name), "%s", name);
- cpu->timeout = val;
- pmqos_head = g_list_append(pmqos_head, (gpointer)cpu);
+ snprintf(pmqos->name, sizeof(pmqos->name), "%s", name);
+ pmqos->timeout = val;
+ pmqos_head = g_list_append(pmqos_head, (gpointer)pmqos);
}
pmqos_head = g_list_sort(pmqos_head, compare_timeout);
if (ret < 0)
goto err;
- set_pmqos(cpu->name, true);
+ set_pmqos(pmqos->name, true);
return 0;
err:
if (!found) {
- pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu);
- free(cpu);
+ pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos);
+ free(pmqos);
}
return ret;
memset(&unlock_timer_start_st, 0, sizeof(struct timespec));
memset(&unlock_timer_end_st, 0, sizeof(struct timespec));
- memset(&unlock_timer_owner, 0, sizeof(struct pmqos_cpu));
+ memset(&unlock_timer_owner, 0, sizeof(struct pmqos_data));
if (pmqos_head) {
g_list_free_full(pmqos_head, free);