Skip to content

Commit

Permalink
Input: gtco - use sign_extend32() for sign extension
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Martin Kepplinger authored and Dmitry Torokhov committed Jan 27, 2015
1 parent bb03bf3 commit 8d21282
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions drivers/input/tablet/gtco.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Scott Hill shill@gtcocalcomp.com
#include <asm/uaccess.h>
#include <asm/unaligned.h>
#include <asm/byteorder.h>

#include <linux/bitops.h>

#include <linux/usb/input.h>

Expand Down Expand Up @@ -614,7 +614,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
struct input_dev *inputdev;
int rc;
u32 val = 0;
s8 valsigned = 0;
char le_buffer[2];

inputdev = device->inputdevice;
Expand Down Expand Up @@ -665,20 +664,11 @@ static void gtco_urb_callback(struct urb *urbinfo)
/* Fall thru */
case 4:
/* Tilt */
input_report_abs(inputdev, ABS_TILT_X,
sign_extend32(device->buffer[6], 6));

/* Sign extend these 7 bit numbers. */
if (device->buffer[6] & 0x40)
device->buffer[6] |= 0x80;

if (device->buffer[7] & 0x40)
device->buffer[7] |= 0x80;


valsigned = (device->buffer[6]);
input_report_abs(inputdev, ABS_TILT_X, (s32)valsigned);

valsigned = (device->buffer[7]);
input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned);
input_report_abs(inputdev, ABS_TILT_Y,
sign_extend32(device->buffer[7], 6));

/* Fall thru */
case 2:
Expand Down

0 comments on commit 8d21282

Please sign in to comment.