diff mbox

[V2,3/7] ARM: OMAP2+: Remove hard-coded test on timer ID

Message ID 1359999786-8740-4-git-send-email-jon-hunter@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hunter, Jon Feb. 4, 2013, 5:43 p.m. UTC
Currently, when configuring the clock-events and clock-source timers
for OMAP2+ devices, we check whether the timer ID is 12 before
attempting to set the parent clock for the timer.

This test was added for OMAP3 general purpose devices (no security
features enabled) that a 12th timer available but unlike the other
timers only has a single functional clock source. Calling
clk_set_parent() for this 12th timer would always return an error
because there is only one choice for a parent clock. Therefore,
this hard-coded timer ID test was added.

To avoid this timer ID test, simply check to see if the timer's current
parent clock is the desired parent clock and only call clk_set_parent()
if this is not the case.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/mach-omap2/timer.c |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

Russell King - ARM Linux Feb. 4, 2013, 5:46 p.m. UTC | #1
On Mon, Feb 04, 2013 at 11:43:02AM -0600, Jon Hunter wrote:
> @@ -280,22 +281,22 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
>  	if (IS_ERR(timer->fclk))
>  		return -ENODEV;
>  
> -	/* FIXME: Need to remove hard-coded test on timer ID */
> -	if (gptimer_id != 12) {
> -		struct clk *src;
> -
> -		src = clk_get(NULL, fck_source);
> -		if (IS_ERR(src)) {
> -			r = -EINVAL;
> -		} else {
> -			r = clk_set_parent(timer->fclk, src);
> -			if (IS_ERR_VALUE(r))
> -				pr_warn("%s: %s cannot set source\n",
> -					__func__, oh->name);
> +	src = clk_get(NULL, fck_source);
> +	if (IS_ERR(src))
> +		return -EINVAL;

This should be:
		return PTR_ERR(src);

and should've been there previously...
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hunter, Jon Feb. 4, 2013, 6:01 p.m. UTC | #2
On 02/04/2013 11:46 AM, Russell King - ARM Linux wrote:
> On Mon, Feb 04, 2013 at 11:43:02AM -0600, Jon Hunter wrote:
>> @@ -280,22 +281,22 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
>>  	if (IS_ERR(timer->fclk))
>>  		return -ENODEV;
>>  
>> -	/* FIXME: Need to remove hard-coded test on timer ID */
>> -	if (gptimer_id != 12) {
>> -		struct clk *src;
>> -
>> -		src = clk_get(NULL, fck_source);
>> -		if (IS_ERR(src)) {
>> -			r = -EINVAL;
>> -		} else {
>> -			r = clk_set_parent(timer->fclk, src);
>> -			if (IS_ERR_VALUE(r))
>> -				pr_warn("%s: %s cannot set source\n",
>> -					__func__, oh->name);
>> +	src = clk_get(NULL, fck_source);
>> +	if (IS_ERR(src))
>> +		return -EINVAL;
> 
> This should be:
> 		return PTR_ERR(src);
> 
> and should've been there previously...

Thanks for the catch. I will include this and resend.

Cheers
Jon

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 83118fb..ec2fb80 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -224,6 +224,7 @@  static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
 	struct device_node *np;
 	struct omap_hwmod *oh;
 	struct resource irq, mem;
+	struct clk *src;
 	int r = 0;
 
 	if (of_have_populated_dt()) {
@@ -280,22 +281,22 @@  static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
 	if (IS_ERR(timer->fclk))
 		return -ENODEV;
 
-	/* FIXME: Need to remove hard-coded test on timer ID */
-	if (gptimer_id != 12) {
-		struct clk *src;
-
-		src = clk_get(NULL, fck_source);
-		if (IS_ERR(src)) {
-			r = -EINVAL;
-		} else {
-			r = clk_set_parent(timer->fclk, src);
-			if (IS_ERR_VALUE(r))
-				pr_warn("%s: %s cannot set source\n",
-					__func__, oh->name);
+	src = clk_get(NULL, fck_source);
+	if (IS_ERR(src))
+		return -EINVAL;
+
+	if (clk_get_parent(timer->fclk) != src) {
+		r = clk_set_parent(timer->fclk, src);
+		if (IS_ERR_VALUE(r)) {
+			pr_warn("%s: %s cannot set source\n", __func__,
+				oh->name);
 			clk_put(src);
+			return r;
 		}
 	}
 
+	clk_put(src);
+
 	omap_hwmod_setup_one(oh_name);
 	omap_hwmod_enable(oh);
 	__omap_dm_timer_init_regs(timer);