Commit c7f22f7a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: fix up formatting issues with aiptek driver

parent d9e08e98
...@@ -410,28 +410,22 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -410,28 +410,22 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
switch (urb->status) { switch (urb->status) {
case 0: case 0:
{
/* Success */ /* Success */
}
break; break;
case -ECONNRESET: case -ECONNRESET:
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
{
/* This urb is terminated, clean up */ /* This urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d", dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status); __FUNCTION__, urb->status);
return; return;
}
default: default:
{
dbg("%s - nonzero urb status received: %d", dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status); __FUNCTION__, urb->status);
goto exit; goto exit;
} }
}
/* See if we are in a delay loop -- throw out report if true. /* See if we are in a delay loop -- throw out report if true.
*/ */
...@@ -466,20 +460,16 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -466,20 +460,16 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
*/ */
jitterable = data[5] & 0x07; jitterable = data[5] & 0x07;
left = (data[5] & aiptek->curSetting. left = (data[5] & aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
mouseButtonLeft) != 0 ? 1 : 0; right = (data[5] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
right = (data[5] & aiptek->curSetting. middle = (data[5] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
mouseButtonRight) != 0 ? 1 : 0;
middle = (data[5] & aiptek->curSetting.
mouseButtonMiddle) != 0 ? 1 : 0;
input_report_key(inputdev, BTN_LEFT, left); input_report_key(inputdev, BTN_LEFT, left);
input_report_key(inputdev, BTN_MIDDLE, middle); input_report_key(inputdev, BTN_MIDDLE, middle);
input_report_key(inputdev, BTN_RIGHT, right); input_report_key(inputdev, BTN_RIGHT, right);
input_report_rel(inputdev, REL_X, x); input_report_rel(inputdev, REL_X, x);
input_report_rel(inputdev, REL_Y, y); input_report_rel(inputdev, REL_Y, y);
input_report_rel(inputdev, REL_MISC, input_report_rel(inputdev, REL_MISC, 1 | AIPTEK_REPORT_TOOL_UNKNOWN);
1 | AIPTEK_REPORT_TOOL_UNKNOWN);
/* Wheel support is in the form of a single-event /* Wheel support is in the form of a single-event
* firing. * firing.
...@@ -496,12 +486,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -496,12 +486,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
* absolute coordinates. * absolute coordinates.
*/ */
else if (data[0] == 2) { else if (data[0] == 2) {
if (aiptek->curSetting.coordinateMode == if (aiptek->curSetting.coordinateMode == AIPTEK_COORDINATE_RELATIVE_MODE) {
AIPTEK_COORDINATE_RELATIVE_MODE) { aiptek->diagnostic = AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
aiptek->diagnostic = } else if (!AIPTEK_POINTER_ALLOW_STYLUS_MODE
AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
} else
if (!AIPTEK_POINTER_ALLOW_STYLUS_MODE
(aiptek->curSetting.pointerMode)) { (aiptek->curSetting.pointerMode)) {
aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
} else { } else {
...@@ -519,10 +506,8 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -519,10 +506,8 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
*/ */
jitterable = data[5] & 0x18; jitterable = data[5] & 0x18;
bs = (data[5] & aiptek->curSetting. bs = (data[5] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0;
stylusButtonLower) != 0 ? 1 : 0; pck = (data[5] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0;
pck = (data[5] & aiptek->curSetting.
stylusButtonUpper) != 0 ? 1 : 0;
/* dv indicates 'data valid' (e.g., the tablet is in sync /* dv indicates 'data valid' (e.g., the tablet is in sync
* and has delivered a "correct" report) We will ignore * and has delivered a "correct" report) We will ignore
...@@ -536,42 +521,30 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -536,42 +521,30 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
if (TOOL_BUTTON_FIRED if (TOOL_BUTTON_FIRED
(aiptek->curSetting.toolMode) == 0) { (aiptek->curSetting.toolMode) == 0) {
input_report_key(inputdev, input_report_key(inputdev,
TOOL_BUTTON(aiptek-> TOOL_BUTTON(aiptek->curSetting.toolMode),
curSetting.
toolMode),
1); 1);
aiptek->curSetting.toolMode |= aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
TOOL_BUTTON_FIRED_BIT;
} }
if (p != 0) { if (p != 0) {
input_report_abs(inputdev, ABS_X, x); input_report_abs(inputdev, ABS_X, x);
input_report_abs(inputdev, ABS_Y, y); input_report_abs(inputdev, ABS_Y, y);
input_report_abs(inputdev, ABS_PRESSURE, input_report_abs(inputdev, ABS_PRESSURE, z);
z);
input_report_key(inputdev, BTN_TOUCH, input_report_key(inputdev, BTN_TOUCH, tip);
tip); input_report_key(inputdev, BTN_STYLUS, bs);
input_report_key(inputdev, BTN_STYLUS, input_report_key(inputdev, BTN_STYLUS2, pck);
bs);
input_report_key(inputdev, BTN_STYLUS2,
pck);
if (aiptek->curSetting.xTilt != if (aiptek->curSetting.xTilt !=
AIPTEK_TILT_DISABLE) { AIPTEK_TILT_DISABLE) {
input_report_abs(inputdev, input_report_abs(inputdev,
ABS_TILT_X, ABS_TILT_X,
aiptek-> aiptek->curSetting.xTilt);
curSetting.
xTilt);
} }
if (aiptek->curSetting.yTilt != if (aiptek->curSetting.yTilt != AIPTEK_TILT_DISABLE) {
AIPTEK_TILT_DISABLE) {
input_report_abs(inputdev, input_report_abs(inputdev,
ABS_TILT_Y, ABS_TILT_Y,
aiptek-> aiptek->curSetting.yTilt);
curSetting.
yTilt);
} }
/* Wheel support is in the form of a single-event /* Wheel support is in the form of a single-event
...@@ -581,15 +554,11 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -581,15 +554,11 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
AIPTEK_WHEEL_DISABLE) { AIPTEK_WHEEL_DISABLE) {
input_report_abs(inputdev, input_report_abs(inputdev,
ABS_WHEEL, ABS_WHEEL,
aiptek-> aiptek->curSetting.wheel);
curSetting. aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
wheel);
aiptek->curSetting.wheel =
AIPTEK_WHEEL_DISABLE;
} }
} }
input_report_abs(inputdev, ABS_MISC, input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_STYLUS);
p | AIPTEK_REPORT_TOOL_STYLUS);
input_sync(inputdev); input_sync(inputdev);
} }
} }
...@@ -597,12 +566,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -597,12 +566,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
/* Report 3's come from the mouse in absolute mode. /* Report 3's come from the mouse in absolute mode.
*/ */
else if (data[0] == 3) { else if (data[0] == 3) {
if (aiptek->curSetting.coordinateMode == if (aiptek->curSetting.coordinateMode == AIPTEK_COORDINATE_RELATIVE_MODE) {
AIPTEK_COORDINATE_RELATIVE_MODE) { aiptek->diagnostic = AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
aiptek->diagnostic = } else if (!AIPTEK_POINTER_ALLOW_MOUSE_MODE
AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
} else
if (!AIPTEK_POINTER_ALLOW_MOUSE_MODE
(aiptek->curSetting.pointerMode)) { (aiptek->curSetting.pointerMode)) {
aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
} else { } else {
...@@ -614,12 +580,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -614,12 +580,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
p = (data[5] & 0x01) != 0 ? 1 : 0; p = (data[5] & 0x01) != 0 ? 1 : 0;
dv = (data[5] & 0x02) != 0 ? 1 : 0; dv = (data[5] & 0x02) != 0 ? 1 : 0;
left = (data[5] & aiptek->curSetting. left = (data[5] & aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
mouseButtonLeft) != 0 ? 1 : 0; right = (data[5] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
right = (data[5] & aiptek->curSetting. middle = (data[5] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
mouseButtonRight) != 0 ? 1 : 0;
middle = (data[5] & aiptek->curSetting.
mouseButtonMiddle) != 0 ? 1 : 0;
if (dv != 0) { if (dv != 0) {
/* If we've not already sent a tool_button_?? code, do /* If we've not already sent a tool_button_?? code, do
...@@ -629,41 +592,30 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -629,41 +592,30 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
if (TOOL_BUTTON_FIRED if (TOOL_BUTTON_FIRED
(aiptek->curSetting.toolMode) == 0) { (aiptek->curSetting.toolMode) == 0) {
input_report_key(inputdev, input_report_key(inputdev,
TOOL_BUTTON(aiptek-> TOOL_BUTTON(aiptek->curSetting.toolMode),
curSetting.
toolMode),
1); 1);
aiptek->curSetting.toolMode |= aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
TOOL_BUTTON_FIRED_BIT;
} }
if (p != 0) { if (p != 0) {
input_report_abs(inputdev, ABS_X, x); input_report_abs(inputdev, ABS_X, x);
input_report_abs(inputdev, ABS_Y, y); input_report_abs(inputdev, ABS_Y, y);
input_report_key(inputdev, BTN_LEFT, input_report_key(inputdev, BTN_LEFT, left);
left); input_report_key(inputdev, BTN_MIDDLE, middle);
input_report_key(inputdev, BTN_MIDDLE, input_report_key(inputdev, BTN_RIGHT, right);
middle);
input_report_key(inputdev, BTN_RIGHT,
right);
/* Wheel support is in the form of a single-event /* Wheel support is in the form of a single-event
* firing. * firing.
*/ */
if (aiptek->curSetting.wheel != if (aiptek->curSetting.wheel != AIPTEK_WHEEL_DISABLE) {
AIPTEK_WHEEL_DISABLE) {
input_report_abs(inputdev, input_report_abs(inputdev,
ABS_WHEEL, ABS_WHEEL,
aiptek-> aiptek->curSetting.wheel);
curSetting. aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
wheel);
aiptek->curSetting.wheel =
AIPTEK_WHEEL_DISABLE;
} }
} }
input_report_rel(inputdev, REL_MISC, input_report_rel(inputdev, REL_MISC, p | AIPTEK_REPORT_TOOL_MOUSE);
p | AIPTEK_REPORT_TOOL_MOUSE);
input_sync(inputdev); input_sync(inputdev);
} }
} }
...@@ -676,10 +628,8 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -676,10 +628,8 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
p = (data[1] & 0x01) != 0 ? 1 : 0; p = (data[1] & 0x01) != 0 ? 1 : 0;
dv = (data[1] & 0x02) != 0 ? 1 : 0; dv = (data[1] & 0x02) != 0 ? 1 : 0;
tip = (data[1] & 0x04) != 0 ? 1 : 0; tip = (data[1] & 0x04) != 0 ? 1 : 0;
bs = (data[1] & aiptek->curSetting.stylusButtonLower) != bs = (data[1] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0;
0 ? 1 : 0; pck = (data[1] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0;
pck = (data[1] & aiptek->curSetting.stylusButtonUpper) !=
0 ? 1 : 0;
macro = data[3]; macro = data[3];
z = le16_to_cpu(get_unaligned((__u16 *) (data + 4))); z = le16_to_cpu(get_unaligned((__u16 *) (data + 4)));
...@@ -693,10 +643,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -693,10 +643,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
*/ */
if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) { if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) {
input_report_key(inputdev, input_report_key(inputdev,
TOOL_BUTTON(aiptek->curSetting. TOOL_BUTTON(aiptek->curSetting.toolMode),
toolMode), 1); 1);
aiptek->curSetting.toolMode |= aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
TOOL_BUTTON_FIRED_BIT;
} }
if (p != 0) { if (p != 0) {
...@@ -730,12 +679,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -730,12 +679,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
p = (data[1] & 0x01) != 0 ? 1 : 0; p = (data[1] & 0x01) != 0 ? 1 : 0;
dv = (data[1] & 0x02) != 0 ? 1 : 0; dv = (data[1] & 0x02) != 0 ? 1 : 0;
left = (data[1]& aiptek->curSetting.mouseButtonLeft) left = (data[1]& aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
!= 0 ? 1 : 0; right = (data[1] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
right = (data[1] & aiptek->curSetting.mouseButtonRight) middle = (data[1] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
!= 0 ? 1 : 0;
middle = (data[1] & aiptek->curSetting.mouseButtonMiddle)
!= 0 ? 1 : 0;
macro = data[3]; macro = data[3];
if (dv != 0) { if (dv != 0) {
...@@ -747,10 +693,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -747,10 +693,9 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
*/ */
if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) { if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) {
input_report_key(inputdev, input_report_key(inputdev,
TOOL_BUTTON(aiptek->curSetting. TOOL_BUTTON(aiptek->curSetting.toolMode),
toolMode), 1); 1);
aiptek->curSetting.toolMode |= aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
TOOL_BUTTON_FIRED_BIT;
} }
if (p != 0) { if (p != 0) {
...@@ -835,7 +780,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) ...@@ -835,7 +780,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
} }
aiptek->previousJitterable = jitterable; aiptek->previousJitterable = jitterable;
exit: exit:
retval = usb_submit_urb(urb, GFP_ATOMIC); retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval != 0) { if (retval != 0) {
err("%s - usb_submit_urb failed with result %d", err("%s - usb_submit_urb failed with result %d",
...@@ -937,9 +882,8 @@ aiptek_command(struct aiptek *aiptek, unsigned char command, unsigned char data) ...@@ -937,9 +882,8 @@ aiptek_command(struct aiptek *aiptek, unsigned char command, unsigned char data)
u8 *buf; u8 *buf;
buf = kmalloc(sizeof_buf, GFP_KERNEL); buf = kmalloc(sizeof_buf, GFP_KERNEL);
if (!buf) { if (!buf)
return -ENOMEM; return -ENOMEM;
}
buf[0] = 2; buf[0] = 2;
buf[1] = command; buf[1] = command;
...@@ -967,9 +911,8 @@ aiptek_query(struct aiptek *aiptek, unsigned char command, unsigned char data) ...@@ -967,9 +911,8 @@ aiptek_query(struct aiptek *aiptek, unsigned char command, unsigned char data)
u8 *buf; u8 *buf;
buf = kmalloc(sizeof_buf, GFP_KERNEL); buf = kmalloc(sizeof_buf, GFP_KERNEL);
if (!buf) { if (!buf)
return -ENOMEM; return -ENOMEM;
}
buf[0] = 2; buf[0] = 2;
buf[1] = command; buf[1] = command;
...@@ -1001,46 +944,39 @@ static int aiptek_program_tablet(struct aiptek *aiptek) ...@@ -1001,46 +944,39 @@ static int aiptek_program_tablet(struct aiptek *aiptek)
{ {
int ret; int ret;
/* Execute Resolution500LPI */ /* Execute Resolution500LPI */
if ((ret = aiptek_command(aiptek, 0x18, 0x04)) < 0) { if ((ret = aiptek_command(aiptek, 0x18, 0x04)) < 0)
return ret; return ret;
}
/* Query getModelCode */ /* Query getModelCode */
if ((ret = aiptek_query(aiptek, 0x02, 0x00)) < 0) { if ((ret = aiptek_query(aiptek, 0x02, 0x00)) < 0)
return ret; return ret;
}
aiptek->features.modelCode = ret & 0xff; aiptek->features.modelCode = ret & 0xff;
/* Query getODMCode */ /* Query getODMCode */
if ((ret = aiptek_query(aiptek, 0x03, 0x00)) < 0) { if ((ret = aiptek_query(aiptek, 0x03, 0x00)) < 0)
return ret; return ret;
}
aiptek->features.odmCode = ret; aiptek->features.odmCode = ret;
/* Query getFirmwareCode */ /* Query getFirmwareCode */
if ((ret = aiptek_query(aiptek, 0x04, 0x00)) < 0) { if ((ret = aiptek_query(aiptek, 0x04, 0x00)) < 0)
return ret; return ret;
}
aiptek->features.firmwareCode = ret; aiptek->features.firmwareCode = ret;
/* Query getXextension */ /* Query getXextension */
if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) { if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0)
return ret; return ret;
}
aiptek->inputdev.absmin[ABS_X] = 0; aiptek->inputdev.absmin[ABS_X] = 0;
aiptek->inputdev.absmax[ABS_X] = ret - 1; aiptek->inputdev.absmax[ABS_X] = ret - 1;
/* Query getYextension */ /* Query getYextension */
if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) { if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0)
return ret; return ret;
}
aiptek->inputdev.absmin[ABS_Y] = 0; aiptek->inputdev.absmin[ABS_Y] = 0;
aiptek->inputdev.absmax[ABS_Y] = ret - 1; aiptek->inputdev.absmax[ABS_Y] = ret - 1;
/* Query getPressureLevels */ /* Query getPressureLevels */
if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) { if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0)
return ret; return ret;
}
aiptek->inputdev.absmin[ABS_PRESSURE] = 0; aiptek->inputdev.absmin[ABS_PRESSURE] = 0;
aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1;
...@@ -1061,20 +997,17 @@ static int aiptek_program_tablet(struct aiptek *aiptek) ...@@ -1061,20 +997,17 @@ static int aiptek_program_tablet(struct aiptek *aiptek)
} }
/* Enable the macro keys */ /* Enable the macro keys */
if ((ret = aiptek_command(aiptek, 0x11, 0x02)) < 0) { if ((ret = aiptek_command(aiptek, 0x11, 0x02)) < 0)
return ret; return ret;
}
#if 0 #if 0
/* Execute FilterOn */ /* Execute FilterOn */
if ((ret = aiptek_command(aiptek, 0x17, 0x00)) < 0) { if ((ret = aiptek_command(aiptek, 0x17, 0x00)) < 0)
return ret; return ret;
}
#endif #endif
/* Execute AutoGainOn */ /* Execute AutoGainOn */
if ((ret = aiptek_command(aiptek, 0x12, 0xff)) < 0) { if ((ret = aiptek_command(aiptek, 0x12, 0xff)) < 0)
return ret; return ret;
}
/* Reset the eventCount, so we track events from last (re)programming /* Reset the eventCount, so we track events from last (re)programming
*/ */
...@@ -1098,9 +1031,8 @@ static ssize_t show_tabletSize(struct device *dev, char *buf) ...@@ -1098,9 +1031,8 @@ static ssize_t show_tabletSize(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "%dx%d\n", return snprintf(buf, PAGE_SIZE, "%dx%d\n",
aiptek->inputdev.absmax[ABS_X] + 1, aiptek->inputdev.absmax[ABS_X] + 1,
...@@ -1122,9 +1054,8 @@ static ssize_t show_tabletProductId(struct device *dev, char *buf) ...@@ -1122,9 +1054,8 @@ static ssize_t show_tabletProductId(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "0x%04x\n", return snprintf(buf, PAGE_SIZE, "0x%04x\n",
aiptek->inputdev.id.product); aiptek->inputdev.id.product);
...@@ -1139,9 +1070,8 @@ static ssize_t show_tabletVendorId(struct device *dev, char *buf) ...@@ -1139,9 +1070,8 @@ static ssize_t show_tabletVendorId(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor);
} }
...@@ -1156,9 +1086,8 @@ static ssize_t show_tabletManufacturer(struct device *dev, char *buf) ...@@ -1156,9 +1086,8 @@ static ssize_t show_tabletManufacturer(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int retval; int retval;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->features.manuName); retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->features.manuName);
return retval; return retval;
...@@ -1174,9 +1103,8 @@ static ssize_t show_tabletProduct(struct device *dev, char *buf) ...@@ -1174,9 +1103,8 @@ static ssize_t show_tabletProduct(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int retval; int retval;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->features.prodName); retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->features.prodName);
return retval; return retval;
...@@ -1193,35 +1121,26 @@ static ssize_t show_tabletPointerMode(struct device *dev, char *buf) ...@@ -1193,35 +1121,26 @@ static ssize_t show_tabletPointerMode(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.pointerMode) { switch (aiptek->curSetting.pointerMode) {
case AIPTEK_POINTER_ONLY_STYLUS_MODE: case AIPTEK_POINTER_ONLY_STYLUS_MODE:
{
s = "stylus"; s = "stylus";
break; break;
}
case AIPTEK_POINTER_ONLY_MOUSE_MODE: case AIPTEK_POINTER_ONLY_MOUSE_MODE:
{
s = "mouse"; s = "mouse";
break; break;
}
case AIPTEK_POINTER_EITHER_MODE: case AIPTEK_POINTER_EITHER_MODE:
{
s = "either"; s = "either";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1229,9 +1148,8 @@ static ssize_t ...@@ -1229,9 +1148,8 @@ static ssize_t
store_tabletPointerMode(struct device *dev, const char *buf, size_t count) store_tabletPointerMode(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "stylus") == 0) { if (strcmp(buf, "stylus") == 0) {
aiptek->newSetting.pointerMode = aiptek->newSetting.pointerMode =
...@@ -1257,29 +1175,22 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, char *buf) ...@@ -1257,29 +1175,22 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.coordinateMode) { switch (aiptek->curSetting.coordinateMode) {
case AIPTEK_COORDINATE_ABSOLUTE_MODE: case AIPTEK_COORDINATE_ABSOLUTE_MODE:
{
s = "absolute"; s = "absolute";
break; break;
}
case AIPTEK_COORDINATE_RELATIVE_MODE: case AIPTEK_COORDINATE_RELATIVE_MODE:
{
s = "relative"; s = "relative";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1287,9 +1198,8 @@ static ssize_t ...@@ -1287,9 +1198,8 @@ static ssize_t
store_tabletCoordinateMode(struct device *dev, const char *buf, size_t count) store_tabletCoordinateMode(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "absolute") == 0) { if (strcmp(buf, "absolute") == 0) {
aiptek->newSetting.pointerMode = aiptek->newSetting.pointerMode =
...@@ -1314,59 +1224,42 @@ static ssize_t show_tabletToolMode(struct device *dev, char *buf) ...@@ -1314,59 +1224,42 @@ static ssize_t show_tabletToolMode(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (TOOL_BUTTON(aiptek->curSetting.toolMode)) { switch (TOOL_BUTTON(aiptek->curSetting.toolMode)) {
case AIPTEK_TOOL_BUTTON_MOUSE_MODE: case AIPTEK_TOOL_BUTTON_MOUSE_MODE:
{
s = "mouse"; s = "mouse";
break; break;
}
case AIPTEK_TOOL_BUTTON_ERASER_MODE: case AIPTEK_TOOL_BUTTON_ERASER_MODE:
{
s = "eraser"; s = "eraser";
break; break;
}
case AIPTEK_TOOL_BUTTON_PENCIL_MODE: case AIPTEK_TOOL_BUTTON_PENCIL_MODE:
{
s = "pencil"; s = "pencil";
break; break;
}
case AIPTEK_TOOL_BUTTON_PEN_MODE: case AIPTEK_TOOL_BUTTON_PEN_MODE:
{
s = "pen"; s = "pen";
break; break;
}
case AIPTEK_TOOL_BUTTON_BRUSH_MODE: case AIPTEK_TOOL_BUTTON_BRUSH_MODE:
{
s = "brush"; s = "brush";
break; break;
}
case AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE: case AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE:
{
s = "airbrush"; s = "airbrush";
break; break;
}
case AIPTEK_TOOL_BUTTON_LENS_MODE: case AIPTEK_TOOL_BUTTON_LENS_MODE:
{
s = "lens"; s = "lens";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1374,9 +1267,8 @@ static ssize_t ...@@ -1374,9 +1267,8 @@ static ssize_t
store_tabletToolMode(struct device *dev, const char *buf, size_t count) store_tabletToolMode(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "mouse") == 0) { if (strcmp(buf, "mouse") == 0) {
aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_MOUSE_MODE; aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_MOUSE_MODE;
...@@ -1409,9 +1301,8 @@ static ssize_t show_tabletXtilt(struct device *dev, char *buf) ...@@ -1409,9 +1301,8 @@ static ssize_t show_tabletXtilt(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) { if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return snprintf(buf, PAGE_SIZE, "disable\n");
...@@ -1426,9 +1317,9 @@ store_tabletXtilt(struct device *dev, const char *buf, size_t count) ...@@ -1426,9 +1317,9 @@ store_tabletXtilt(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int x; int x;
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "disable") == 0) { if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
...@@ -1452,9 +1343,8 @@ static ssize_t show_tabletYtilt(struct device *dev, char *buf) ...@@ -1452,9 +1343,8 @@ static ssize_t show_tabletYtilt(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) { if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return snprintf(buf, PAGE_SIZE, "disable\n");
...@@ -1469,9 +1359,9 @@ store_tabletYtilt(struct device *dev, const char *buf, size_t count) ...@@ -1469,9 +1359,9 @@ store_tabletYtilt(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int y; int y;
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "disable") == 0) { if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
...@@ -1495,9 +1385,8 @@ static ssize_t show_tabletJitterDelay(struct device *dev, char *buf) ...@@ -1495,9 +1385,8 @@ static ssize_t show_tabletJitterDelay(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay); return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay);
} }
...@@ -1506,9 +1395,9 @@ static ssize_t ...@@ -1506,9 +1395,9 @@ static ssize_t
store_tabletJitterDelay(struct device *dev, const char *buf, size_t count) store_tabletJitterDelay(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, 0, 10); aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, 0, 10);
return count; return count;
...@@ -1526,9 +1415,8 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, char *buf) ...@@ -1526,9 +1415,8 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "%d\n", return snprintf(buf, PAGE_SIZE, "%d\n",
aiptek->curSetting.programmableDelay); aiptek->curSetting.programmableDelay);
...@@ -1538,9 +1426,9 @@ static ssize_t ...@@ -1538,9 +1426,9 @@ static ssize_t
store_tabletProgrammableDelay(struct device *dev, const char *buf, size_t count) store_tabletProgrammableDelay(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, 0, 10); aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, 0, 10);
return count; return count;
...@@ -1558,9 +1446,8 @@ static ssize_t show_tabletInputDevice(struct device *dev, char *buf) ...@@ -1558,9 +1446,8 @@ static ssize_t show_tabletInputDevice(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "/dev/input/%s\n", return snprintf(buf, PAGE_SIZE, "/dev/input/%s\n",
aiptek->features.inputPath); aiptek->features.inputPath);
...@@ -1576,9 +1463,8 @@ static ssize_t show_tabletEventsReceived(struct device *dev, char *buf) ...@@ -1576,9 +1463,8 @@ static ssize_t show_tabletEventsReceived(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount); return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount);
} }
...@@ -1593,31 +1479,24 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, char *buf) ...@@ -1593,31 +1479,24 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *retMsg; char *retMsg;
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->diagnostic) { switch (aiptek->diagnostic) {
case AIPTEK_DIAGNOSTIC_NA: case AIPTEK_DIAGNOSTIC_NA:
{
retMsg = "no errors\n"; retMsg = "no errors\n";
break; break;
}
case AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE: case AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE:
{
retMsg = "Error: receiving relative reports\n"; retMsg = "Error: receiving relative reports\n";
break; break;
}
case AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE: case AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE:
{
retMsg = "Error: receiving absolute reports\n"; retMsg = "Error: receiving absolute reports\n";
break; break;
}
case AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED: case AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED:
{
if (aiptek->curSetting.pointerMode == if (aiptek->curSetting.pointerMode ==
AIPTEK_POINTER_ONLY_MOUSE_MODE) { AIPTEK_POINTER_ONLY_MOUSE_MODE) {
retMsg = "Error: receiving stylus reports\n"; retMsg = "Error: receiving stylus reports\n";
...@@ -1625,13 +1504,10 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, char *buf) ...@@ -1625,13 +1504,10 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, char *buf)
retMsg = "Error: receiving mouse reports\n"; retMsg = "Error: receiving mouse reports\n";
} }
break; break;
}
default: default:
{
return 0; return 0;
} }
}
return snprintf(buf, PAGE_SIZE, retMsg); return snprintf(buf, PAGE_SIZE, retMsg);
} }
...@@ -1646,29 +1522,22 @@ static ssize_t show_tabletStylusUpper(struct device *dev, char *buf) ...@@ -1646,29 +1522,22 @@ static ssize_t show_tabletStylusUpper(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.stylusButtonUpper) { switch (aiptek->curSetting.stylusButtonUpper) {
case AIPTEK_STYLUS_UPPER_BUTTON: case AIPTEK_STYLUS_UPPER_BUTTON:
{
s = "upper"; s = "upper";
break; break;
}
case AIPTEK_STYLUS_LOWER_BUTTON: case AIPTEK_STYLUS_LOWER_BUTTON:
{
s = "lower"; s = "lower";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1676,9 +1545,9 @@ static ssize_t ...@@ -1676,9 +1545,9 @@ static ssize_t
store_tabletStylusUpper(struct device *dev, const char *buf, size_t count) store_tabletStylusUpper(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "upper") == 0) { if (strcmp(buf, "upper") == 0) {
aiptek->newSetting.stylusButtonUpper = aiptek->newSetting.stylusButtonUpper =
...@@ -1703,29 +1572,22 @@ static ssize_t show_tabletStylusLower(struct device *dev, char *buf) ...@@ -1703,29 +1572,22 @@ static ssize_t show_tabletStylusLower(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.stylusButtonLower) { switch (aiptek->curSetting.stylusButtonLower) {
case AIPTEK_STYLUS_UPPER_BUTTON: case AIPTEK_STYLUS_UPPER_BUTTON:
{
s = "upper"; s = "upper";
break; break;
}
case AIPTEK_STYLUS_LOWER_BUTTON: case AIPTEK_STYLUS_LOWER_BUTTON:
{
s = "lower"; s = "lower";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1733,9 +1595,9 @@ static ssize_t ...@@ -1733,9 +1595,9 @@ static ssize_t
store_tabletStylusLower(struct device *dev, const char *buf, size_t count) store_tabletStylusLower(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "upper") == 0) { if (strcmp(buf, "upper") == 0) {
aiptek->newSetting.stylusButtonLower = aiptek->newSetting.stylusButtonLower =
...@@ -1760,35 +1622,26 @@ static ssize_t show_tabletMouseLeft(struct device *dev, char *buf) ...@@ -1760,35 +1622,26 @@ static ssize_t show_tabletMouseLeft(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.mouseButtonLeft) { switch (aiptek->curSetting.mouseButtonLeft) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
{
s = "left"; s = "left";
break; break;
}
case AIPTEK_MOUSE_MIDDLE_BUTTON: case AIPTEK_MOUSE_MIDDLE_BUTTON:
{
s = "middle"; s = "middle";
break; break;
}
case AIPTEK_MOUSE_RIGHT_BUTTON: case AIPTEK_MOUSE_RIGHT_BUTTON:
{
s = "right"; s = "right";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1796,9 +1649,9 @@ static ssize_t ...@@ -1796,9 +1649,9 @@ static ssize_t
store_tabletMouseLeft(struct device *dev, const char *buf, size_t count) store_tabletMouseLeft(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "left") == 0) { if (strcmp(buf, "left") == 0) {
aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON; aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON;
...@@ -1823,35 +1676,26 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, char *buf) ...@@ -1823,35 +1676,26 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.mouseButtonMiddle) { switch (aiptek->curSetting.mouseButtonMiddle) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
{
s = "left"; s = "left";
break; break;
}
case AIPTEK_MOUSE_MIDDLE_BUTTON: case AIPTEK_MOUSE_MIDDLE_BUTTON:
{
s = "middle"; s = "middle";
break; break;
}
case AIPTEK_MOUSE_RIGHT_BUTTON: case AIPTEK_MOUSE_RIGHT_BUTTON:
{
s = "right"; s = "right";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1859,9 +1703,9 @@ static ssize_t ...@@ -1859,9 +1703,9 @@ static ssize_t
store_tabletMouseMiddle(struct device *dev, const char *buf, size_t count) store_tabletMouseMiddle(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "left") == 0) { if (strcmp(buf, "left") == 0) {
aiptek->newSetting.mouseButtonMiddle = AIPTEK_MOUSE_LEFT_BUTTON; aiptek->newSetting.mouseButtonMiddle = AIPTEK_MOUSE_LEFT_BUTTON;
...@@ -1888,35 +1732,26 @@ static ssize_t show_tabletMouseRight(struct device *dev, char *buf) ...@@ -1888,35 +1732,26 @@ static ssize_t show_tabletMouseRight(struct device *dev, char *buf)
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
switch (aiptek->curSetting.mouseButtonRight) { switch (aiptek->curSetting.mouseButtonRight) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
{
s = "left"; s = "left";
break; break;
}
case AIPTEK_MOUSE_MIDDLE_BUTTON: case AIPTEK_MOUSE_MIDDLE_BUTTON:
{
s = "middle"; s = "middle";
break; break;
}
case AIPTEK_MOUSE_RIGHT_BUTTON: case AIPTEK_MOUSE_RIGHT_BUTTON:
{
s = "right"; s = "right";
break; break;
}
default: default:
{
s = "unknown"; s = "unknown";
break; break;
} }
}
return snprintf(buf, PAGE_SIZE, "%s\n", s); return snprintf(buf, PAGE_SIZE, "%s\n", s);
} }
...@@ -1924,9 +1759,9 @@ static ssize_t ...@@ -1924,9 +1759,9 @@ static ssize_t
store_tabletMouseRight(struct device *dev, const char *buf, size_t count) store_tabletMouseRight(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (strcmp(buf, "left") == 0) { if (strcmp(buf, "left") == 0) {
aiptek->newSetting.mouseButtonRight = AIPTEK_MOUSE_LEFT_BUTTON; aiptek->newSetting.mouseButtonRight = AIPTEK_MOUSE_LEFT_BUTTON;
...@@ -1950,9 +1785,9 @@ static DEVICE_ATTR(mouse_right, ...@@ -1950,9 +1785,9 @@ static DEVICE_ATTR(mouse_right,
static ssize_t show_tabletWheel(struct device *dev, char *buf) static ssize_t show_tabletWheel(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) { if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return snprintf(buf, PAGE_SIZE, "disable\n");
...@@ -1966,9 +1801,9 @@ static ssize_t ...@@ -1966,9 +1801,9 @@ static ssize_t
store_tabletWheel(struct device *dev, const char *buf, size_t count) store_tabletWheel(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
aiptek->newSetting.wheel = (int)simple_strtol(buf, 0, 10); aiptek->newSetting.wheel = (int)simple_strtol(buf, 0, 10);
return count; return count;
...@@ -1985,9 +1820,8 @@ static ssize_t show_tabletExecute(struct device *dev, char *buf) ...@@ -1985,9 +1820,8 @@ static ssize_t show_tabletExecute(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
/* There is nothing useful to display, so a one-line manual /* There is nothing useful to display, so a one-line manual
* is in order... * is in order...
...@@ -2000,18 +1834,18 @@ static ssize_t ...@@ -2000,18 +1834,18 @@ static ssize_t
store_tabletExecute(struct device *dev, const char *buf, size_t count) store_tabletExecute(struct device *dev, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) {
if (aiptek == NULL)
return 0; return 0;
}
/* We do not care what you write to this file. Merely the action /* We do not care what you write to this file. Merely the action
* of writing to this file triggers a tablet reprogramming. * of writing to this file triggers a tablet reprogramming.
*/ */
memcpy(&aiptek->curSetting, &aiptek->newSetting, memcpy(&aiptek->curSetting, &aiptek->newSetting,
sizeof(struct aiptek_settings)); sizeof(struct aiptek_settings));
if (aiptek_program_tablet(aiptek) < 0) { if (aiptek_program_tablet(aiptek) < 0)
return -EIO; return -EIO;
}
return count; return count;
} }
...@@ -2027,9 +1861,8 @@ static ssize_t show_tabletODMCode(struct device *dev, char *buf) ...@@ -2027,9 +1861,8 @@ static ssize_t show_tabletODMCode(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode); return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode);
} }
...@@ -2044,9 +1877,8 @@ static ssize_t show_tabletModelCode(struct device *dev, char *buf) ...@@ -2044,9 +1877,8 @@ static ssize_t show_tabletModelCode(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode); return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode);
} }
...@@ -2061,9 +1893,8 @@ static ssize_t show_firmwareCode(struct device *dev, char *buf) ...@@ -2061,9 +1893,8 @@ static ssize_t show_firmwareCode(struct device *dev, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL) { if (aiptek == NULL)
return 0; return 0;
}
return snprintf(buf, PAGE_SIZE, "%04x\n", return snprintf(buf, PAGE_SIZE, "%04x\n",
aiptek->features.firmwareCode); aiptek->features.firmwareCode);
...@@ -2175,9 +2006,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -2175,9 +2006,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
*/ */
speeds[0] = programmableDelay; speeds[0] = programmableDelay;
if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) { if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
}
memset(aiptek, 0, sizeof(struct aiptek)); memset(aiptek, 0, sizeof(struct aiptek));
aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
...@@ -2255,9 +2085,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -2255,9 +2085,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* Programming the tablet macro keys needs to be done with a for loop /* Programming the tablet macro keys needs to be done with a for loop
* as the keycodes are discontiguous. * as the keycodes are discontiguous.
*/ */
for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) { for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i)
set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); set_bit(macroKeyEvents[i], aiptek->inputdev.keybit);
}
/* Set up client data, pointers to open and close routines /* Set up client data, pointers to open and close routines
* for the input device. * for the input device.
...@@ -2273,9 +2102,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -2273,9 +2102,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
* & a tablet, and the inputX number actually will tell * & a tablet, and the inputX number actually will tell
* us something... * us something...
*/ */
if (usb_make_path(usbdev, path, 64) > 0) { if (usb_make_path(usbdev, path, 64) > 0)
sprintf(aiptek->features.usbPath, "%s/input0", path); sprintf(aiptek->features.usbPath, "%s/input0", path);
}
/* Program the input device coordinate capacities. We do not yet /* Program the input device coordinate capacities. We do not yet
* know what maximum X, Y, and Z values are, so we're putting fake * know what maximum X, Y, and Z values are, so we're putting fake
...@@ -2400,9 +2228,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -2400,9 +2228,8 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* Make sure the evdev module is loaded. Assuming evdev IS a module :-) /* Make sure the evdev module is loaded. Assuming evdev IS a module :-)
*/ */
if (request_module("evdev") != 0) { if (request_module("evdev") != 0)
info("aiptek: error loading 'evdev' module"); info("aiptek: error loading 'evdev' module");
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment