linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocks_calc_mult_shift(): rename minsec argument according to actual usage
@ 2011-01-11 17:18 Nicolas Pitre
  2011-01-11 17:24 ` john stultz
  2011-01-12 11:30 ` [tip:timers/urgent] time: Rename misnamed minsec argument of clocks_calc_mult_shift() tip-bot for Nicolas Pitre
  0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Pitre @ 2011-01-11 17:18 UTC (permalink / raw)
  To: John Stultz; +Cc: lkml

The minsec argument to clocks_calc_mult_shift() is misnamed. It is used 
to clamp the magnitude of the mult factor so that a multiplication with 
any value in the given range won't overflow a 64 bit result.  Let's 
rename it to match the actual usage.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index c18d7ef..8588abc 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -113,7 +113,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * @shift:	pointer to shift variable
  * @from:	frequency to convert from
  * @to:		frequency to convert to
- * @minsec:	guaranteed runtime conversion range in seconds
+ * @maxsec:	guaranteed runtime conversion range in seconds
  *
  * The function evaluates the shift/mult pair for the scaled math
  * operations of clocksources and clockevents.
@@ -122,7 +122,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * NSEC_PER_SEC == 1GHz and @from is the counter frequency. For clock
  * event @to is the counter frequency and @from is NSEC_PER_SEC.
  *
- * The @minsec conversion range argument controls the time frame in
+ * The @maxsec conversion range argument controls the time frame in
  * seconds which must be covered by the runtime conversion with the
  * calculated mult and shift factors. This guarantees that no 64bit
  * overflow happens when the input value of the conversion is
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * factors.
  */
 void
-clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
+clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
 {
 	u64 tmp;
 	u32 sft, sftacc= 32;
@@ -140,7 +140,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
 	 * Calculate the shift factor which is limiting the conversion
 	 * range:
 	 */
-	tmp = ((u64)minsec * from) >> 32;
+	tmp = ((u64)maxsec * from) >> 32;
 	while (tmp) {
 		tmp >>=1;
 		sftacc--;

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

* Re: [PATCH] clocks_calc_mult_shift(): rename minsec argument according to actual usage
  2011-01-11 17:18 [PATCH] clocks_calc_mult_shift(): rename minsec argument according to actual usage Nicolas Pitre
@ 2011-01-11 17:24 ` john stultz
  2011-01-12 11:30 ` [tip:timers/urgent] time: Rename misnamed minsec argument of clocks_calc_mult_shift() tip-bot for Nicolas Pitre
  1 sibling, 0 replies; 3+ messages in thread
From: john stultz @ 2011-01-11 17:24 UTC (permalink / raw)
  To: Nicolas Pitre, Thomas Gleixner; +Cc: lkml

On Tue, 2011-01-11 at 12:18 -0500, Nicolas Pitre wrote:
> The minsec argument to clocks_calc_mult_shift() is misnamed. It is used 
> to clamp the magnitude of the mult factor so that a multiplication with 
> any value in the given range won't overflow a 64 bit result.  Let's 
> rename it to match the actual usage.
> 
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>

Acked-by: John Stultz <johnstul@us.ibm.com>

Thomas, mind picking this up for 2.6.38?

thanks
-john

> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> index c18d7ef..8588abc 100644
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -113,7 +113,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
>   * @shift:	pointer to shift variable
>   * @from:	frequency to convert from
>   * @to:		frequency to convert to
> - * @minsec:	guaranteed runtime conversion range in seconds
> + * @maxsec:	guaranteed runtime conversion range in seconds
>   *
>   * The function evaluates the shift/mult pair for the scaled math
>   * operations of clocksources and clockevents.
> @@ -122,7 +122,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
>   * NSEC_PER_SEC == 1GHz and @from is the counter frequency. For clock
>   * event @to is the counter frequency and @from is NSEC_PER_SEC.
>   *
> - * The @minsec conversion range argument controls the time frame in
> + * The @maxsec conversion range argument controls the time frame in
>   * seconds which must be covered by the runtime conversion with the
>   * calculated mult and shift factors. This guarantees that no 64bit
>   * overflow happens when the input value of the conversion is
> @@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
>   * factors.
>   */
>  void
> -clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
> +clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
>  {
>  	u64 tmp;
>  	u32 sft, sftacc= 32;
> @@ -140,7 +140,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
>  	 * Calculate the shift factor which is limiting the conversion
>  	 * range:
>  	 */
> -	tmp = ((u64)minsec * from) >> 32;
> +	tmp = ((u64)maxsec * from) >> 32;
>  	while (tmp) {
>  		tmp >>=1;
>  		sftacc--;



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

* [tip:timers/urgent] time: Rename misnamed minsec argument of clocks_calc_mult_shift()
  2011-01-11 17:18 [PATCH] clocks_calc_mult_shift(): rename minsec argument according to actual usage Nicolas Pitre
  2011-01-11 17:24 ` john stultz
@ 2011-01-12 11:30 ` tip-bot for Nicolas Pitre
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Nicolas Pitre @ 2011-01-12 11:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, johnstul, nicolas.pitre, tglx, nico

Commit-ID:  5fdade95f26372154459347dfb9f60721d22cfc7
Gitweb:     http://git.kernel.org/tip/5fdade95f26372154459347dfb9f60721d22cfc7
Author:     Nicolas Pitre <nico@fluxnic.net>
AuthorDate: Tue, 11 Jan 2011 12:18:12 -0500
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 12 Jan 2011 12:23:12 +0100

time: Rename misnamed minsec argument of clocks_calc_mult_shift()

The minsec argument to clocks_calc_mult_shift() is misnamed. It is used 
to clamp the magnitude of the mult factor so that a multiplication with 
any value in the given range won't overflow a 64 bit result.  Let's 
rename it to match the actual usage.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <alpine.LFD.2.00.1101111207140.17086@xanadu.home>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/time/clocksource.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index c18d7ef..8588abc 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -113,7 +113,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * @shift:	pointer to shift variable
  * @from:	frequency to convert from
  * @to:		frequency to convert to
- * @minsec:	guaranteed runtime conversion range in seconds
+ * @maxsec:	guaranteed runtime conversion range in seconds
  *
  * The function evaluates the shift/mult pair for the scaled math
  * operations of clocksources and clockevents.
@@ -122,7 +122,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * NSEC_PER_SEC == 1GHz and @from is the counter frequency. For clock
  * event @to is the counter frequency and @from is NSEC_PER_SEC.
  *
- * The @minsec conversion range argument controls the time frame in
+ * The @maxsec conversion range argument controls the time frame in
  * seconds which must be covered by the runtime conversion with the
  * calculated mult and shift factors. This guarantees that no 64bit
  * overflow happens when the input value of the conversion is
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(timecounter_cyc2time);
  * factors.
  */
 void
-clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
+clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
 {
 	u64 tmp;
 	u32 sft, sftacc= 32;
@@ -140,7 +140,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)
 	 * Calculate the shift factor which is limiting the conversion
 	 * range:
 	 */
-	tmp = ((u64)minsec * from) >> 32;
+	tmp = ((u64)maxsec * from) >> 32;
 	while (tmp) {
 		tmp >>=1;
 		sftacc--;

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

end of thread, other threads:[~2011-01-12 11:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-11 17:18 [PATCH] clocks_calc_mult_shift(): rename minsec argument according to actual usage Nicolas Pitre
2011-01-11 17:24 ` john stultz
2011-01-12 11:30 ` [tip:timers/urgent] time: Rename misnamed minsec argument of clocks_calc_mult_shift() tip-bot for Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).