summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/math.h
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-01-16 17:21:12 +0100
committerDavid Sterba <dsterba@suse.cz>2015-03-03 17:23:57 +0100
commitf8c269d7223f6b63cc5936eb191bc3b170d24342 (patch)
tree2e82cc23da9f436bbb6fde058b3321619f990db2 /fs/btrfs/math.h
parent351810c1d2aafa288af61844d877941d516fb031 (diff)
downloadlinux-stable-f8c269d7223f6b63cc5936eb191bc3b170d24342.tar.gz
linux-stable-f8c269d7223f6b63cc5936eb191bc3b170d24342.tar.bz2
linux-stable-f8c269d7223f6b63cc5936eb191bc3b170d24342.zip
btrfs: cleanup 64bit/32bit divs, compile time constants
Switch to div_u64 if the divisor is a numeric constant or sum of sizeof()s. We can remove a few instances of do_div that has the hidden semtantics of changing the 1st argument. Small power-of-two divisors are converted to bitshifts, large values are kept intact for clarity. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/math.h')
-rw-r--r--fs/btrfs/math.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/btrfs/math.h b/fs/btrfs/math.h
index b7816cefbd13..1b10a3cd1195 100644
--- a/fs/btrfs/math.h
+++ b/fs/btrfs/math.h
@@ -28,8 +28,7 @@ static inline u64 div_factor(u64 num, int factor)
if (factor == 10)
return num;
num *= factor;
- do_div(num, 10);
- return num;
+ return div_u64(num, 10);
}
static inline u64 div_factor_fine(u64 num, int factor)
@@ -37,8 +36,7 @@ static inline u64 div_factor_fine(u64 num, int factor)
if (factor == 100)
return num;
num *= factor;
- do_div(num, 100);
- return num;
+ return div_u64(num, 100);
}
#endif