diff options
author | Paul Walmsley <paul@pwsan.com> | 2009-01-27 21:12:50 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-02-08 12:50:24 -0500 |
commit | fecb494beef09e4caaa80313834af26f57091195 (patch) | |
tree | 4fc6d90c615a3e408f32c69916fcf5e7712f9d9a /arch/arm/mach-omap2 | |
parent | 16c90f020034d3cd38b3dab280001e728e6b19e5 (diff) |
[ARM] OMAP: Fix sparse, checkpatch warnings in OMAP2/3 PRCM/PM code
Fix sparse & checkpatch warnings in OMAP2/3 PRCM & PM code. This mostly
consists of:
- converting pointer comparisons to integers in form similar to
(ptr == 0) to the standard idiom (!ptr)
- labeling a few non-static private functions as static
- adding prototypes for *_init() functions in the appropriate header
files, and getting rid of the corresponding open-coded extern
prototypes in other C files
- renaming the variable 'sclk' in mach-omap2/clock.c:omap2_get_apll_clkin
to avoid shadowing an earlier declaration
Clean up checkpatch issues. This mostly involves:
- converting some asm/ includes to linux/ includes
- cleaning up some whitespace
- getting rid of braces for conditionals with single following statements
Also take care of a few odds and ends, including:
- getting rid of unlikely() and likely() - none of this code is particularly
fast-path code, so the performance impact seems slim; and some of those
likely() and unlikely() indicators are probably not as accurate as the
ARM's branch predictor
- removing some superfluous casts
linux-omap source commit is 347df59f5d20fdf905afbc26b1328b0e28a8a01b.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 51 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock24xx.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm.c | 2 |
4 files changed, 36 insertions, 35 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 53fda9977d55..886f73f3933a 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include <mach/clock.h> | 27 | #include <mach/clock.h> |
28 | #include <mach/clockdomain.h> | 28 | #include <mach/clockdomain.h> |
29 | #include <mach/sram.h> | ||
30 | #include <mach/cpu.h> | 29 | #include <mach/cpu.h> |
31 | #include <asm/div64.h> | 30 | #include <asm/div64.h> |
32 | 31 | ||
@@ -187,11 +186,10 @@ int omap2_wait_clock_ready(void __iomem *reg, u32 mask, const char *name) | |||
187 | * 24xx uses 0 to indicate not ready, and 1 to indicate ready. | 186 | * 24xx uses 0 to indicate not ready, and 1 to indicate ready. |
188 | * 34xx reverses this, just to keep us on our toes | 187 | * 34xx reverses this, just to keep us on our toes |
189 | */ | 188 | */ |
190 | if (cpu_mask & (RATE_IN_242X | RATE_IN_243X)) { | 189 | if (cpu_mask & (RATE_IN_242X | RATE_IN_243X)) |
191 | ena = mask; | 190 | ena = mask; |
192 | } else if (cpu_mask & RATE_IN_343X) { | 191 | else if (cpu_mask & RATE_IN_343X) |
193 | ena = 0; | 192 | ena = 0; |
194 | } | ||
195 | 193 | ||
196 | /* Wait for lock */ | 194 | /* Wait for lock */ |
197 | while (((__raw_readl(reg) & mask) != ena) && | 195 | while (((__raw_readl(reg) & mask) != ena) && |
@@ -267,7 +265,7 @@ static int omap2_dflt_clk_enable_wait(struct clk *clk) | |||
267 | { | 265 | { |
268 | int ret; | 266 | int ret; |
269 | 267 | ||
270 | if (unlikely(clk->enable_reg == NULL)) { | 268 | if (!clk->enable_reg) { |
271 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", | 269 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", |
272 | clk->name); | 270 | clk->name); |
273 | return 0; /* REVISIT: -EINVAL */ | 271 | return 0; /* REVISIT: -EINVAL */ |
@@ -283,7 +281,7 @@ static void omap2_dflt_clk_disable(struct clk *clk) | |||
283 | { | 281 | { |
284 | u32 regval32; | 282 | u32 regval32; |
285 | 283 | ||
286 | if (clk->enable_reg == NULL) { | 284 | if (!clk->enable_reg) { |
287 | /* | 285 | /* |
288 | * 'Independent' here refers to a clock which is not | 286 | * 'Independent' here refers to a clock which is not |
289 | * controlled by its parent. | 287 | * controlled by its parent. |
@@ -330,7 +328,7 @@ void omap2_clk_disable(struct clk *clk) | |||
330 | { | 328 | { |
331 | if (clk->usecount > 0 && !(--clk->usecount)) { | 329 | if (clk->usecount > 0 && !(--clk->usecount)) { |
332 | _omap2_clk_disable(clk); | 330 | _omap2_clk_disable(clk); |
333 | if (likely((u32)clk->parent)) | 331 | if (clk->parent) |
334 | omap2_clk_disable(clk->parent); | 332 | omap2_clk_disable(clk->parent); |
335 | if (clk->clkdm) | 333 | if (clk->clkdm) |
336 | omap2_clkdm_clk_disable(clk->clkdm, clk); | 334 | omap2_clkdm_clk_disable(clk->clkdm, clk); |
@@ -343,10 +341,10 @@ int omap2_clk_enable(struct clk *clk) | |||
343 | int ret = 0; | 341 | int ret = 0; |
344 | 342 | ||
345 | if (clk->usecount++ == 0) { | 343 | if (clk->usecount++ == 0) { |
346 | if (likely((u32)clk->parent)) | 344 | if (clk->parent) |
347 | ret = omap2_clk_enable(clk->parent); | 345 | ret = omap2_clk_enable(clk->parent); |
348 | 346 | ||
349 | if (unlikely(ret != 0)) { | 347 | if (ret != 0) { |
350 | clk->usecount--; | 348 | clk->usecount--; |
351 | return ret; | 349 | return ret; |
352 | } | 350 | } |
@@ -356,7 +354,7 @@ int omap2_clk_enable(struct clk *clk) | |||
356 | 354 | ||
357 | ret = _omap2_clk_enable(clk); | 355 | ret = _omap2_clk_enable(clk); |
358 | 356 | ||
359 | if (unlikely(ret != 0)) { | 357 | if (ret != 0) { |
360 | if (clk->clkdm) | 358 | if (clk->clkdm) |
361 | omap2_clkdm_clk_disable(clk->clkdm, clk); | 359 | omap2_clkdm_clk_disable(clk->clkdm, clk); |
362 | 360 | ||
@@ -384,7 +382,7 @@ void omap2_clksel_recalc(struct clk *clk) | |||
384 | if (div == 0) | 382 | if (div == 0) |
385 | return; | 383 | return; |
386 | 384 | ||
387 | if (unlikely(clk->rate == clk->parent->rate / div)) | 385 | if (clk->rate == (clk->parent->rate / div)) |
388 | return; | 386 | return; |
389 | clk->rate = clk->parent->rate / div; | 387 | clk->rate = clk->parent->rate / div; |
390 | 388 | ||
@@ -400,8 +398,8 @@ void omap2_clksel_recalc(struct clk *clk) | |||
400 | * the element associated with the supplied parent clock address. | 398 | * the element associated with the supplied parent clock address. |
401 | * Returns a pointer to the struct clksel on success or NULL on error. | 399 | * Returns a pointer to the struct clksel on success or NULL on error. |
402 | */ | 400 | */ |
403 | const struct clksel *omap2_get_clksel_by_parent(struct clk *clk, | 401 | static const struct clksel *omap2_get_clksel_by_parent(struct clk *clk, |
404 | struct clk *src_clk) | 402 | struct clk *src_clk) |
405 | { | 403 | { |
406 | const struct clksel *clks; | 404 | const struct clksel *clks; |
407 | 405 | ||
@@ -450,7 +448,7 @@ u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | |||
450 | *new_div = 1; | 448 | *new_div = 1; |
451 | 449 | ||
452 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 450 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
453 | if (clks == NULL) | 451 | if (!clks) |
454 | return ~0; | 452 | return ~0; |
455 | 453 | ||
456 | for (clkr = clks->rates; clkr->div; clkr++) { | 454 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -509,7 +507,7 @@ long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate) | |||
509 | /* Given a clock and a rate apply a clock specific rounding function */ | 507 | /* Given a clock and a rate apply a clock specific rounding function */ |
510 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate) | 508 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate) |
511 | { | 509 | { |
512 | if (clk->round_rate != NULL) | 510 | if (clk->round_rate) |
513 | return clk->round_rate(clk, rate); | 511 | return clk->round_rate(clk, rate); |
514 | 512 | ||
515 | if (clk->flags & RATE_FIXED) | 513 | if (clk->flags & RATE_FIXED) |
@@ -535,7 +533,7 @@ u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val) | |||
535 | const struct clksel_rate *clkr; | 533 | const struct clksel_rate *clkr; |
536 | 534 | ||
537 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 535 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
538 | if (clks == NULL) | 536 | if (!clks) |
539 | return 0; | 537 | return 0; |
540 | 538 | ||
541 | for (clkr = clks->rates; clkr->div; clkr++) { | 539 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -571,7 +569,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) | |||
571 | WARN_ON(div == 0); | 569 | WARN_ON(div == 0); |
572 | 570 | ||
573 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 571 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
574 | if (clks == NULL) | 572 | if (!clks) |
575 | return 0; | 573 | return 0; |
576 | 574 | ||
577 | for (clkr = clks->rates; clkr->div; clkr++) { | 575 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -596,9 +594,9 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) | |||
596 | * | 594 | * |
597 | * Returns the address of the clksel register upon success or NULL on error. | 595 | * Returns the address of the clksel register upon success or NULL on error. |
598 | */ | 596 | */ |
599 | void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask) | 597 | static void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask) |
600 | { | 598 | { |
601 | if (unlikely((clk->clksel_reg == NULL) || (clk->clksel_mask == NULL))) | 599 | if (!clk->clksel_reg || (clk->clksel_mask == 0)) |
602 | return NULL; | 600 | return NULL; |
603 | 601 | ||
604 | *field_mask = clk->clksel_mask; | 602 | *field_mask = clk->clksel_mask; |
@@ -618,7 +616,7 @@ u32 omap2_clksel_get_divisor(struct clk *clk) | |||
618 | void __iomem *div_addr; | 616 | void __iomem *div_addr; |
619 | 617 | ||
620 | div_addr = omap2_get_clksel(clk, &field_mask); | 618 | div_addr = omap2_get_clksel(clk, &field_mask); |
621 | if (div_addr == NULL) | 619 | if (!div_addr) |
622 | return 0; | 620 | return 0; |
623 | 621 | ||
624 | field_val = __raw_readl(div_addr) & field_mask; | 622 | field_val = __raw_readl(div_addr) & field_mask; |
@@ -637,7 +635,7 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) | |||
637 | return -EINVAL; | 635 | return -EINVAL; |
638 | 636 | ||
639 | div_addr = omap2_get_clksel(clk, &field_mask); | 637 | div_addr = omap2_get_clksel(clk, &field_mask); |
640 | if (div_addr == NULL) | 638 | if (!div_addr) |
641 | return -EINVAL; | 639 | return -EINVAL; |
642 | 640 | ||
643 | field_val = omap2_divisor_to_clksel(clk, new_div); | 641 | field_val = omap2_divisor_to_clksel(clk, new_div); |
@@ -675,7 +673,7 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate) | |||
675 | return -EINVAL; | 673 | return -EINVAL; |
676 | 674 | ||
677 | /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */ | 675 | /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */ |
678 | if (clk->set_rate != NULL) | 676 | if (clk->set_rate) |
679 | ret = clk->set_rate(clk, rate); | 677 | ret = clk->set_rate(clk, rate); |
680 | 678 | ||
681 | return ret; | 679 | return ret; |
@@ -696,7 +694,7 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr, | |||
696 | *src_addr = NULL; | 694 | *src_addr = NULL; |
697 | 695 | ||
698 | clks = omap2_get_clksel_by_parent(clk, src_clk); | 696 | clks = omap2_get_clksel_by_parent(clk, src_clk); |
699 | if (clks == NULL) | 697 | if (!clks) |
700 | return 0; | 698 | return 0; |
701 | 699 | ||
702 | for (clkr = clks->rates; clkr->div; clkr++) { | 700 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -726,7 +724,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) | |||
726 | void __iomem *src_addr; | 724 | void __iomem *src_addr; |
727 | u32 field_val, field_mask, reg_val, parent_div; | 725 | u32 field_val, field_mask, reg_val, parent_div; |
728 | 726 | ||
729 | if (unlikely(clk->flags & CONFIG_PARTICIPANT)) | 727 | if (clk->flags & CONFIG_PARTICIPANT) |
730 | return -EINVAL; | 728 | return -EINVAL; |
731 | 729 | ||
732 | if (!clk->clksel) | 730 | if (!clk->clksel) |
@@ -734,7 +732,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) | |||
734 | 732 | ||
735 | field_val = omap2_clksel_get_src_field(&src_addr, new_parent, | 733 | field_val = omap2_clksel_get_src_field(&src_addr, new_parent, |
736 | &field_mask, clk, &parent_div); | 734 | &field_mask, clk, &parent_div); |
737 | if (src_addr == NULL) | 735 | if (!src_addr) |
738 | return -EINVAL; | 736 | return -EINVAL; |
739 | 737 | ||
740 | if (clk->usecount > 0) | 738 | if (clk->usecount > 0) |
@@ -794,7 +792,8 @@ int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance) | |||
794 | return 0; | 792 | return 0; |
795 | } | 793 | } |
796 | 794 | ||
797 | static unsigned long _dpll_compute_new_rate(unsigned long parent_rate, unsigned int m, unsigned int n) | 795 | static unsigned long _dpll_compute_new_rate(unsigned long parent_rate, |
796 | unsigned int m, unsigned int n) | ||
798 | { | 797 | { |
799 | unsigned long long num; | 798 | unsigned long long num; |
800 | 799 | ||
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index b0358b659b43..90077f0df78d 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h | |||
@@ -27,7 +27,7 @@ void omap2_clk_disable(struct clk *clk); | |||
27 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); | 27 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); |
28 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); | 28 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); |
29 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); | 29 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); |
30 | int omap2_dpll_rate_tolerance_set(struct clk *clk, unsigned int tolerance); | 30 | int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance); |
31 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); | 31 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); |
32 | 32 | ||
33 | #ifdef CONFIG_OMAP_RESET_CLOCKS | 33 | #ifdef CONFIG_OMAP_RESET_CLOCKS |
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c index bd77ef2d5ae9..91ad2070264d 100644 --- a/arch/arm/mach-omap2/clock24xx.c +++ b/arch/arm/mach-omap2/clock24xx.c | |||
@@ -339,7 +339,7 @@ static const struct clkops clkops_fixed = { | |||
339 | * Uses the current prcm set to tell if a rate is valid. | 339 | * Uses the current prcm set to tell if a rate is valid. |
340 | * You can go slower, but not faster within a given rate set. | 340 | * You can go slower, but not faster within a given rate set. |
341 | */ | 341 | */ |
342 | long omap2_dpllcore_round_rate(unsigned long target_rate) | 342 | static long omap2_dpllcore_round_rate(unsigned long target_rate) |
343 | { | 343 | { |
344 | u32 high, low, core_clk_src; | 344 | u32 high, low, core_clk_src; |
345 | 345 | ||
@@ -550,7 +550,9 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate) | |||
550 | 550 | ||
551 | /* Major subsystem dividers */ | 551 | /* Major subsystem dividers */ |
552 | tmp = cm_read_mod_reg(CORE_MOD, CM_CLKSEL1) & OMAP24XX_CLKSEL_DSS2_MASK; | 552 | tmp = cm_read_mod_reg(CORE_MOD, CM_CLKSEL1) & OMAP24XX_CLKSEL_DSS2_MASK; |
553 | cm_write_mod_reg(prcm->cm_clksel1_core | tmp, CORE_MOD, CM_CLKSEL1); | 553 | cm_write_mod_reg(prcm->cm_clksel1_core | tmp, CORE_MOD, |
554 | CM_CLKSEL1); | ||
555 | |||
554 | if (cpu_is_omap2430()) | 556 | if (cpu_is_omap2430()) |
555 | cm_write_mod_reg(prcm->cm_clksel_mdm, | 557 | cm_write_mod_reg(prcm->cm_clksel_mdm, |
556 | OMAP2430_MDM_MOD, CM_CLKSEL); | 558 | OMAP2430_MDM_MOD, CM_CLKSEL); |
@@ -582,20 +584,20 @@ static struct clk_functions omap2_clk_functions = { | |||
582 | 584 | ||
583 | static u32 omap2_get_apll_clkin(void) | 585 | static u32 omap2_get_apll_clkin(void) |
584 | { | 586 | { |
585 | u32 aplls, sclk = 0; | 587 | u32 aplls, srate = 0; |
586 | 588 | ||
587 | aplls = cm_read_mod_reg(PLL_MOD, CM_CLKSEL1); | 589 | aplls = cm_read_mod_reg(PLL_MOD, CM_CLKSEL1); |
588 | aplls &= OMAP24XX_APLLS_CLKIN_MASK; | 590 | aplls &= OMAP24XX_APLLS_CLKIN_MASK; |
589 | aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT; | 591 | aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT; |
590 | 592 | ||
591 | if (aplls == APLLS_CLKIN_19_2MHZ) | 593 | if (aplls == APLLS_CLKIN_19_2MHZ) |
592 | sclk = 19200000; | 594 | srate = 19200000; |
593 | else if (aplls == APLLS_CLKIN_13MHZ) | 595 | else if (aplls == APLLS_CLKIN_13MHZ) |
594 | sclk = 13000000; | 596 | srate = 13000000; |
595 | else if (aplls == APLLS_CLKIN_12MHZ) | 597 | else if (aplls == APLLS_CLKIN_12MHZ) |
596 | sclk = 12000000; | 598 | srate = 12000000; |
597 | 599 | ||
598 | return sclk; | 600 | return srate; |
599 | } | 601 | } |
600 | 602 | ||
601 | static u32 omap2_get_sysclkdiv(void) | 603 | static u32 omap2_get_sysclkdiv(void) |
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 55361c16c9d9..ea8ceaed09cb 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c | |||
@@ -103,7 +103,7 @@ static struct platform_suspend_ops omap_pm_ops = { | |||
103 | .valid = suspend_valid_only_mem, | 103 | .valid = suspend_valid_only_mem, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | int __init omap2_pm_init(void) | 106 | static int __init omap2_pm_init(void) |
107 | { | 107 | { |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |