[PATCH] clockevents/drivers/sh_cmt: set ->min_delta_ticks and ->max_delta_ticks

From: Nicolai Stange
Date: Thu Mar 30 2017 - 16:09:21 EST


In preparation for making the clockevents core NTP correction aware,
all clockevent device drivers must set ->min_delta_ticks and
->max_delta_ticks rather than ->min_delta_ns and ->max_delta_ns: a
clockevent device's rate is going to change dynamically and thus, the
ratio of ns to ticks ceases to stay invariant.

Make the sh_cmt clockevent driver initialize these fields properly.

This patch alone doesn't introduce any change in functionality as the
clockevents core still looks exclusively at the (untouched) ->min_delta_ns
and ->max_delta_ns. As soon as this has changed, a followup patch will
purge the initialization of ->min_delta_ns and ->max_delta_ns from this
driver.

Signed-off-by: Nicolai Stange <nicstange@xxxxxxxxx>
---

Notes:
This prerequisite patch is part of a larger effort to feed NTP
corrections into the clockevent devices' frequencies and thus
avoiding their notion of time to diverge from the system's
one. If you're interested, the current state of the whole series
can be found at [1].

If you haven't got any objections and these prerequisites get
merged by 4.12 everywhere, I'll proceed with the remainder of
this series in 4.13.

Attention: due to 890f423b2666 ("clocksource: sh_cmt: Compute rate before
registration again"), this should go through John' Stultz tree [2].

[1]
git://nicst.de/linux.git cev-freq-adj.v10.fortglx-4.12-time
https://nicst.de/git/?p=linux.git;a=shortlog;h=refs/heads/cev-freq-adj.v10.fortglx-4.12-time

[2]
https://git.linaro.org/people/john.stultz/linux.git fortglx/4.12/time

drivers/clocksource/sh_cmt.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index e3bf3baa12cc..e09e8bf0bb9b 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -815,7 +815,9 @@ static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch,
ced->shift = 32;
ced->mult = div_sc(ch->cmt->rate, NSEC_PER_SEC, ced->shift);
ced->max_delta_ns = clockevent_delta2ns(ch->max_match_value, ced);
+ ced->max_delta_ticks = ch->max_match_value;
ced->min_delta_ns = clockevent_delta2ns(0x1f, ced);
+ ced->min_delta_ticks = 0x1f;

dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n",
ch->index);
--
2.12.0