diff mbox

[3/5] intel_pstate: Fix fixed point rounding macro

Message ID 1399579047-5792-4-git-send-email-dirk.j.brandewie@intel.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

dirk.brandewie@gmail.com May 8, 2014, 7:57 p.m. UTC
From: Dirk Brandewie <dirk.j.brandewie@intel.com>

Change the FP_ROUNDUP macro to add 0.5 in fixed point representation
instead of 1.0

Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
---
 drivers/cpufreq/intel_pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rafael J. Wysocki May 12, 2014, 12:17 p.m. UTC | #1
On Thursday, May 08, 2014 12:57:25 PM dirk.brandewie@gmail.com wrote:
> From: Dirk Brandewie <dirk.j.brandewie@intel.com>
> 
> Change the FP_ROUNDUP macro to add 0.5 in fixed point representation
> instead of 1.0

It would be good to say why exactly it is a problem too.  I guess it overflows
sometimes, right?

> Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index eab8ccf..bb20881 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -43,7 +43,7 @@
>  #define FRAC_BITS 6
>  #define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
>  #define fp_toint(X) ((X) >> FRAC_BITS)
> -#define FP_ROUNDUP(X) ((X) += 1 << FRAC_BITS)
> +#define FP_ROUNDUP(X) ((X) += 1 << (FRAC_BITS-1))
>  
>  static inline int32_t mul_fp(int32_t x, int32_t y)
>  {
>
diff mbox

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index eab8ccf..bb20881 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -43,7 +43,7 @@ 
 #define FRAC_BITS 6
 #define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
 #define fp_toint(X) ((X) >> FRAC_BITS)
-#define FP_ROUNDUP(X) ((X) += 1 << FRAC_BITS)
+#define FP_ROUNDUP(X) ((X) += 1 << (FRAC_BITS-1))
 
 static inline int32_t mul_fp(int32_t x, int32_t y)
 {