diff options
author | Julia Lawall <julia@diku.dk> | 2011-06-06 21:59:02 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2011-07-13 18:29:54 -0400 |
commit | 4911ca1031c2ade225fdf22cc872bc121c2c2ec5 (patch) | |
tree | f3e949229f7b1c112cd1c70cd3ebeb18df138ef4 /drivers/cpufreq/s5pv210-cpufreq.c | |
parent | 15964d388528c1dbb672027c8003fe7e81630a35 (diff) |
[CPUFREQ] s5pv210-cpufreq.c: Add missing clk_put
The successive calls to clk_get each call clk_put in the case of failure,
but this is not done for subsequent error handling code. The calls to
clk_get are moved to the end of the function, and appropriate gotos are
added.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
expression e1,e2;
statement S;
@@
e1 = clk_get@p1(...);
... when != e1 = e2
when != clk_put(e1)
when any
if (...) { ... when != clk_put(e1)
when != if (...) { ... clk_put(e1) ... }
* return@p3 ...;
} else S
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq/s5pv210-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/s5pv210-cpufreq.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index ea35d3f74e3d..a7cb3385bf5e 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c | |||
@@ -415,6 +415,7 @@ static int check_mem_type(void __iomem *dmc_reg) | |||
415 | static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) | 415 | static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) |
416 | { | 416 | { |
417 | unsigned long mem_type; | 417 | unsigned long mem_type; |
418 | int ret; | ||
418 | 419 | ||
419 | cpu_clk = clk_get(NULL, "armclk"); | 420 | cpu_clk = clk_get(NULL, "armclk"); |
420 | if (IS_ERR(cpu_clk)) | 421 | if (IS_ERR(cpu_clk)) |
@@ -422,19 +423,20 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) | |||
422 | 423 | ||
423 | dmc0_clk = clk_get(NULL, "sclk_dmc0"); | 424 | dmc0_clk = clk_get(NULL, "sclk_dmc0"); |
424 | if (IS_ERR(dmc0_clk)) { | 425 | if (IS_ERR(dmc0_clk)) { |
425 | clk_put(cpu_clk); | 426 | ret = PTR_ERR(dmc0_clk); |
426 | return PTR_ERR(dmc0_clk); | 427 | goto out_dmc0; |
427 | } | 428 | } |
428 | 429 | ||
429 | dmc1_clk = clk_get(NULL, "hclk_msys"); | 430 | dmc1_clk = clk_get(NULL, "hclk_msys"); |
430 | if (IS_ERR(dmc1_clk)) { | 431 | if (IS_ERR(dmc1_clk)) { |
431 | clk_put(dmc0_clk); | 432 | ret = PTR_ERR(dmc1_clk); |
432 | clk_put(cpu_clk); | 433 | goto out_dmc1; |
433 | return PTR_ERR(dmc1_clk); | ||
434 | } | 434 | } |
435 | 435 | ||
436 | if (policy->cpu != 0) | 436 | if (policy->cpu != 0) { |
437 | return -EINVAL; | 437 | ret = -EINVAL; |
438 | goto out_dmc1; | ||
439 | } | ||
438 | 440 | ||
439 | /* | 441 | /* |
440 | * check_mem_type : This driver only support LPDDR & LPDDR2. | 442 | * check_mem_type : This driver only support LPDDR & LPDDR2. |
@@ -444,7 +446,8 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) | |||
444 | 446 | ||
445 | if ((mem_type != LPDDR) && (mem_type != LPDDR2)) { | 447 | if ((mem_type != LPDDR) && (mem_type != LPDDR2)) { |
446 | printk(KERN_ERR "CPUFreq doesn't support this memory type\n"); | 448 | printk(KERN_ERR "CPUFreq doesn't support this memory type\n"); |
447 | return -EINVAL; | 449 | ret = -EINVAL; |
450 | goto out_dmc1; | ||
448 | } | 451 | } |
449 | 452 | ||
450 | /* Find current refresh counter and frequency each DMC */ | 453 | /* Find current refresh counter and frequency each DMC */ |
@@ -461,6 +464,12 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) | |||
461 | policy->cpuinfo.transition_latency = 40000; | 464 | policy->cpuinfo.transition_latency = 40000; |
462 | 465 | ||
463 | return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table); | 466 | return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table); |
467 | |||
468 | out_dmc1: | ||
469 | clk_put(dmc0_clk); | ||
470 | out_dmc0: | ||
471 | clk_put(cpu_clk); | ||
472 | return ret; | ||
464 | } | 473 | } |
465 | 474 | ||
466 | static struct cpufreq_driver s5pv210_driver = { | 475 | static struct cpufreq_driver s5pv210_driver = { |