This is taken from linux/include/uapi/linux/const.h to match the driver behaviour when reading sensor values.
Signed-off-by: Titus Rwantare <[email protected]> --- include/qemu/osdep.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 1ec5b42230..a6a40ab8df 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -522,6 +522,20 @@ void QEMU_ERROR("code path is reachable") #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #endif +#ifndef DIV_ROUND_CLOSEST +#define DIV_ROUND_CLOSEST(n, d) \ +({ \ + typeof(n) __n = n; \ + typeof(d) __d = d; \ + (((typeof(n))-1) > 0 || \ + ((typeof(d))-1) > 0 || \ + (((__n) > 0) == ((__d) > 0))) ? \ + (((__n) + ((__d) / 2)) / (__d)) : \ + (((__n) - ((__d) / 2)) / (__d)); \ +}) +#endif + + /* * &(x)[0] is always a pointer - if it's same type as x then the argument is a * pointer, not an array. -- 2.55.0.rc2.803.g1fd1e6609c-goog
