aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/hid-input.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 76e1f64e9765..30af8760174b 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -162,8 +162,8 @@ static int hidinput_setkeycode(struct input_dev *dev,
162 * 162 *
163 * as seen in the HID specification v1.11 6.2.2.7 Global Items. 163 * as seen in the HID specification v1.11 6.2.2.7 Global Items.
164 * 164 *
165 * Only exponent 1 length units are processed. Centimeters are converted to 165 * Only exponent 1 length units are processed. Centimeters and inches are
166 * inches. Degrees are converted to radians. 166 * converted to millimeters. Degrees are converted to radians.
167 */ 167 */
168static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) 168static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
169{ 169{
@@ -184,13 +184,16 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
184 */ 184 */
185 if (code == ABS_X || code == ABS_Y || code == ABS_Z) { 185 if (code == ABS_X || code == ABS_Y || code == ABS_Z) {
186 if (field->unit == 0x11) { /* If centimeters */ 186 if (field->unit == 0x11) { /* If centimeters */
187 /* Convert to inches */ 187 /* Convert to millimeters */
188 prev = logical_extents; 188 unit_exponent += 1;
189 logical_extents *= 254; 189 } else if (field->unit == 0x13) { /* If inches */
190 if (logical_extents < prev) 190 /* Convert to millimeters */
191 prev = physical_extents;
192 physical_extents *= 254;
193 if (physical_extents < prev)
191 return 0; 194 return 0;
192 unit_exponent += 2; 195 unit_exponent -= 1;
193 } else if (field->unit != 0x13) { /* If not inches */ 196 } else {
194 return 0; 197 return 0;
195 } 198 }
196 } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { 199 } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) {