Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 33165
b: refs/heads/master
c: 3bcb09a
h: refs/heads/master
i:
  33163: db0f1de
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Dave Jones committed Jul 31, 2006
1 parent b2e818e commit b291e19
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 32deb2d5c4c291d7d9a73198dc357a151e4b978c
refs/heads/master: 3bcb09a35641f2840bd59d8f82154f830dca282c
57 changes: 34 additions & 23 deletions trunk/drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,39 +284,52 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);
* SYSFS INTERFACE *
*********************************************************************/

static struct cpufreq_governor *__find_governor(const char *str_governor)
{
struct cpufreq_governor *t;

list_for_each_entry(t, &cpufreq_governor_list, governor_list)
if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN))
return t;

return NULL;
}

/**
* cpufreq_parse_governor - parse a governor string
*/
static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
struct cpufreq_governor **governor)
{
int err = -EINVAL;

if (!cpufreq_driver)
return -EINVAL;
goto out;

if (cpufreq_driver->setpolicy) {
if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
*policy = CPUFREQ_POLICY_PERFORMANCE;
return 0;
err = 0;
} else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) {
*policy = CPUFREQ_POLICY_POWERSAVE;
return 0;
err = 0;
}
return -EINVAL;
} else {
} else if (cpufreq_driver->target) {
struct cpufreq_governor *t;

mutex_lock(&cpufreq_governor_mutex);
if (!cpufreq_driver || !cpufreq_driver->target)
goto out;
list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) {
*governor = t;
mutex_unlock(&cpufreq_governor_mutex);
return 0;
}

t = __find_governor(str_governor);

if (t != NULL) {
*governor = t;
err = 0;
}
out:

mutex_unlock(&cpufreq_governor_mutex);
}
return -EINVAL;
out:
return err;
}


Expand Down Expand Up @@ -1265,23 +1278,21 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)

int cpufreq_register_governor(struct cpufreq_governor *governor)
{
struct cpufreq_governor *t;
int err;

if (!governor)
return -EINVAL;

mutex_lock(&cpufreq_governor_mutex);

list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
mutex_unlock(&cpufreq_governor_mutex);
return -EBUSY;
}
err = -EBUSY;
if (__find_governor(governor->name) == NULL) {
err = 0;
list_add(&governor->governor_list, &cpufreq_governor_list);
}
list_add(&governor->governor_list, &cpufreq_governor_list);

mutex_unlock(&cpufreq_governor_mutex);
return 0;
return err;
}
EXPORT_SYMBOL_GPL(cpufreq_register_governor);

Expand Down

0 comments on commit b291e19

Please sign in to comment.