Skip to content

Commit

Permalink
ARM: OMAP1: Add checks for possible error condition in timer_init
Browse files Browse the repository at this point in the history
On OMAP1, omap_32k_timer_init() function always returns "true",
irrespective of whether error occurred while initializing 32k sync
counter as a kernel clocksource or not and execution will never
fallback to mpu_timer clocksource init code.

This patch adds check for return value from function
omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
in case of failure/error from omap_init_clocksource_32k().

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Vaibhav Hiremath authored and Tony Lindgren committed May 9, 2012
1 parent bfd1787 commit 1879991
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
9 changes: 8 additions & 1 deletion arch/arm/mach-omap1/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ void omap1_init_irq(void);
void omap1_restart(char, const char *);

extern struct sys_timer omap1_timer;
extern bool omap_32k_timer_init(void);
#ifdef CONFIG_OMAP_32K_TIMER
extern int omap_32k_timer_init(void);
#else
static inline int __init omap_32k_timer_init(void)
{
return -ENODEV;
}
#endif
extern void __init omap_init_consistent_dma_size(void);

#endif /* __ARCH_ARM_MACH_OMAP1_COMMON_H */
16 changes: 1 addition & 15 deletions arch/arm/mach-omap1/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,28 +232,14 @@ static inline void omap_mpu_timer_init(void)
}
#endif /* CONFIG_OMAP_MPU_TIMER */

static inline int omap_32k_timer_usable(void)
{
int res = false;

if (cpu_is_omap730() || cpu_is_omap15xx())
return res;

#ifdef CONFIG_OMAP_32K_TIMER
res = omap_32k_timer_init();
#endif

return res;
}

/*
* ---------------------------------------------------------------------------
* Timer initialization
* ---------------------------------------------------------------------------
*/
static void __init omap1_timer_init(void)
{
if (!omap_32k_timer_usable())
if (omap_32k_timer_init() != 0)
omap_mpu_timer_init();
}

Expand Down
13 changes: 9 additions & 4 deletions arch/arm/mach-omap1/timer32k.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,15 @@ static __init void omap_init_32k_timer(void)
* Timer initialization
* ---------------------------------------------------------------------------
*/
bool __init omap_32k_timer_init(void)
int __init omap_32k_timer_init(void)
{
omap_init_clocksource_32k();
omap_init_32k_timer();
int ret = -ENODEV;

return true;
if (cpu_is_omap16xx())
ret = omap_init_clocksource_32k();

if (!ret)
omap_init_32k_timer();

return ret;
}

0 comments on commit 1879991

Please sign in to comment.