Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1468408 > unrolled thread

[PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups

Started byAlexandre Belloni <alexandre.belloni@free-electrons.com>
First post2016-08-23 11:00 +0200
Last post2016-08-23 11:10 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-08-23 11:00 +0200
    [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-08-23 11:10 +0200
    [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-08-23 11:10 +0200

#1468408 — [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-08-23 11:00 +0200
Subject[PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups
Message-ID<s9fIR-1yv-17@gated-at.bofh.it>
Hi,

The first patch in the series is a fix that will be needed starting v4.9. The
remaining patches are cleanups.

Changes in v3:
 - stop using panic

Changes in v2:
 - Rebased on v4.8-rc1
 - Collected acks


Alexandre Belloni (4):
  clocksource: timer-atmel-pit: enable mck
  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 | 93 +++++++++++++++--------------------
 1 file changed, 41 insertions(+), 52 deletions(-)

-- 
2.8.1

[toc] | [next] | [standalone]


#1468417 — [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-08-23 11:10 +0200
Subject[PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler
Message-ID<s9fSy-1R4-117@gated-at.bofh.it>
In reply to#1468408
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>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
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 633a94429842..2e215e8e6c1d 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

[toc] | [prev] | [next] | [standalone]


#1468418 — [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-08-23 11:10 +0200
Subject[PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
Message-ID<s9fSy-1R4-119@gated-at.bofh.it>
In reply to#1468408
Merge at91sam926x_pit_common_init in at91sam926x_pit_dt_init as this is the
only initialization method now.

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-pit.c | 82 ++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 44 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 3494bc5a21d5..67240228fe8e 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -177,11 +177,45 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 /*
  * Set up both clocksource and clockevent support.
  */
-static int __init at91sam926x_pit_common_init(struct pit_data *data)
+static int __init at91sam926x_pit_dt_init(struct device_node *node)
 {
-	unsigned long	pit_rate;
-	unsigned	bits;
-	int		ret;
+	unsigned long   pit_rate;
+	unsigned        bits;
+	int             ret;
+	struct pit_data *data;
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->base = of_iomap(node, 0);
+	if (!data->base) {
+		pr_err("Could not map PIT address\n");
+		return -ENXIO;
+	}
+
+	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)) {
+		pr_err("Unable to get mck clk\n");
+		return PTR_ERR(data->mck);
+	}
+
+	ret = clk_prepare_enable(data->mck);
+	if (ret) {
+		pr_err("Unable to enable mck\n");
+		return ret;
+	}
+
+	/* Get the interrupts property */
+	data->irq = irq_of_parse_and_map(node, 0);
+	if (!data->irq) {
+		pr_err("Unable to get IRQ from DT\n");
+		return -EINVAL;
+	}
 
 	/*
 	 * Use our actual MCK to figure out how many MCK/16 ticks per
@@ -236,45 +270,5 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data)
 
 	return 0;
 }
-
-static int __init at91sam926x_pit_dt_init(struct device_node *node)
-{
-	struct pit_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->base = of_iomap(node, 0);
-	if (!data->base) {
-		pr_err("Could not map PIT address\n");
-		return -ENXIO;
-	}
-
-	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)) {
-		pr_err("Unable to get mck clk\n");
-		return PTR_ERR(data->mck);
-	}
-
-	ret = clk_prepare_enable(data->mck);
-	if (ret) {
-		pr_err("Unable to enable mck\n");
-		return ret;
-	}
-
-	/* Get the interrupts property */
-	data->irq = irq_of_parse_and_map(node, 0);
-	if (!data->irq) {
-		pr_err("Unable to get IRQ from DT\n");
-		return -EINVAL;
-	}
-
-	return at91sam926x_pit_common_init(data);
-}
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
-- 
2.8.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web