Linux Samsung SOC development
 help / color / mirror / Atom feed
* [question] [PATCH RFC] clocksource: exynos_mct: remove unneeded container_of()
@ 2015-06-14 22:50 Alexey Klimov
  2015-06-15 19:39 ` Stephen Boyd
  2015-06-21 20:41 ` [PATCH] " Alexey Klimov
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Klimov @ 2015-06-14 22:50 UTC (permalink / raw)
  To: linux-samsung-soc, sboyd
  Cc: klimov.linux, t.dakhran, yury.norov, kgene, k.kozlowski,
	thomas.abraham

Hi Stephen and all,

i'm lazy-looking on commit ee98d27df6827b5ba4bd99cb7d5cb1239b6a1a31
"ARM: EXYNOS4: Divorce mct from local timer API".

I think i miss some point of local timers APIs and other things but why
we are going to get evt pointer from mevt structure in
exynos4_mct_cpu_notify(), pass it to setup function and there we
calculate mevt pointer again from evt by using container_of() macro?

To be simple, does patch below makes any sense or am I wrong somewhere?
Just want to optimize setup function a little. Looks like code performs
useless work.

Tested on odroid-xu3 with PMU spare2 register fix.

Best regards,
Alexey Klimov.

----------
From: Alexey Klimov <klimov.linux@gmail.com>

Patch removes unneeded container_of() macro
in exynos4_local_timer_setup(). Instead let's pass mevt pointer
to setup and stop functions from exynos4_mct_cpu_notify() 
and let them get evt pointer.

Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
---
 drivers/clocksource/exynos_mct.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index 83564c9..752a37c 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -446,13 +446,11 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int exynos4_local_timer_setup(struct clock_event_device *evt)
+static int exynos4_local_timer_setup(struct mct_clock_event_device *mevt)
 {
-	struct mct_clock_event_device *mevt;
+	struct clock_event_device *evt = &mevt->evt;
 	unsigned int cpu = smp_processor_id();
 
-	mevt = container_of(evt, struct mct_clock_event_device, evt);
-
 	mevt->base = EXYNOS4_MCT_L_BASE(cpu);
 	snprintf(mevt->name, sizeof(mevt->name), "mct_tick%d", cpu);
 
@@ -484,8 +482,10 @@ static int exynos4_local_timer_setup(struct clock_event_device *evt)
 	return 0;
 }
 
