All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, tglx@linutronix.de
Cc: ghennadi.procopciuc@oss.nxp.com, S32@nxp.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 16/20] clocksource/drivers/vf-pit: Consolidate calls to pit_*_disable/enable
Date: Sat,  5 Jul 2025 18:01:22 +0200	[thread overview]
Message-ID: <20250705160129.3688026-16-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20250705160129.3688026-1-daniel.lezcano@linaro.org>

The difference between the pit_clocksource_enable() and
pit_clocksource_disable() is only setting the TIF flag for the
clockevent. Let's group them and pass the TIF flag parameter to the
function so we save some lines of code. But as the base address is
different regarding if it is a clocksource or a clockevent, we pass
the base address in parameter instead of the struct pit_timer.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/timer-vf-pit.c | 34 ++++++++++++------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/clocksource/timer-vf-pit.c b/drivers/clocksource/timer-vf-pit.c
index cd104129e900..f4b25d5a5685 100644
--- a/drivers/clocksource/timer-vf-pit.c
+++ b/drivers/clocksource/timer-vf-pit.c
@@ -64,14 +64,16 @@ static inline void pit_module_disable(void __iomem *base)
 	writel(PITMCR_MDIS, PITMCR(base));
 }
 
-static inline void pit_timer_enable(struct pit_timer *pit)
+static inline void pit_timer_enable(void __iomem *base, bool tie)
 {
-	writel(PITTCTRL_TEN | PITTCTRL_TIE, PITTCTRL(pit->clkevt_base));
+	int val = PITTCTRL_TEN | (tie ? PITTCTRL_TIE : 0);
+
+	writel(val, PITTCTRL(base));
 }
 
-static inline void pit_timer_disable(struct pit_timer *pit)
+static inline void pit_timer_disable(void __iomem *base)
 {
-	writel(0, PITTCTRL(pit->clkevt_base));
+	writel(0, PITTCTRL(base));
 }
 
 static inline void pit_timer_set_counter(void __iomem *base, unsigned int cnt)
@@ -79,16 +81,6 @@ static inline void pit_timer_set_counter(void __iomem *base, unsigned int cnt)
 	writel(cnt, PITLDVAL(base));
 }
 
