diff mbox

[2/6] clocksource: arm_global_timer: Migrate to new 'set-state' interface

Message ID 54f346e663f605e2f078a3114de85ba281d1e6d0.1433768426.git.viresh.kumar@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Viresh Kumar June 8, 2015, 1:40 p.m. UTC
Migrate arm_global_timer driver to the new 'set-state' interface
provided by the 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: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
Cc: Maxime Coquelin <maxime.coquelin@st.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/clocksource/arm_global_timer.c | 37 ++++++++++++++++------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

Comments

Daniel Lezcano June 11, 2015, 2:49 p.m. UTC | #1
On 06/08/2015 03:40 PM, Viresh Kumar wrote:
> Migrate arm_global_timer driver to the new 'set-state' interface
> provided by the 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: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
> Cc: Maxime Coquelin <maxime.coquelin@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   drivers/clocksource/arm_global_timer.c | 37 ++++++++++++++++------------------

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> -	clk->set_mode = gt_clockevent_set_mode;
> +	clk->set_state_shutdown = gt_clockevent_shutdown;
> +	clk->set_state_periodic = gt_clockevent_set_periodic;
> +	clk->set_state_oneshot = gt_clockevent_shutdown;

nit: it sounds weird to use the same function as the purpose of the 
patch is use the new API which is to ventilate those functions (anyway ...)

>   	clk->set_next_event = gt_clockevent_set_next_event;
>   	clk->cpumask = cpumask_of(cpu);
>   	clk->rating = 300;
> @@ -184,7 +181,7 @@ static int gt_clockevents_init(struct clock_event_device *clk)
>
>   static void gt_clockevents_stop(struct clock_event_device *clk)
>   {
> -	gt_clockevent_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
> +	gt_clockevent_shutdown(clk);
>   	disable_percpu_irq(clk->irq);
>   }
Viresh Kumar June 11, 2015, 2:56 p.m. UTC | #2
On 11-06-15, 16:49, Daniel Lezcano wrote:
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Thanks :)

> >-	clk->set_mode = gt_clockevent_set_mode;
> >+	clk->set_state_shutdown = gt_clockevent_shutdown;
> >+	clk->set_state_periodic = gt_clockevent_set_periodic;
> >+	clk->set_state_oneshot = gt_clockevent_shutdown;
> 
> nit: it sounds weird to use the same function as the purpose of the
> patch is use the new API which is to ventilate those functions
> (anyway ...)

Hmm, but there is no point creating two routines to do exactly the
same thing. And this is making it evident that we actually shutdown
the device in oneshot-state request. And enable it only when the next
event is programmed.
Daniel Lezcano June 11, 2015, 2:58 p.m. UTC | #3
On 06/11/2015 04:56 PM, Viresh Kumar wrote:
> On 11-06-15, 16:49, Daniel Lezcano wrote:
>> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>
> Thanks :)
>
>>> -	clk->set_mode = gt_clockevent_set_mode;
>>> +	clk->set_state_shutdown = gt_clockevent_shutdown;
>>> +	clk->set_state_periodic = gt_clockevent_set_periodic;
>>> +	clk->set_state_oneshot = gt_clockevent_shutdown;
>>
>> nit: it sounds weird to use the same function as the purpose of the
>> patch is use the new API which is to ventilate those functions
>> (anyway ...)
>
> Hmm, but there is no point creating two routines to do exactly the
> same thing. And this is making it evident that we actually shutdown
> the device in oneshot-state request. And enable it only when the next
> event is programmed.

Yes, this is really a detail.
Srinivas Kandagatla June 12, 2015, 8:39 a.m. UTC | #4
On 08/06/15 14:40, Viresh Kumar wrote:
> Migrate arm_global_timer driver to the new 'set-state' interface
> provided by the 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: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
> Cc: Maxime Coquelin <maxime.coquelin@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   drivers/clocksource/arm_global_timer.c | 37 ++++++++++++++++------------------
>   1 file changed, 17 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
> index e6833771a716..29ea50ac366a 100644
> --- a/drivers/clocksource/arm_global_timer.c
> +++ b/drivers/clocksource/arm_global_timer.c
>
Hi Viresh,
Thanks for the patch,

Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

--srini
Viresh Kumar June 12, 2015, 8:51 a.m. UTC | #5
On 12-06-15, 09:39, Srinivas Kandagatla wrote:
> Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Thanks Srinivas, but you gave this for the V1 version. Can you please
do that again for V2 ?
diff mbox

Patch

diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index e6833771a716..29ea50ac366a 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -107,26 +107,21 @@  static void gt_compare_set(unsigned long delta, int periodic)
 	writel(ctrl, gt_base + GT_CONTROL);
 }
 
-static void gt_clockevent_set_mode(enum clock_event_mode mode,
-				   struct clock_event_device *clk)
+static int gt_clockevent_shutdown(struct clock_event_device *evt)
 {
 	unsigned long ctrl;
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		ctrl = readl(gt_base + GT_CONTROL);
-		ctrl &= ~(GT_CONTROL_COMP_ENABLE |
-				GT_CONTROL_IRQ_ENABLE | GT_CONTROL_AUTO_INC);
-		writel(ctrl, gt_base + GT_CONTROL);
-		break;
-	default:
-		break;
-	}
+	ctrl = readl(gt_base + GT_CONTROL);
+	ctrl &= ~(GT_CONTROL_COMP_ENABLE | GT_CONTROL_IRQ_ENABLE |
+		  GT_CONTROL_AUTO_INC);
+	writel(ctrl, gt_base + GT_CONTROL);
+	return 0;
+}
+
+static int gt_clockevent_set_periodic(struct clock_event_device *evt)
+{
+	gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1);
+	return 0;
 }
 
 static int gt_clockevent_set_next_event(unsigned long evt,
@@ -155,7 +150,7 @@  static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id)
 	 *	the Global Timer flag _after_ having incremented
 	 *	the Comparator register	value to a higher value.
 	 */
-	if (evt->mode == CLOCK_EVT_MODE_ONESHOT)
+	if (clockevent_state_oneshot(evt))
 		gt_compare_set(ULONG_MAX, 0);
 
 	writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS);
@@ -171,7 +166,9 @@  static int gt_clockevents_init(struct clock_event_device *clk)
 	clk->name = "arm_global_timer";
 	clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
 		CLOCK_EVT_FEAT_PERCPU;
-	clk->set_mode = gt_clockevent_set_mode;
+	clk->set_state_shutdown = gt_clockevent_shutdown;
+	clk->set_state_periodic = gt_clockevent_set_periodic;
+	clk->set_state_oneshot = gt_clockevent_shutdown;
 	clk->set_next_event = gt_clockevent_set_next_event;
 	clk->cpumask = cpumask_of(cpu);
 	clk->rating = 300;
@@ -184,7 +181,7 @@  static int gt_clockevents_init(struct clock_event_device *clk)
 
 static void gt_clockevents_stop(struct clock_event_device *clk)
 {
-	gt_clockevent_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
+	gt_clockevent_shutdown(clk);
 	disable_percpu_irq(clk->irq);
 }