Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312782
b: refs/heads/master
c: a914443
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Boyd authored and Rafael J. Wysocki committed Jul 20, 2012
1 parent 6a18db4 commit cf204ac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 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: 53df1ad52545854fc34d336b26f3086b2fb2d6f7
refs/heads/master: a9144436271583115a2230db15d0b6ae2c481d3c
35 changes: 27 additions & 8 deletions trunk/drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void disable_cpufreq(void)
static LIST_HEAD(cpufreq_governor_list);
static DEFINE_MUTEX(cpufreq_governor_mutex);

struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
{
struct cpufreq_policy *data;
unsigned long flags;
Expand All @@ -162,7 +162,7 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
if (!data)
goto err_out_put_module;

if (!kobject_get(&data->kobj))
if (!sysfs && !kobject_get(&data->kobj))
goto err_out_put_module;

spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
Expand All @@ -175,16 +175,35 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
err_out:
return NULL;
}

struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
{
return __cpufreq_cpu_get(cpu, false);
}
EXPORT_SYMBOL_GPL(cpufreq_cpu_get);

static struct cpufreq_policy *cpufreq_cpu_get_sysfs(unsigned int cpu)
{
return __cpufreq_cpu_get(cpu, true);
}

void cpufreq_cpu_put(struct cpufreq_policy *data)
static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs)
{
kobject_put(&data->kobj);
if (!sysfs)
kobject_put(&data->kobj);
module_put(cpufreq_driver->owner);
}

void cpufreq_cpu_put(struct cpufreq_policy *data)
{
__cpufreq_cpu_put(data, false);
}
EXPORT_SYMBOL_GPL(cpufreq_cpu_put);

static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data)
{
__cpufreq_cpu_put(data, true);
}

/*********************************************************************
* EXTERNALLY AFFECTING FREQUENCY CHANGES *
Expand Down Expand Up @@ -617,7 +636,7 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
struct cpufreq_policy *policy = to_policy(kobj);
struct freq_attr *fattr = to_attr(attr);
ssize_t ret = -EINVAL;
policy = cpufreq_cpu_get(policy->cpu);
policy = cpufreq_cpu_get_sysfs(policy->cpu);
if (!policy)
goto no_policy;

Expand All @@ -631,7 +650,7 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)

unlock_policy_rwsem_read(policy->cpu);
fail:
cpufreq_cpu_put(policy);
cpufreq_cpu_put_sysfs(policy);
no_policy:
return ret;
}
Expand All @@ -642,7 +661,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
struct cpufreq_policy *policy = to_policy(kobj);
struct freq_attr *fattr = to_attr(attr);
ssize_t ret = -EINVAL;
policy = cpufreq_cpu_get(policy->cpu);
policy = cpufreq_cpu_get_sysfs(policy->cpu);
if (!policy)
goto no_policy;

Expand All @@ -656,7 +675,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,

unlock_policy_rwsem_write(policy->cpu);
fail:
cpufreq_cpu_put(policy);
cpufreq_cpu_put_sysfs(policy);
no_policy:
return ret;
}
Expand Down

0 comments on commit cf204ac

Please sign in to comment.