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