summaryrefslogtreecommitdiff
path: root/fs/btrfs/misc.h
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-08-21 19:54:28 +0300
committerDavid Sterba <dsterba@suse.com>2019-09-09 15:59:15 +0300
commit784352fe0bb4814bd969fb390c3d03486a5aaafa (patch)
tree50ef76b70d0aa12b35a214f1fa2dd1cc92996c0b /fs/btrfs/misc.h
parent602cbe91fb012a923a9fea880e600e004eb1543b (diff)
downloadlinux-784352fe0bb4814bd969fb390c3d03486a5aaafa.tar.xz
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.h17
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