timer: replace timer_data

Replaces void pointer to timer_data with pointers to
timer handler and handler data. We had multiple definitions
of timer_data structure and they were all the same.
This way we can remove unnecessary static data.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2020-01-14 12:18:29 +01:00 committed by Liam Girdwood
parent 0ad546d73d
commit 925da68b63
3 changed files with 8 additions and 30 deletions

View File

@ -11,17 +11,9 @@
#include <errno.h>
#include <stdint.h>
struct timer_data {
void (*handler2)(void *arg);
void *arg2;
};
static struct timer_data xtimer[ARCH_TIMER_COUNT];
void timer_64_handler(void *arg)
{
struct timer *timer = arg;
struct timer_data *tdata = timer->timer_data;
uint32_t ccompare;
if (timer->id >= ARCH_TIMER_COUNT)
@ -37,7 +29,7 @@ void timer_64_handler(void *arg)
arch_timer_clear(timer);
} else {
/* no roll over, run the handler */
tdata->handler2(tdata->arg2);
timer->handler(timer->data);
}
/* get next timeout value */
@ -54,16 +46,11 @@ void timer_64_handler(void *arg)
int timer64_register(struct timer *timer, void(*handler)(void *arg), void *arg)
{
struct timer_data *tdata;
if (timer->id >= ARCH_TIMER_COUNT)
return -EINVAL;
tdata = &xtimer[timer->id];
tdata->handler2 = handler;
tdata->arg2 = arg;
timer->timer_data = tdata;
timer->handler = handler;
timer->data = arg;
timer->hitime = 0;
timer->hitimeout = 0;
return 0;

View File

@ -20,7 +20,8 @@ struct timer {
int irq;
int logical_irq; /* used for external timers */
const char *irq_name;
void *timer_data; /* used by core */
void (*handler)(void *data); /* optional timer handler */
void *data; /* optional timer handler's data */
uint32_t hitime; /* high end of 64bit timer */
uint32_t hitimeout;
uint32_t lowtimeout;

View File

@ -18,17 +18,9 @@
#include <errno.h>
#include <stdint.h>
struct timer_data {
void (*handler2)(void *arg);
void *arg2;
};
static struct timer_data xtimer[1] = {};
static void platform_timer_64_handler(void *arg)
{
struct timer *timer = arg;
struct timer_data *tdata = timer->timer_data;
uint32_t timeout;
/* get timeout value - will tell us timeout reason */
@ -43,7 +35,7 @@ static void platform_timer_64_handler(void *arg)
timer->hitime++;
} else {
/* no roll over, run the handler */
tdata->handler2(tdata->arg2);
timer->handler(timer->data);
}
/* get next timeout value */
@ -183,14 +175,12 @@ void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock)
static int platform_timer_register(struct timer *timer,
void (*handler)(void *arg), void *arg)
{
struct timer_data *tdata = &xtimer[0];
uint32_t flags;
int ret;
flags = arch_interrupt_global_disable();
tdata->handler2 = handler;
tdata->arg2 = arg;
timer->timer_data = tdata;
timer->handler = handler;
timer->data = arg;
timer->hitime = 0;
timer->hitimeout = 0;
ret = arch_interrupt_register(timer->irq,