blob: 75246f2f56baf32473ab992982923f678f3f229d [file] [log] [blame]
David Sterba9888c342018-04-03 19:16:55 +02001/* SPDX-License-Identifier: GPL-2.0 */
Miao Xie3fed40c2012-09-13 04:51:36 -06002/*
3 * Copyright (C) 2012 Fujitsu. All rights reserved.
4 * Written by Miao Xie <miaox@cn.fujitsu.com>
Miao Xie3fed40c2012-09-13 04:51:36 -06005 */
6
David Sterba9888c342018-04-03 19:16:55 +02007#ifndef BTRFS_MATH_H
8#define BTRFS_MATH_H
Miao Xie3fed40c2012-09-13 04:51:36 -06009
10#include <asm/div64.h>
11
12static inline u64 div_factor(u64 num, int factor)
13{
14 if (factor == 10)
15 return num;
16 num *= factor;
David Sterbaf8c269d2015-01-16 17:21:12 +010017 return div_u64(num, 10);
Miao Xie3fed40c2012-09-13 04:51:36 -060018}
19
20static inline u64 div_factor_fine(u64 num, int factor)
21{
22 if (factor == 100)
23 return num;
24 num *= factor;
David Sterbaf8c269d2015-01-16 17:21:12 +010025 return div_u64(num, 100);
Miao Xie3fed40c2012-09-13 04:51:36 -060026}
27
28#endif