2018-04-04 01:16:55 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2012-09-13 18:51:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Fujitsu. All rights reserved.
|
|
|
|
* Written by Miao Xie <miaox@cn.fujitsu.com>
|
|
|
|
*/
|
|
|
|
|
2018-04-04 01:16:55 +08:00
|
|
|
#ifndef BTRFS_MATH_H
|
|
|
|
#define BTRFS_MATH_H
|
2012-09-13 18:51:36 +08:00
|
|
|
|
|
|
|
#include <asm/div64.h>
|
|
|
|
|
|
|
|
static inline u64 div_factor(u64 num, int factor)
|
|
|
|
{
|
|
|
|
if (factor == 10)
|
|
|
|
return num;
|
|
|
|
num *= factor;
|
2015-01-17 00:21:12 +08:00
|
|
|
return div_u64(num, 10);
|
2012-09-13 18:51:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 div_factor_fine(u64 num, int factor)
|
|
|
|
{
|
|
|
|
if (factor == 100)
|
|
|
|
return num;
|
|
|
|
num *= factor;
|
2015-01-17 00:21:12 +08:00
|
|
|
return div_u64(num, 100);
|
2012-09-13 18:51:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|