diff options
author | David Sterba <dsterba@suse.com> | 2019-08-21 18:54:28 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-09-09 14:59:15 +0200 |
commit | 784352fe0bb4814bd969fb390c3d03486a5aaafa (patch) | |
tree | 50ef76b70d0aa12b35a214f1fa2dd1cc92996c0b /fs/btrfs/misc.h | |
parent | 602cbe91fb012a923a9fea880e600e004eb1543b (diff) | |
download | lwn-784352fe0bb4814bd969fb390c3d03486a5aaafa.tar.gz lwn-784352fe0bb4814bd969fb390c3d03486a5aaafa.zip |
btrfs: move math functions to misc.h
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/misc.h')
-rw-r--r-- | fs/btrfs/misc.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h index ef3901238ddd..7d564924dfeb 100644 --- a/fs/btrfs/misc.h +++ b/fs/btrfs/misc.h @@ -5,6 +5,7 @@ #include <linux/sched.h> #include <linux/wait.h> +#include <asm/div64.h> #define in_range(b, first, len) ((b) >= (first) && (b) < (first) + (len)) @@ -30,4 +31,20 @@ static inline void cond_wake_up_nomb(struct wait_queue_head *wq) wake_up(wq); } +static inline u64 div_factor(u64 num, int factor) +{ + if (factor == 10) + return num; + num *= factor; + return div_u64(num, 10); +} + +static inline u64 div_factor_fine(u64 num, int factor) +{ + if (factor == 100) + return num; + num *= factor; + return div_u64(num, 100); +} + #endif |