diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2015-09-28 16:32:38 +0100 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2015-09-28 16:33:00 +0100 |
commit | 543128771c59e9f1ee91c245d342e929d5ba7fa1 (patch) | |
tree | 5081b28baa8a20741e433b842656312028b79da2 /include | |
parent | 7dc28e9c6e577c5151d0a6df7165f7d21f509f5f (diff) |
Bug fix in the SP804 dual timer driver
The generic delay timer driver expects a pointer to a timer_ops_t
structure containing the specific timer driver information. It
doesn't make a copy of the structure, instead it just keeps the
pointer. Therefore, this pointer must remain valid over time.
The SP804 driver doesn't satisfy this requirement. The
sp804_timer_init() macro creates a temporary instanciation of the
timer_ops_t structure on the fly and passes it to the generic
delay timer. When this temporary instanciation gets deallocated,
the generic delay timer is left with a pointer to invalid data.
This patch fixes this bug by statically allocating the SP804
timer_ops_t structure.
Change-Id: I8fbf75907583aef06701e3fd9fabe0b2c9bc95bf
Diffstat (limited to 'include')
-rw-r--r-- | include/drivers/arm/sp804_delay_timer.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/drivers/arm/sp804_delay_timer.h b/include/drivers/arm/sp804_delay_timer.h index 5a335716..1531e5a1 100644 --- a/include/drivers/arm/sp804_delay_timer.h +++ b/include/drivers/arm/sp804_delay_timer.h @@ -40,8 +40,13 @@ uint32_t sp804_get_timer_value(void); void sp804_timer_ops_init(uintptr_t base_addr, const timer_ops_t *ops); #define sp804_timer_init(base_addr, clk_mult, clk_div) \ - sp804_timer_ops_init((base_addr), &(const timer_ops_t) \ - { sp804_get_timer_value, (clk_mult), (clk_div) }) - + do { \ + static const timer_ops_t sp804_timer_ops = { \ + sp804_get_timer_value, \ + (clk_mult), \ + (clk_div) \ + }; \ + sp804_timer_ops_init((base_addr), &sp804_timer_ops); \ + } while (0) #endif /* __SP804_DELAY_TIMER_H__ */ |