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