diff options
author | Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> | 2011-08-04 18:00:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-08-08 15:05:34 -0400 |
commit | 3ca15c4486beb113700cda44e32109cf0d97528b (patch) | |
tree | 099ee5fff1cd27dfbc7fe070cfb9bb4312355936 | |
parent | f704648281831fbb8a4ca1acbe18cb84bc0267c8 (diff) |
zcache: Use div_u64 for 64-bit division
xv_get_total_size_bytes returns a u64 value and it's used in a division.
This causes build failures in 32-bit architectures, as reported by Randy
Dunlap.
Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/zcache/zcache-main.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index 66469acce58e..2c41c4465e14 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/atomic.h> | 30 | #include <linux/atomic.h> |
31 | #include <linux/math64.h> | ||
31 | #include "tmem.h" | 32 | #include "tmem.h" |
32 | 33 | ||
33 | #include "../zram/xvmalloc.h" /* if built in drivers/staging */ | 34 | #include "../zram/xvmalloc.h" /* if built in drivers/staging */ |
@@ -1162,6 +1163,7 @@ static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph, | |||
1162 | uint16_t client_id = get_client_id_from_client(cli); | 1163 | uint16_t client_id = get_client_id_from_client(cli); |
1163 | unsigned long zv_mean_zsize; | 1164 | unsigned long zv_mean_zsize; |
1164 | unsigned long curr_pers_pampd_count; | 1165 | unsigned long curr_pers_pampd_count; |
1166 | u64 total_zsize; | ||
1165 | 1167 | ||
1166 | if (eph) { | 1168 | if (eph) { |
1167 | ret = zcache_compress(page, &cdata, &clen); | 1169 | ret = zcache_compress(page, &cdata, &clen); |
@@ -1194,8 +1196,9 @@ static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph, | |||
1194 | } | 1196 | } |
1195 | /* reject if mean compression is too poor */ | 1197 | /* reject if mean compression is too poor */ |
1196 | if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) { | 1198 | if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) { |
1197 | zv_mean_zsize = xv_get_total_size_bytes(cli->xvpool) / | 1199 | total_zsize = xv_get_total_size_bytes(cli->xvpool); |
1198 | curr_pers_pampd_count; | 1200 | zv_mean_zsize = div_u64(total_zsize, |
1201 | curr_pers_pampd_count); | ||
1199 | if (zv_mean_zsize > zv_max_mean_zsize) { | 1202 | if (zv_mean_zsize > zv_max_mean_zsize) { |
1200 | zcache_mean_compress_poor++; | 1203 | zcache_mean_compress_poor++; |
1201 | goto out; | 1204 | goto out; |