AVR32: fix timer_init() function
PATCH 1/1 AVR32: fix timer_init() function
timer_init() now returns an int (the error code) instead of void. This makes compilation fail with:
interrupts.c:111: error: conflicting types for 'timer_init' /home/svens/u-boot/u-boot/include/common.h:246: error: previous declaration of 'timer_init' was here make[1]: *** [interrupts.o] Error 1
--- arch/avr32/cpu/interrupts.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/avr32/cpu/interrupts.c +5 -3
@@ -107,10 +107,11 @@ static int set_interrupt_handler(unsigned int nr, void (*handler)(void),return 0 ; } -void timer_init (void ) +int timer_init (void ) {extern void timer_interrupt_handler (void );u64 tmp; +int ret;sysreg_write (COUNT ,0 );
@@ -119,9 +120,10 @@ void timer_init(void)do_div (tmp, gd->cpu_hz); tb_factor = (u32 )tmp; -if (set_interrupt_handler (0 , &timer_interrupt_handler,3 )) -return ; +if ((ret =set_interrupt_handler (0 , &timer_interrupt_handler,3 ))) +return ret;/* For all practical purposes, this gives us an overflow interrupt */ sysreg_write (COMPARE ,0xffffffff ); +return 0 ; }
Signature · 1 line
1.7.6.3
PATCH 1/1 AVR32: fix timer_init() function
Dear Sven,
Am 04.10.2011 um 11:20 schrieb Sven Schnelle:
<snip>
arch/avr32/cpu/interrupts.c void timer_init(void) · line 124
Quoted 4 lines
arch/avr32/cpu/interrupts.c +2
-2-if (set_interrupt_handler (0 , &timer_interrupt_handler,3 )) -return ; +if ((ret =set_interrupt_handler (0 , &timer_interrupt_handler,3 ))) +return ret;
can you do it like this:
ret = set_interrupt_handler();
if (ret)
return ret;
best regards
Andreas Bie?mann
PATCH 1/1 AVR32: fix timer_init() function
Quoted 9 lines · Andreas Bie?mann
Review
Quoted 4 lines
(quoted diff) +2
-2- if (set_interrupt_handler(0, &timer_interrupt_handler, 3)) - return; + if ((ret = set_interrupt_handler(0, &timer_interrupt_handler, 3))) + return ret;can you do it like this:
ret =
set_interrupt_handler();
if (ret)return ret;
Sure, modified patch attached. Thanks!
Signature · 13 lines
AVR32: fix timer_init() function timer_init() now returns an int (the error code) instead of void. This makes compilation fail with: interrupts.c:111: error: conflicting types for 'timer_init' /home/svens/u-boot/u-boot/include/common.h:246: error: previous declaration of 'timer_init' was here make[1]: *** [interrupts.o] Error 1 Signed-off-by: Sven Schnelle <[email protected]> --- arch/avr32/cpu/interrupts.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
arch/avr32/cpu/interrupts.c +6 -3
@@ -107,10 +107,11 @@ static int set_interrupt_handler(unsigned int nr, void (*handler)(void),return 0 ; } -void timer_init (void ) +int timer_init (void ) {extern void timer_interrupt_handler (void );u64 tmp; +int ret;sysreg_write (COUNT ,0 );
@@ -119,9 +120,11 @@ void timer_init(void)do_div (tmp, gd->cpu_hz); tb_factor = (u32 )tmp; -if (set_interrupt_handler (0 , &timer_interrupt_handler,3 )) -return ; + ret =set_interrupt_handler (0 , &timer_interrupt_handler,3 ); +if (ret) +return ret;/* For all practical purposes, this gives us an overflow interrupt */ sysreg_write (COMPARE ,0xffffffff ); +return 0 ; }
Signature · 1 line
1.7.6.3
PATCH 1/1 AVR32: fix timer_init() function
Dear Sven,
two things:
a) please read http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
b) my first hint wasn't that good ...
Am 04.10.2011 um 16:37 schrieb Sven Schnelle:
Quoted 47 lines
Quoted 9 lines · Andreas Bie?mann
arch/avr32/cpu/interrupts.c void timer_init(void) · line 125
Quoted 4 lines
arch/avr32/cpu/interrupts.c +2
-2-if (set_interrupt_handler (0 , &timer_interrupt_handler,3 )) -return ; +if ((ret =set_interrupt_handler (0 , &timer_interrupt_handler,3 ))) +return ret;can you do it like this:
ret =
set_interrupt_handler();
if (ret)return ret;Sure, modified patch attached. Thanks!
Signature · 13 lines
AVR32: fix timer_init() function timer_init() now returns an int (the error code) instead of void. This makes compilation fail with: interrupts.c:111: error: conflicting types for 'timer_init' /home/svens/u-boot/u-boot/include/common.h:246: error: previous declaration of 'timer_init' was here make[1]: *** [interrupts.o] Error 1 Signed-off-by: Sven Schnelle <[email protected]> --- arch/avr32/cpu/interrupts.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)arch/avr32/cpu/interrupts.c +2
-1@@ -107,10 +107,11 @@ static int set_interrupt_handler(unsigned int nr, void (*handler)(void),return 0 ; } -void timer_init (void ) +int timer_init (void ) {extern void timer_interrupt_handler (void );u64 tmp; +int ret;sysreg_write (COUNT ,0 );
arch/avr32/cpu/interrupts.c void timer_init(void) · line 125
Quoted 8 lines
arch/avr32/cpu/interrupts.c +3
-2@@ -119,9 +120,11 @@ void timer_init(void)do_div (tmp, gd->cpu_hz); tb_factor = (u32 )tmp; -if (set_interrupt_handler (0 , &timer_interrupt_handler,3 )) -return ; + ret =set_interrupt_handler (0 , &timer_interrupt_handler,3 ); +if (ret) +return ret;
Since set_interrupt_handler() does not return any useful information on error I think it is enough to return -EINVAL as set_interrupt_handler() does. If we do it that way we can omit the 'int ret' value completely.
best regards
Andreas Bie?mann