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