All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] PM / devfreq: exynos-ppmu: fix load_count calculation
@ 2015-08-17 14:48 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-08-17 14:48 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi
  Cc: Kyungmin Park, Krzysztof Kozlowski, linux-samsung-soc,
	kernel-janitors

"pmcnt_high & 0xff" is a u32 so we shifting it 32 spaces is zero.  GCC
catches this bug:

drivers/devfreq/event/exynos-ppmu.c: In function ‘exynos_ppmu_v2_get_event’:
drivers/devfreq/event/exynos-ppmu.c:322:3: warning: left shift count >= width of type
   load_count = (u64)((pmcnt_high & 0xff) << 32) + (u64)pmcnt_low;

Fixes: 3d87b02281a2 ('PM / devfreq: exynos-ppmu: Add the support of PPMUv2 for Exynos5433')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c
index f9901f5..daf2cdb 100644
--- a/drivers/devfreq/event/exynos-ppmu.c
+++ b/drivers/devfreq/event/exynos-ppmu.c
@@ -319,7 +319,7 @@ static int exynos_ppmu_v2_get_event(struct devfreq_event_dev *edev,
 	case PPMU_PMNCNT3:
 		pmcnt_high = __raw_readl(info->ppmu.base + PPMU_V2_PMCNT3_HIGH);
 		pmcnt_low = __raw_readl(info->ppmu.base + PPMU_V2_PMCNT3_LOW);
-		load_count = (u64)((pmcnt_high & 0xff) << 32) + (u64)pmcnt_low;
+		load_count = (((u64)pmcnt_high & 0xff) << 32) + pmcnt_low;
 		break;
 	}
 	edata->load_count = load_count;

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* Re: [patch] PM / devfreq: exynos-ppmu: fix load_count calculation
  2015-08-17 14:48 ` Dan Carpenter
@ 2015-08-18  0:52 ` MyungJoo Ham
  -1 siblings, 0 replies; 4+ messages in thread
From: MyungJoo Ham @ 2015-08-18  0:52 UTC (permalink / raw)
  To: Dan Carpenter, 최찬우
  Cc: 박경민,
	크쉬시토프,
	linux-samsung-soc@vger.kernel.org,
	kernel-janitors@vger.kernel.org, linux-pm

> "pmcnt_high & 0xff" is a u32 so we shifting it 32 spaces is zero.  GCC
> catches this bug:
> 
> drivers/devfreq/event/exynos-ppmu.c: In function ‘exynos_ppmu_v2_get_event’:
> drivers/devfreq/event/exynos-ppmu.c:322:3: warning: left shift count >= width of type
>    load_count = (u64)((pmcnt_high & 0xff) << 32) + (u64)pmcnt_low;
> 
> Fixes: 3d87b02281a2 ('PM / devfreq: exynos-ppmu: Add the support of PPMUv2 for Exynos5433')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

This patch has been waiting in devfreq tree for some days.
It will be sent with the next pull request.

https://git.kernel.org/cgit/linux/kernel/git/mzx/devfreq.git/commit/?h=for-rafael&id=8e29abebbdb32a30d87a58201ac9b77f8a87fd84

> 
> diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c
> index f9901f5..daf2cdb 100644
> --- a/drivers/devfreq/event/exynos-ppmu.c
> +++ b/drivers/devfreq/event/exynos-ppmu.c
> @@ -319,7 +319,7 @@ static int exynos_ppmu_v2_get_event(struct devfreq_event_dev *edev,
>  	case PPMU_PMNCNT3:
>  		pmcnt_high = __raw_readl(info->ppmu.base + PPMU_V2_PMCNT3_HIGH);
>  		pmcnt_low = __raw_readl(info->ppmu.base + PPMU_V2_PMCNT3_LOW);
> -		load_count = (u64)((pmcnt_high & 0xff) << 32) + (u64)pmcnt_low;
> +		load_count = (((u64)pmcnt_high & 0xff) << 32) + pmcnt_low;
>  		break;
>  	}
>  	edata->load_count = load_count;
> 

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

end of thread, other threads:[~2015-08-18  0:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 14:48 [patch] PM / devfreq: exynos-ppmu: fix load_count calculation Dan Carpenter
2015-08-17 14:48 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2015-08-18  0:52 MyungJoo Ham
2015-08-18  0:52 ` MyungJoo Ham

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.