-static inline void pit_clocksource_enable(struct pit_timer *pit)
-{
-	writel(PITTCTRL_TEN, PITTCTRL(pit->clksrc_base));
-}
-
-static inline void pit_clocksource_disable(struct pit_timer *pit)
-{
-	pit_timer_disable(pit);
-}
-
 static inline void pit_irq_acknowledge(struct pit_timer *pit)
 {
 	writel(PITTFLG_TIF, PITTFLG(pit->clkevt_base));
@@ -122,9 +114,9 @@ static int __init pit_clocksource_init(struct pit_timer *pit, const char *name,
 	pit->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
 	/* set the max load value and start the clock source counter */
-	pit_clocksource_disable(pit);
+	pit_timer_disable(pit->clksrc_base);
 	pit_timer_set_counter(pit->clksrc_base, ~0);
-	pit_clocksource_enable(pit);
+	pit_timer_enable(pit->clksrc_base, 0);
 
 	sched_clock_base = pit->clksrc_base + PITCVAL_OFFSET;
 	sched_clock_register(pit_read_sched_clock, 32, rate);
@@ -143,9 +135,9 @@ static int pit_set_next_event(unsigned long delta, struct clock_event_device *ce
 	 * and the PITLAVAL should be set to delta minus one according to pit
 	 * hardware requirement.
 	 */
-	pit_timer_disable(pit);
+	pit_timer_disable(pit->clkevt_base);
 	pit_timer_set_counter(pit->clkevt_base, delta - 1);
-	pit_timer_enable(pit);
+	pit_timer_enable(pit->clkevt_base, true);
 
 	return 0;
 }
@@ -154,7 +146,7 @@ static int pit_shutdown(struct clock_event_device *ced)
 {
 	struct pit_timer *pit = ced_to_pit(ced);
 
-	pit_timer_disable(pit);
+	pit_timer_disable(pit->clkevt_base);
 
 	return 0;
 }
@@ -182,7 +174,7 @@ static irqreturn_t pit_timer_interrupt(int irq, void *dev_id)
 	 * to stop the counter loop in ONESHOT mode.
 	 */
 	if (likely(clockevent_state_oneshot(ced)))
-		pit_timer_disable(pit);
+		pit_timer_disable(pit->clkevt_base);
 
 	ced->event_handler(ced);
 
@@ -200,7 +192,7 @@ static int __init pit_clockevent_init(struct pit_timer *pit, const char *name,
 	pit->clkevt_base = base + PIT_CH(3);
 	pit->cycle_per_jiffy = rate / (HZ);
 
-	pit_timer_disable(pit);
+	pit_timer_disable(pit->clkevt_base);
 
 	pit_irq_acknowledge(pit);
 
-- 
2.43.0


  parent reply	other threads:[~2025-07-05 16:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-05 16:01 [PATCH 01/20] clocksource/drivers/vf-pit: Replace raw_readl/writel to reald/writel Daniel Lezcano
2025-07-05 16:01 ` [PATCH 02/20] clocksource/drivers/vf_pit: Add COMPILE_TEST option Daniel Lezcano
2025-07-05 16:01 ` [PATCH 03/20] clocksource/drivers/vf_pit: Set the scene for multiple timers Daniel Lezcano
2025-07-07 12:04   ` Ghennadi Procopciuc
2025-07-05 16:01 ` [PATCH 04/20] clocksource/drivers/vf_pit: Rework the base address usage Daniel Lezcano
2025-07-07 12:03   ` Ghennadi Procopciuc
2025-07-24 17:29     ` Daniel Lezcano
2025-07-25  5:10       ` Ghennadi Procopciuc
2025-07-05 16:01 ` [PATCH 05/20] clocksource/drivers/vf_pit: Pass the cpu number as parameter Daniel Lezcano
2025-07-07  9:33   ` Ghennadi Procopciuc
2025-07-24 17:30     ` Daniel Lezcano
2025-07-05 16:01 ` [PATCH 06/20] clocksource/drivers/vf_pit: Encapsulate the initialization of the cycles_per_jiffy Daniel Lezcano
2025-07-05 16:01 ` [PATCH 07/20] clocksource/drivers/vf-pit: Allocate the struct timer at init time Daniel Lezcano
2025-07-05 16:01 ` [PATCH 08/20] clocksource/drivers/vf-pit: Convert raw values to BIT macros Daniel Lezcano
2025-07-05 16:01 ` [PATCH 09/20] clocksource/drivers/vf-pit: Register the clocksource from the driver Daniel Lezcano
2025-07-07 12:02   ` Ghennadi Procopciuc
2025-07-26 19:37     ` Daniel Lezcano
2025-07-05 16:01 ` [PATCH 10/20] clocksource/drivers/vf-pit: Encapsulate the macros Daniel Lezcano
2025-07-07 12:03   ` Ghennadi Procopciuc
2025-07-28  8:35     ` Daniel Lezcano
2025-07-05 16:01 ` [PATCH 11/20] clocksource/drivers/vf-pit: Encapsulate the PTLCVAL macro Daniel Lezcano
2025-07-05 16:01 ` [PATCH 12/20] clocksource/drivers/vf-pit: Use the node name for the interrupt and timer names Daniel Lezcano
2025-07-25  5:12   ` Ghennadi Procopciuc
2025-07-05 16:01 ` [PATCH 13/20] clocksource/drivers/vf-pit: Encapsulate clocksource enable / disable Daniel Lezcano
2025-07-05 16:01 ` [PATCH 14/20] clocksource/drivers/vf-pit: Enable and disable module on error Daniel Lezcano
2025-07-05 16:01 ` [PATCH 15/20] clocksource/drivers/vf-pit: Encapsulate set counter function Daniel Lezcano
2025-07-05 16:01 ` Daniel Lezcano [this message]
2025-07-07 10:28   ` [PATCH 16/20] clocksource/drivers/vf-pit: Consolidate calls to pit_*_disable/enable Ghennadi Procopciuc
2025-07-05 16:01 ` [PATCH 17/20] clocksource/drivers/vf-pit: Unify the function name for irq ack Daniel Lezcano
2025-07-05 16:01 ` [PATCH 18/20] clocksource/drivers/pit: Rename the VF PIT to NXP PIT Daniel Lezcano
2025-07-05 16:01 ` [PATCH 19/20] clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support Daniel Lezcano
2025-07-06 22:13   ` kernel test robot
2025-07-07 12:02   ` Ghennadi Procopciuc
2025-07-28  8:31     ` Daniel Lezcano
2025-07-05 16:01 ` [PATCH 20/20] dt: bindings: fsl,vf610-pit: Add compatible for s32g2 and s32g3 Daniel Lezcano
2025-07-08 17:27   ` Rob Herring
2025-07-07  9:11 ` [PATCH 01/20] clocksource/drivers/vf-pit: Replace raw_readl/writel to reald/writel Ghennadi Procopciuc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250705160129.3688026-16-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=S32@nxp.com \
    --cc=ghennadi.procopciuc@oss.nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.