diff --git a/arch/arm/src/cxd56xx/cxd56_timer.c b/arch/arm/src/cxd56xx/cxd56_timer.c index fb2cecf221..7735acba99 100644 --- a/arch/arm/src/cxd56xx/cxd56_timer.c +++ b/arch/arm/src/cxd56xx/cxd56_timer.c @@ -35,10 +35,8 @@ #include #include #include -#include #include -#include #include #include #include @@ -93,13 +91,12 @@ struct cxd56_lowerhalf_s /* Private data */ - uint32_t base; /* Base address of the timer */ - tccb_t callback; /* Current user interrupt callback */ - void *arg; /* Argument passed to upper half callback */ - uint32_t timeout; /* The current timeout value (us) */ - uint32_t clkticks; /* actual clock ticks for current interval */ - bool started; /* The timer has been started */ - spinlock_t lock; /* Spinlock */ + uint32_t base; /* Base address of the timer */ + tccb_t callback; /* Current user interrupt callback */ + void *arg; /* Argument passed to upper half callback */ + uint32_t timeout; /* The current timeout value (us) */ + uint32_t clkticks; /* actual clock ticks for current interval */ + bool started; /* The timer has been started */ }; /**************************************************************************** @@ -433,8 +430,7 @@ static void cxd56_setcallback(struct timer_lowerhalf_s *lower, struct cxd56_lowerhalf_s *priv = (struct cxd56_lowerhalf_s *)lower; irqstate_t flags; - flags = spin_lock_irqsave(&priv->lock); - sched_lock(); + flags = enter_critical_section(); DEBUGASSERT(priv); tmrinfo("Entry: callback=%p\n", callback); @@ -444,8 +440,7 @@ static void cxd56_setcallback(struct timer_lowerhalf_s *lower, priv->callback = callback; priv->arg = arg; - spin_unlock_irqrestore(&priv->lock, flags); - sched_unlock(); + leave_critical_section(flags); } /**************************************************************************** @@ -564,7 +559,6 @@ void cxd56_timer_initialize(const char *devpath, int timer) } priv->ops = &g_tmrops; - spin_lock_init(&priv->lock); irq_attach(irq, cxd56_timer_interrupt, priv); diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_timer.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_timer.c index 8900ac0eb2..6331bda03e 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_timer.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_timer.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -92,7 +91,6 @@ struct lpc17_40_timer_s uint32_t pincfg; /* Output pin configuration */ uint32_t pclk; /* The frequency of the peripheral clock * that drives the timer module. */ - spinlock_t lock; /* Spinlock */ }; /**************************************************************************** @@ -156,7 +154,6 @@ static struct lpc17_40_timer_s g_pwm1dev = .base = LPC17_40_TMR1_BASE, .pincfg = GPIO_MAT0p1_2, .pclk = (0x1 << 12), - .lock = SP_UNLOCKED, }; #endif @@ -269,7 +266,7 @@ static int timer_timer(struct lpc17_40_timer_s *priv, irqstate_t flags; uint32_t regval; - flags = spin_lock_irqsave(&priv->lock); + flags = enter_critical_section(); putreg32(info->frequency, LPC17_40_TMR0_MR1); /* Set TIMER0 MR1 = number of counts */ putreg32(info->frequency, LPC17_40_TMR1_MR0); /* Set TIMER1 MR0 = number of counts */ @@ -277,7 +274,7 @@ static int timer_timer(struct lpc17_40_timer_s *priv, putreg32(1, LPC17_40_TMR0_TCR); /* Start timer0 */ putreg32(1, LPC17_40_TMR1_TCR); /* Start timer1 */ - spin_unlock_irqrestore(&priv->lock, flags); + leave_critical_section(flags); timer_dumpregs(priv, "After starting"); return OK; } @@ -364,7 +361,7 @@ static int timer_setup(struct pwm_lowerhalf_s *dev) irqstate_t flags; uint32_t regval; - flags = spin_lock_irqsave(&priv->lock); + flags = enter_critical_section(); /* Power on the timer peripherals */ @@ -426,7 +423,7 @@ static int timer_setup(struct pwm_lowerhalf_s *dev) /* lpc17_40_configgpio(GPIO_MAT0p1_2); */ - spin_unlock_irqrestore(&priv->lock, flags); + leave_critical_section(flags); pwm_dumpgpio(priv->pincfg, "TIMER setup"); return OK; } @@ -514,7 +511,7 @@ static int timer_stop(struct pwm_lowerhalf_s *dev) * to prevent any concurrent access to the reset register. */ - flags = spin_lock_irqsave(&priv->lock); + flags = enter_critical_section(); /* Disable further interrupts and stop the timer */ @@ -532,7 +529,7 @@ static int timer_stop(struct pwm_lowerhalf_s *dev) * into a state where timer_start() can be called. */ - spin_unlock_irqrestore(&priv->lock, flags); + leave_critical_section(flags); pwminfo("regaddr: %08x resetbit: %08x\n", regaddr, resetbit); timer_dumpregs(priv, "After stop"); diff --git a/arch/arm/src/lpc43xx/lpc43_timer.c b/arch/arm/src/lpc43xx/lpc43_timer.c index fa16bd2c75..aa93024801 100644 --- a/arch/arm/src/lpc43xx/lpc43_timer.c +++ b/arch/arm/src/lpc43xx/lpc43_timer.c @@ -34,10 +34,8 @@ #include #include #include -#include #include -#include #include #include @@ -80,15 +78,14 @@ struct lpc43_lowerhalf_s /* Private data */ - uint32_t base; /* Base address of the timer */ - tccb_t callback; /* Current user interrupt callback */ - void *arg; /* Argument passed to the callback function */ - uint32_t timeout; /* The current timeout value (us) */ - uint32_t adjustment; /* time lost due to clock resolution truncation (us) */ - uint32_t clkticks; /* actual clock ticks for current interval */ - bool started; /* The timer has been started */ - uint16_t tmrid; /* Timer id */ - spinlock_t lock; /* Spinlock */ + uint32_t base; /* Base address of the timer */ + tccb_t callback; /* Current user interrupt callback */ + void *arg; /* Argument passed to the callback function */ + uint32_t timeout; /* The current timeout value (us) */ + uint32_t adjustment; /* time lost due to clock resolution truncation (us) */ + uint32_t clkticks; /* actual clock ticks for current interval */ + bool started; /* The timer has been started */ + uint16_t tmrid; /* Timer id */ }; /**************************************************************************** @@ -635,8 +632,7 @@ static void lpc43_setcallback(struct timer_lowerhalf_s *lower, struct lpc43_lowerhalf_s *priv = (struct lpc43_lowerhalf_s *)lower; irqstate_t flags; - flags = spin_lock_irqsave(&priv->lock); - sched_lock(); + flags = enter_critical_section(); DEBUGASSERT(priv); tmrinfo("Entry: callback=%p\n", callback); @@ -646,8 +642,7 @@ static void lpc43_setcallback(struct timer_lowerhalf_s *lower, priv->callback = callback; priv->arg = arg; - spin_unlock_irqrestore(&priv->lock, flags); - sched_unlock(); + leave_critical_section(flags); } /**************************************************************************** @@ -754,7 +749,6 @@ void lpc43_tmrinitialize(const char *devpath, int irq) } priv->ops = &g_tmrops; - spin_lock_init(&priv->lock); irq_attach(irq, lpc43_interrupt, NULL);