aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>2012-11-14 10:59:14 -0500
committerJiri Kosina <jkosina@suse.cz>2012-11-15 04:06:56 -0500
commitccdd699411b77c463022ebac311eb4a06ca56db4 (patch)
tree3103c884cc1f4f89969c5889485e032742f40c3e /drivers/hid/hid-input.c
parent37cf6e6fc34e2fca4e7c565697e7cd5c317bc316 (diff)
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: Benjamin Tissoires <benjamin.tissoires@gmail.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index d1ec571bdb3b..1b0adc3f7803 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -287,7 +287,7 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
287 } 287 }
288 288
289 /* Calculate resolution */ 289 /* Calculate resolution */
290 return logical_extents / physical_extents; 290 return DIV_ROUND_CLOSEST(logical_extents, physical_extents);
291} 291}
292EXPORT_SYMBOL_GPL(hidinput_calc_abs_res); 292EXPORT_SYMBOL_GPL(hidinput_calc_abs_res);
293 293