mirror of
https://github.com/openvswitch/ovs
synced 2025-10-23 14:57:06 +00:00
With the latest change of separating vports into their own modules, it is necessary to export all public functions in linux/compat/ directory. Also, we should prefix functions which replace the upstream ones with 'rpl_' and others with 'ovs_'. This will prevent the linker error when vport modules use those functions in the future. e.g., the to be merged vport-stt module will use the flex_array_* functions which are not currently exported. Co-authored-by: Tuan Nguyen <tuan.nguyen@veriksystems.com> Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
28 lines
504 B
C
28 lines
504 B
C
#include <linux/kernel.h>
|
|
#include <asm/div64.h>
|
|
#include <linux/module.h>
|
|
#include <linux/reciprocal_div.h>
|
|
|
|
/*
|
|
* For a description of the algorithm please have a look at
|
|
* include/linux/reciprocal_div.h
|
|
*/
|
|
|
|
struct reciprocal_value rpl_reciprocal_value(u32 d)
|
|
{
|
|
struct reciprocal_value R;
|
|
u64 m;
|
|
int l;
|
|
|
|
l = fls(d - 1);
|
|
m = ((1ULL << 32) * ((1ULL << l) - d));
|
|
do_div(m, d);
|
|
++m;
|
|
R.m = (u32)m;
|
|
R.sh1 = min(l, 1);
|
|
R.sh2 = max(l - 1, 0);
|
|
|
|
return R;
|
|
}
|
|
EXPORT_SYMBOL_GPL(rpl_reciprocal_value);
|