提交 ccdd6994 编写于 作者: B Benjamin Tissoires 提交者: Jiri Kosina

HID: round return value of hidinput_calc_abs_res

hidinput_calc_abs_res should return the closest int in the division
instead of the floor.
On a device with a logical_max of 3008 and a physical_max of 255mm,
previous implementation gave a resolution of 11 instead of 12.
With 11, user-space computes a physical size of 273.5mm and the
round_closest results gives 250.6mm.
The old implementation introduced an error of 2cm in this example.
Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@gmail.com>
Acked-by: NJiri Kosina <jkosina@suse.cz>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 37cf6e6f
...@@ -287,7 +287,7 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) ...@@ -287,7 +287,7 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
} }
/* Calculate resolution */ /* Calculate resolution */
return logical_extents / physical_extents; return DIV_ROUND_CLOSEST(logical_extents, physical_extents);
} }
EXPORT_SYMBOL_GPL(hidinput_calc_abs_res); EXPORT_SYMBOL_GPL(hidinput_calc_abs_res);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册