public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup
@ 2016-07-04 22:12 Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 1/3] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-07-04 22:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Alexandre Belloni

Hi,

Here are a few cleanups I had laying around for a while. I rebased and
tested on top of 4.7-rc1.

The series will apply after:
"clocksource: timer-atmel-pit: enable mck"


Alexandre Belloni (3):
  clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
  clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE
  clocksource: timer-atmel-pit: simplify IRQ handler

 drivers/clocksource/timer-atmel-pit.c | 76 ++++++++++++++---------------------
 1 file changed, 30 insertions(+), 46 deletions(-)

-- 
2.8.1

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

* [PATCH 1/3] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
  2016-07-04 22:12 [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Alexandre Belloni
@ 2016-07-04 22:12 ` Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 2/3] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-07-04 22:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Alexandre Belloni

Merge at91sam926x_pit_common_init in at91sam926x_pit_dt_init as this is the
only initialization method now.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-pit.c | 59 ++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index fcc97711cd79..87659b8734d5 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -177,11 +177,37 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 /*
  * Set up both clocksource and clockevent support.
  */
-static void __init at91sam926x_pit_common_init(struct pit_data *data)
+static void __init at91sam926x_pit_dt_init(struct device_node *node)
 {
 	unsigned long	pit_rate;
 	unsigned	bits;
 	int		ret;
+	struct pit_data *data;
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data)
+		panic(pr_fmt("Unable to allocate memory\n"));
+
+	data->base = of_iomap(node, 0);
+	if (!data->base)
+		panic(pr_fmt("Could not map PIT address\n"));
+
+	data->mck = of_clk_get(node, 0);
+	if (IS_ERR(data->mck))
+		/* Fallback on clkdev for !CCF-based boards */
+		data->mck = clk_get(NULL, "mck");
+
+	if (IS_ERR(data->mck))
+		panic(pr_fmt("Unable to get mck clk\n"));
+
+	if (clk_prepare_enable(data->mck))
+		panic(pr_fmt("Unable to enable mck\n"));
+
+	/* Get the interrupts property */
+	data->irq = irq_of_parse_and_map(node, 0);
+	if (!data->irq)
+		panic(pr_fmt("Unable to get IRQ from DT\n"));
+
 
 	/*
 	 * Use our actual MCK to figure out how many MCK/16 ticks per
@@ -227,36 +253,5 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
 	data->clkevt.suspend = at91sam926x_pit_suspend;
 	clockevents_register_device(&data->clkevt);
 }
-
-static void __init at91sam926x_pit_dt_init(struct device_node *node)
-{
-	struct pit_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		panic(pr_fmt("Unable to allocate memory\n"));
-
-	data->base = of_iomap(node, 0);
-	if (!data->base)
-		panic(pr_fmt("Could not map PIT address\n"));
-
-	data->mck = of_clk_get(node, 0);
-	if (IS_ERR(data->mck))
-		/* Fallback on clkdev for !CCF-based boards */
-		data->mck = clk_get(NULL, "mck");
-
-	if (IS_ERR(data->mck))
-		panic(pr_fmt("Unable to get mck clk\n"));
-
-	if (clk_prepare_enable(data->mck))
-		panic(pr_fmt("Unable to enable mck\n"));
-
-	/* Get the interrupts property */
-	data->irq = irq_of_parse_and_map(node, 0);
-	if (!data->irq)
-		panic(pr_fmt("Unable to get IRQ from DT\n"));
-
-	at91sam926x_pit_common_init(data);
-}
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
-- 
2.8.1

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

* [PATCH 2/3] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE
  2016-07-04 22:12 [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 1/3] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
@ 2016-07-04 22:12 ` Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 3/3] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
  2016-07-05  7:50 ` [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Nicolas Ferre
  3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-07-04 22:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Alexandre Belloni

IRQ handlers are running with IRQ disabled for a while, remove wrong
comment and useless test.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-pit.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 87659b8734d5..b07505cd31cf 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -149,12 +149,6 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 {
 	struct pit_data *data = dev_id;
 
-	/*
-	 * irqs should be disabled here, but as the irq is shared they are only
-	 * guaranteed to be off if the timer irq is registered first.
-	 */
-	WARN_ON_ONCE(!irqs_disabled());
-
 	/* The PIT interrupt may be disabled, and is shared */
 	if (clockevent_state_periodic(&data->clkevt) &&
 	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
-- 
2.8.1

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

* [PATCH 3/3] clocksource: timer-atmel-pit: simplify IRQ handler
  2016-07-04 22:12 [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 1/3] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
  2016-07-04 22:12 ` [PATCH 2/3] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
@ 2016-07-04 22:12 ` Alexandre Belloni
  2016-07-05  7:50 ` [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Nicolas Ferre
  3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-07-04 22:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Alexandre Belloni

Because the PIT is also a proper clocksource, the timekeeping code  is
already able to handle lost ticks.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-pit.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index b07505cd31cf..a9ef5a2292d8 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -152,15 +152,10 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	/* The PIT interrupt may be disabled, and is shared */
 	if (clockevent_state_periodic(&data->clkevt) &&
 	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
-		unsigned nr_ticks;
-
 		/* Get number of ticks performed before irq, and ack it */
-		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
-		do {
-			data->cnt += data->cycle;
-			data->clkevt.event_handler(&data->clkevt);
-			nr_ticks--;
-		} while (nr_ticks);
+		data->cnt += data->cycle * PIT_PICNT(pit_read(data->base,
+							      AT91_PIT_PIVR));
+		data->clkevt.event_handler(&data->clkevt);
 
 		return IRQ_HANDLED;
 	}
-- 
2.8.1

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

* Re: [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup
  2016-07-04 22:12 [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Alexandre Belloni
                   ` (2 preceding siblings ...)
  2016-07-04 22:12 ` [PATCH 3/3] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
@ 2016-07-05  7:50 ` Nicolas Ferre
  3 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-07-05  7:50 UTC (permalink / raw)
  To: Alexandre Belloni, Daniel Lezcano
  Cc: Thomas Gleixner, Boris Brezillon, linux-arm-kernel, linux-kernel

Le 05/07/2016 00:12, Alexandre Belloni a écrit :
> Hi,
> 
> Here are a few cleanups I had laying around for a while. I rebased and
> tested on top of 4.7-rc1.
> 
> The series will apply after:
> "clocksource: timer-atmel-pit: enable mck"
> 
> 
> Alexandre Belloni (3):
>   clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
>   clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE
>   clocksource: timer-atmel-pit: simplify IRQ handler

To the whole series:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Thanks for having done this cleanup. Bye,

>  drivers/clocksource/timer-atmel-pit.c | 76 ++++++++++++++---------------------
>  1 file changed, 30 insertions(+), 46 deletions(-)
> 


-- 
Nicolas Ferre

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

end of thread, other threads:[~2016-07-05  7:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-04 22:12 [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Alexandre Belloni
2016-07-04 22:12 ` [PATCH 1/3] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
2016-07-04 22:12 ` [PATCH 2/3] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
2016-07-04 22:12 ` [PATCH 3/3] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
2016-07-05  7:50 ` [PATCH 0/3] clocksource: timer-atmel-pit: driver cleanup Nicolas Ferre

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