-static void exynos4_local_timer_stop(struct clock_event_device *evt)
+static void exynos4_local_timer_stop(struct mct_clock_event_device *mevt)
 {
+	struct clock_event_device *evt = &mevt->evt;
+
 	evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
 	if (mct_int_type == MCT_INT_SPI)
 		free_irq(evt->irq, this_cpu_ptr(&percpu_mct_tick));
@@ -505,11 +505,11 @@ static int exynos4_mct_cpu_notify(struct notifier_block *self,
 	switch (action & ~CPU_TASKS_FROZEN) {
 	case CPU_STARTING:
 		mevt = this_cpu_ptr(&percpu_mct_tick);
-		exynos4_local_timer_setup(&mevt->evt);
+		exynos4_local_timer_setup(mevt);
 		break;
 	case CPU_DYING:
 		mevt = this_cpu_ptr(&percpu_mct_tick);
-		exynos4_local_timer_stop(&mevt->evt);
+		exynos4_local_timer_stop(mevt);
 		break;
 	}
 
@@ -557,7 +557,7 @@ static void __init exynos4_timer_resources(struct device_node *np, void __iomem
 		goto out_irq;
 
 	/* Immediately configure the timer on the boot CPU */
-	exynos4_local_timer_setup(&mevt->evt);
+	exynos4_local_timer_setup(mevt);
 	return;
 
 out_irq:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [question] [PATCH RFC] clocksource: exynos_mct: remove unneeded container_of()
  2015-06-14 22:50 [question] [PATCH RFC] clocksource: exynos_mct: remove unneeded container_of() Alexey Klimov
@ 2015-06-15 19:39 ` Stephen Boyd
  2015-06-21 20:41 ` [PATCH] " Alexey Klimov
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2015-06-15 19:39 UTC (permalink / raw)
  To: Alexey Klimov
  Cc: linux-samsung-soc, t.dakhran, yury.norov, kgene, k.kozlowski,
	thomas.abraham

On 06/15, Alexey Klimov wrote:
> 
> Patch removes unneeded container_of() macro
> in exynos4_local_timer_setup(). Instead let's pass mevt pointer
> to setup and stop functions from exynos4_mct_cpu_notify() 
> and let them get evt pointer.
> 
> Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

It was done this way to minimize the diff. I don't see any
problem changing it as you propose.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] clocksource: exynos_mct: remove unneeded container_of()
  2015-06-14 22:50 [question] [PATCH RFC] clocksource: exynos_mct: remove unneeded container_of() Alexey Klimov
  2015-06-15 19:39 ` Stephen Boyd
@ 2015-06-21 20:41 ` Alexey Klimov
  2015-06-22  0:04   ` Krzysztof Kozlowski
  2015-06-29  9:09   ` Daniel Lezcano
  1 sibling, 2 replies; 5+ messages in thread
From: Alexey Klimov @ 2015-06-21 20:41 UTC (permalink / raw)
  To: linux-samsung-soc, k.kozlowski; +Cc: sboyd, t.dakhran, kgene

Patch removes unneeded container_of() macro
in exynos4_local_timer_setup(). Instead let's pass mevt pointer
to setup and stop functions from exynos4_mct_cpu_notify()
and let them get evt pointer.

Tested on odroid-xu3.

Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clocksource/exynos_mct.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index 83564c9..752a37c 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -446,13 +446,11 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int exynos4_local_timer_setup(struct clock_event_device *evt)
+static int exynos4_local_timer_setup(struct mct_clock_event_device *mevt)
 {
-	struct mct_clock_event_device *mevt;
+	struct clock_event_device *evt = &mevt->evt;
 	unsigned int cpu = smp_processor_id();
 
-	mevt = container_of(evt, struct mct_clock_event_device, evt);
-
 	mevt->base = EXYNOS4_MCT_L_BASE(cpu);
 	snprintf(mevt->name, sizeof(mevt->name), "mct_tick%d", cpu);
 
@@ -484,8 +482,10 @@ static int exynos4_local_timer_setup(struct clock_event_device *evt)
 	return 0;
 }
 
-static void exynos4_local_timer_stop(struct clock_event_device *evt)
+static void exynos4_local_timer_stop(struct mct_clock_event_device *mevt)
 {
+	struct clock_event_device *evt = &mevt->evt;
+
 	evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
 	if (mct_int_type == MCT_INT_SPI)
 		free_irq(evt->irq, this_cpu_ptr(&percpu_mct_tick));
@@ -505,11 +505,11 @@ static int exynos4_mct_cpu_notify(struct notifier_block *self,
 	switch (action & ~CPU_TASKS_FROZEN) {
 	case CPU_STARTING:
 		mevt = this_cpu_ptr(&percpu_mct_tick);
-		exynos4_local_timer_setup(&mevt->evt);
+		exynos4_local_timer_setup(mevt);
 		break;
 	case CPU_DYING:
 		mevt = this_cpu_ptr(&percpu_mct_tick);
-		exynos4_local_timer_stop(&mevt->evt);
+		exynos4_local_timer_stop(mevt);
 		break;
 	}
 
@@ -557,7 +557,7 @@ static void __init exynos4_timer_resources(struct device_node *np, void __iomem
 		goto out_irq;
 
 	/* Immediately configure the timer on the boot CPU */
-	exynos4_local_timer_setup(&mevt->evt);
+	exynos4_local_timer_setup(mevt);
 	return;
 
 out_irq:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] clocksource: exynos_mct: remove unneeded container_of()
  2015-06-21 20:41 ` [PATCH] " Alexey Klimov
@ 2015-06-22  0:04   ` Krzysztof Kozlowski
  2015-06-29  9:09   ` Daniel Lezcano
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2015-06-22  0:04 UTC (permalink / raw)
  To: Alexey Klimov, linux-samsung-soc
  Cc: sboyd, t.dakhran, kgene, Daniel Lezcano, Thomas Gleixner,
	linux-kernel

On 22.06.2015 05:41, Alexey Klimov wrote:
> Patch removes unneeded container_of() macro
> in exynos4_local_timer_setup(). Instead let's pass mevt pointer
> to setup and stop functions from exynos4_mct_cpu_notify()
> and let them get evt pointer.
> 
> Tested on odroid-xu3.
> 
> Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
> Acked-by: Stephen Boyd <sboyd@codeaurora.org>

Looks good, the internal interface now seems more consistent.
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

However you forgot to mail this to maintainers of clocksource subsystem
(Cc'ed: Daniel, Thomas, LKML).

Best regards,
Krzysztof


> ---
>  drivers/clocksource/exynos_mct.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
> index 83564c9..752a37c 100644
> --- a/drivers/clocksource/exynos_mct.c
> +++ b/drivers/clocksource/exynos_mct.c
> @@ -446,13 +446,11 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> -static int exynos4_local_timer_setup(struct clock_event_device *evt)
> +static int exynos4_local_timer_setup(struct mct_clock_event_device *mevt)
>  {
> -	struct mct_clock_event_device *mevt;
> +	struct clock_event_device *evt = &mevt->evt;
>  	unsigned int cpu = smp_processor_id();
>  
> -	mevt = container_of(evt, struct mct_clock_event_device, evt);
> -
>  	mevt->base = EXYNOS4_MCT_L_BASE(cpu);
>  	snprintf(mevt->name, sizeof(mevt->name), "mct_tick%d", cpu);
>  
> @@ -484,8 +482,10 @@ static int exynos4_local_timer_setup(struct clock_event_device *evt)
>  	return 0;
>  }
>  
> -static void exynos4_local_timer_stop(struct clock_event_device *evt)
> +static void exynos4_local_timer_stop(struct mct_clock_event_device *mevt)
>  {
> +	struct clock_event_device *evt = &mevt->evt;
> +
>  	evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
>  	if (mct_int_type == MCT_INT_SPI)
>  		free_irq(evt->irq, this_cpu_ptr(&percpu_mct_tick));
> @@ -505,11 +505,11 @@ static int exynos4_mct_cpu_notify(struct notifier_block *self,
>  	switch (action & ~CPU_TASKS_FROZEN) {
>  	case CPU_STARTING:
>  		mevt = this_cpu_ptr(&percpu_mct_tick);
> -		exynos4_local_timer_setup(&mevt->evt);
> +		exynos4_local_timer_setup(mevt);
>  		break;
>  	case CPU_DYING:
>  		mevt = this_cpu_ptr(&percpu_mct_tick);
> -		exynos4_local_timer_stop(&mevt->evt);
> +		exynos4_local_timer_stop(mevt);
>  		break;
>  	}
>  
> @@ -557,7 +557,7 @@ static void __init exynos4_timer_resources(struct device_node *np, void __iomem
>  		goto out_irq;
>  
>  	/* Immediately configure the timer on the boot CPU */
> -	exynos4_local_timer_setup(&mevt->evt);
> +	exynos4_local_timer_setup(mevt);
>  	return;
>  
>  out_irq:
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clocksource: exynos_mct: remove unneeded container_of()
  2015-06-21 20:41 ` [PATCH] " Alexey Klimov
  2015-06-22  0:04   ` Krzysztof Kozlowski
@ 2015-06-29  9:09   ` Daniel Lezcano
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2015-06-29  9:09 UTC (permalink / raw)
  To: Alexey Klimov, linux-samsung-soc, k.kozlowski; +Cc: sboyd, t.dakhran, kgene

On 06/21/2015 10:41 PM, Alexey Klimov wrote:
> Patch removes unneeded container_of() macro
> in exynos4_local_timer_setup(). Instead let's pass mevt pointer
> to setup and stop functions from exynos4_mct_cpu_notify()
> and let them get evt pointer.
>
> Tested on odroid-xu3.
>
> Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
> Acked-by: Stephen Boyd <sboyd@codeaurora.org>
> ---

Applied to my tree for 4.3.

Thanks !

   -- Daniel

-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-29  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-14 22:50 [question] [PATCH RFC] clocksource: exynos_mct: remove unneeded container_of() Alexey Klimov
2015-06-15 19:39 ` Stephen Boyd
2015-06-21 20:41 ` [PATCH] " Alexey Klimov
2015-06-22  0:04   ` Krzysztof Kozlowski
2015-06-29  9:09   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox