Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283498
b: refs/heads/master
c: 1c78217
h: refs/heads/master
v: v3
  • Loading branch information
Nishanth Menon authored and Kevin Hilman committed Nov 8, 2011
1 parent 90e471d commit a1847e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 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: 11e04fdd98f0fd6edf1ad6eccb0db4d2f965c392
refs/heads/master: 1c78217fc8c0983f5768a2d1c17c022f1079751e
22 changes: 17 additions & 5 deletions trunk/drivers/cpufreq/omap-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static struct lpj_info global_lpj_ref;
#endif

static struct cpufreq_frequency_table *freq_table;
static atomic_t freq_table_users = ATOMIC_INIT(0);
static struct clk *mpu_clk;
static char *mpu_clk_name;
static struct device *mpu_dev;
Expand Down Expand Up @@ -150,6 +151,12 @@ static int omap_target(struct cpufreq_policy *policy,
return ret;
}

static inline void freq_table_free(void)
{
if (atomic_dec_and_test(&freq_table_users))
opp_free_cpufreq_table(mpu_dev, &freq_table);
}

static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
{
int result = 0;
Expand All @@ -164,7 +171,9 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
}

policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu);
result = opp_init_cpufreq_table(mpu_dev, &freq_table);

if (atomic_inc_return(&freq_table_users) == 1)
result = opp_init_cpufreq_table(mpu_dev, &freq_table);

if (result) {
dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n",
Expand All @@ -173,10 +182,10 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
}

result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
if (!result)
cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
else
goto fail_ck;
if (result)
goto fail_table;

cpufreq_frequency_table_get_attr(freq_table, policy->cpu);

policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;
Expand All @@ -199,13 +208,16 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)

return 0;

fail_table:
freq_table_free();
fail_ck:
clk_put(mpu_clk);
return result;
}

static int omap_cpu_exit(struct cpufreq_policy *policy)
{
freq_table_free();
clk_put(mpu_clk);
return 0;
}
Expand Down

0 comments on commit a1847e9

Please sign in to comment.