2013-09-18 02:58:02

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH v2] clocksource: fix misleading comment for __clocksource_updatefreq_scale()

Functions clocksource_updatefreq_hz() and clocksource_updatefreq_khz()
mentioned in the comment of __clocksource_updatefreq_scale() do not exist.

As Thomas Gleixner's suggestion, I renamed the functions and the few call
sites because the underscores are completely meaningless.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Thomas Gleixner <[email protected]>
---
drivers/clocksource/cadence_ttc_timer.c | 2 +-
drivers/clocksource/em_sti.c | 2 +-
drivers/clocksource/sh_cmt.c | 2 +-
drivers/clocksource/sh_tmu.c | 2 +-
include/linux/clocksource.h | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
index 4cbe28c..05f00e7 100644
--- a/drivers/clocksource/cadence_ttc_timer.c
+++ b/drivers/clocksource/cadence_ttc_timer.c
@@ -226,7 +226,7 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
* Do whatever is necessary to maintain a proper time base
*
* I cannot find a way to adjust the currently used clocksource
- * to the new frequency. __clocksource_updatefreq_hz() sounds
+ * to the new frequency. clocksource_updatefreq_hz() sounds
* good, but does not work. Not sure what's that missing.
*
* This approach works, but triggers two clocksource switches.
diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index 4329a29..ccbb513 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -210,7 +210,7 @@ static int em_sti_clocksource_enable(struct clocksource *cs)

ret = em_sti_start(p, USER_CLOCKSOURCE);
if (!ret)
- __clocksource_updatefreq_hz(cs, p->rate);
+ clocksource_updatefreq_hz(cs, p->rate);
return ret;
}

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 08d0c41..dc812c5 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -504,7 +504,7 @@ static int sh_cmt_clocksource_enable(struct clocksource *cs)

ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
if (!ret) {
- __clocksource_updatefreq_hz(cs, p->rate);
+ clocksource_updatefreq_hz(cs, p->rate);
p->cs_enabled = true;
}
return ret;
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 78b8dae..be4ae3e 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -236,7 +236,7 @@ static int sh_tmu_clocksource_enable(struct clocksource *cs)

ret = sh_tmu_enable(p);
if (!ret) {
- __clocksource_updatefreq_hz(cs, p->rate);
+ clocksource_updatefreq_hz(cs, p->rate);
p->cs_enabled = true;
}

diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index dbbf8aa..87e8aa0 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -314,12 +314,12 @@ static inline int clocksource_register_khz(struct clocksource *cs, u32 khz)
return __clocksource_register_scale(cs, 1000, khz);
}

-static inline void __clocksource_updatefreq_hz(struct clocksource *cs, u32 hz)
+static inline void clocksource_updatefreq_hz(struct clocksource *cs, u32 hz)
{
__clocksource_updatefreq_scale(cs, 1, hz);
}

-static inline void __clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
+static inline void clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
{
__clocksource_updatefreq_scale(cs, 1000, khz);
}
--
1.8.2.1


2013-10-09 23:35:40

by John Stultz

[permalink] [raw]
Subject: Re: [PATCH v2] clocksource: fix misleading comment for __clocksource_updatefreq_scale()

On 09/17/2013 07:57 PM, Xie XiuQi wrote:
> Functions clocksource_updatefreq_hz() and clocksource_updatefreq_khz()
> mentioned in the comment of __clocksource_updatefreq_scale() do not exist.
>
> As Thomas Gleixner's suggestion, I renamed the functions and the few call
> sites because the underscores are completely meaningless.

First of all, sorry for taking so long to reply here.

So I think the __ tries to imply that those are semi-internal functions
that aren't to be causally used w/o understanding the internal details.

> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> ---
> drivers/clocksource/cadence_ttc_timer.c | 2 +-
> drivers/clocksource/em_sti.c | 2 +-
> drivers/clocksource/sh_cmt.c | 2 +-
> drivers/clocksource/sh_tmu.c | 2 +-
> include/linux/clocksource.h | 4 ++--
> 5 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
> index 4cbe28c..05f00e7 100644
> --- a/drivers/clocksource/cadence_ttc_timer.c
> +++ b/drivers/clocksource/cadence_ttc_timer.c
> @@ -226,7 +226,7 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
> * Do whatever is necessary to maintain a proper time base
> *
> * I cannot find a way to adjust the currently used clocksource
> - * to the new frequency. __clocksource_updatefreq_hz() sounds
> + * to the new frequency. clocksource_updatefreq_hz() sounds
> * good, but does not work. Not sure what's that missing.
> *

So I know you didn't write the comment, but my issue with this comment
is that there isn't a way to adjust the currently used clocksource
frequency, because that is totally unsupported. The
__clocksource_updatefreq_hz() method is really only there for
clocksources that are currently not in-use and are disabled.
Specifically for clocksources that may come out of resume at a different
frequency, like the sh_ ones. Hacks like what the cadence_ttc driver is
trying to do result in very poor timekeeping.

So I'm sort of on the fence about this patch.

Thomas: Any other thoughts?

thanks
-john