2015-06-18 10:57:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 36/41] clocksource: stm32: Migrate to new 'set-state' interface

Migrate stm32 driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Cc: Maxime Coquelin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/clocksource/timer-stm32.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index a97e8b50701c..f3dcb76799b4 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -40,24 +40,25 @@ struct stm32_clock_event_ddata {
void __iomem *base;
};

-static void stm32_clock_event_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evtdev)
+static int stm32_clock_event_shutdown(struct clock_event_device *evtdev)
{
struct stm32_clock_event_ddata *data =
container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
void *base = data->base;

- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- writel_relaxed(data->periodic_top, base + TIM_ARR);
- writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, base + TIM_CR1);
- break;
+ writel_relaxed(0, base + TIM_CR1);
+ return 0;
+}

- case CLOCK_EVT_MODE_ONESHOT:
- default:
- writel_relaxed(0, base + TIM_CR1);
- break;
- }
+static int stm32_clock_event_set_periodic(struct clock_event_device *evtdev)
+{
+ struct stm32_clock_event_ddata *data =
+ container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
+ void *base = data->base;
+
+ writel_relaxed(data->periodic_top, base + TIM_ARR);
+ writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, base + TIM_CR1);
+ return 0;
}

static int stm32_clock_event_set_next_event(unsigned long evt,
@@ -88,7 +89,10 @@ static struct stm32_clock_event_ddata clock_event_ddata = {
.evtdev = {
.name = "stm32 clockevent",
.features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
- .set_mode = stm32_clock_event_set_mode,
+ .set_state_shutdown = stm32_clock_event_shutdown,
+ .set_state_periodic = stm32_clock_event_set_periodic,
+ .set_state_oneshot = stm32_clock_event_shutdown,
+ .tick_resume = stm32_clock_event_shutdown,
.set_next_event = stm32_clock_event_set_next_event,
.rating = 200,
},
--
2.4.0


2015-06-18 11:09:59

by Maxime Coquelin

[permalink] [raw]
Subject: Re: [PATCH 36/41] clocksource: stm32: Migrate to new 'set-state' interface

Hi Viresh,

On 06/18/2015 12:54 PM, Viresh Kumar wrote:
> Migrate stm32 driver to the new 'set-state' interface provided by
> clockevents core, the earlier 'set-mode' interface is marked obsolete
> now.
>
> This also enables us to implement callbacks for new states of clockevent
> devices, for example: ONESHOT_STOPPED.
>
> Cc: Maxime Coquelin <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> drivers/clocksource/timer-stm32.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
>

Thanks for having implemented the move to the new interface.
I just tested it, and confirm it works fine on my STM32 board.
You can add:

Tested-by: Maxime Coquelin <[email protected]>
Acked-by: Maxime Coquelin <[email protected]>

Regards,
Maxime

2015-06-18 11:32:46

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 36/41] clocksource: stm32: Migrate to new 'set-state' interface

On 18-06-15, 13:09, Maxime Coquelin wrote:
> Thanks for having implemented the move to the new interface.
> I just tested it, and confirm it works fine on my STM32 board.
> You can add:
>
> Tested-by: Maxime Coquelin <[email protected]>
> Acked-by: Maxime Coquelin <[email protected]>

Oh, that was so quick. Thanks a lot.

--
viresh