提交 02fb6c38 编写于 作者: D Dmitry Torokhov

Input: aiptek - do not check for NULL in attribute methods

It makes no sense to check for NULL in attribute methods -
we do usb_set_intfdata before creating attributes and once
attributes have been removed we are guaranteed to not be
called.
Signed-off-by: NRene van Paassen <rene.vanpaassen@gmail.com>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 b087e1f3
...@@ -1006,9 +1006,6 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr ...@@ -1006,9 +1006,6 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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,
aiptek->inputdev->absmax[ABS_Y] + 1); aiptek->inputdev->absmax[ABS_Y] + 1);
...@@ -1031,9 +1028,6 @@ static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribut ...@@ -1031,9 +1028,6 @@ static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribut
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
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";
...@@ -1058,8 +1052,6 @@ static ssize_t ...@@ -1058,8 +1052,6 @@ static ssize_t
store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
if (strcmp(buf, "stylus") == 0) { if (strcmp(buf, "stylus") == 0) {
aiptek->newSetting.pointerMode = aiptek->newSetting.pointerMode =
...@@ -1085,9 +1077,6 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attri ...@@ -1085,9 +1077,6 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attri
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.coordinateMode) { switch (aiptek->curSetting.coordinateMode) {
case AIPTEK_COORDINATE_ABSOLUTE_MODE: case AIPTEK_COORDINATE_ABSOLUTE_MODE:
s = "absolute"; s = "absolute";
...@@ -1108,8 +1097,6 @@ static ssize_t ...@@ -1108,8 +1097,6 @@ static ssize_t
store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
if (strcmp(buf, "absolute") == 0) { if (strcmp(buf, "absolute") == 0) {
aiptek->newSetting.pointerMode = aiptek->newSetting.pointerMode =
...@@ -1134,9 +1121,6 @@ static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute * ...@@ -1134,9 +1121,6 @@ static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
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";
...@@ -1177,8 +1161,6 @@ static ssize_t ...@@ -1177,8 +1161,6 @@ static ssize_t
store_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) store_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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;
...@@ -1211,9 +1193,6 @@ static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *att ...@@ -1211,9 +1193,6 @@ static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *att
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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");
} else { } else {
...@@ -1228,9 +1207,6 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char ...@@ -1228,9 +1207,6 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int x; int x;
if (aiptek == NULL)
return 0;
if (strcmp(buf, "disable") == 0) { if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
} else { } else {
...@@ -1253,9 +1229,6 @@ static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *att ...@@ -1253,9 +1229,6 @@ static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *att
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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");
} else { } else {
...@@ -1270,9 +1243,6 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char ...@@ -1270,9 +1243,6 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
int y; int y;
if (aiptek == NULL)
return 0;
if (strcmp(buf, "disable") == 0) { if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
} else { } else {
...@@ -1295,9 +1265,6 @@ static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribut ...@@ -1295,9 +1265,6 @@ static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay); return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay);
} }
...@@ -1306,9 +1273,6 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const ...@@ -1306,9 +1273,6 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10);
return count; return count;
} }
...@@ -1325,9 +1289,6 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_at ...@@ -1325,9 +1289,6 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_at
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "%d\n", return snprintf(buf, PAGE_SIZE, "%d\n",
aiptek->curSetting.programmableDelay); aiptek->curSetting.programmableDelay);
} }
...@@ -1337,9 +1298,6 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, ...@@ -1337,9 +1298,6 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr,
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10);
return count; return count;
} }
...@@ -1356,9 +1314,6 @@ static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attri ...@@ -1356,9 +1314,6 @@ static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attri
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount); return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount);
} }
...@@ -1373,9 +1328,6 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_at ...@@ -1373,9 +1328,6 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_at
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *retMsg; char *retMsg;
if (aiptek == NULL)
return 0;
switch (aiptek->diagnostic) { switch (aiptek->diagnostic) {
case AIPTEK_DIAGNOSTIC_NA: case AIPTEK_DIAGNOSTIC_NA:
retMsg = "no errors\n"; retMsg = "no errors\n";
...@@ -1415,9 +1367,6 @@ static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribut ...@@ -1415,9 +1367,6 @@ static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribut
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.stylusButtonUpper) { switch (aiptek->curSetting.stylusButtonUpper) {
case AIPTEK_STYLUS_UPPER_BUTTON: case AIPTEK_STYLUS_UPPER_BUTTON:
s = "upper"; s = "upper";
...@@ -1439,9 +1388,6 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const ...@@ -1439,9 +1388,6 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
if (strcmp(buf, "upper") == 0) { if (strcmp(buf, "upper") == 0) {
aiptek->newSetting.stylusButtonUpper = aiptek->newSetting.stylusButtonUpper =
AIPTEK_STYLUS_UPPER_BUTTON; AIPTEK_STYLUS_UPPER_BUTTON;
...@@ -1465,9 +1411,6 @@ static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribut ...@@ -1465,9 +1411,6 @@ static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribut
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.stylusButtonLower) { switch (aiptek->curSetting.stylusButtonLower) {
case AIPTEK_STYLUS_UPPER_BUTTON: case AIPTEK_STYLUS_UPPER_BUTTON:
s = "upper"; s = "upper";
...@@ -1489,9 +1432,6 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const ...@@ -1489,9 +1432,6 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
if (strcmp(buf, "upper") == 0) { if (strcmp(buf, "upper") == 0) {
aiptek->newSetting.stylusButtonLower = aiptek->newSetting.stylusButtonLower =
AIPTEK_STYLUS_UPPER_BUTTON; AIPTEK_STYLUS_UPPER_BUTTON;
...@@ -1515,9 +1455,6 @@ static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute ...@@ -1515,9 +1455,6 @@ static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.mouseButtonLeft) { switch (aiptek->curSetting.mouseButtonLeft) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
s = "left"; s = "left";
...@@ -1543,9 +1480,6 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c ...@@ -1543,9 +1480,6 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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;
} else if (strcmp(buf, "middle") == 0) { } else if (strcmp(buf, "middle") == 0) {
...@@ -1569,9 +1503,6 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribut ...@@ -1569,9 +1503,6 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribut
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.mouseButtonMiddle) { switch (aiptek->curSetting.mouseButtonMiddle) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
s = "left"; s = "left";
...@@ -1597,9 +1528,6 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const ...@@ -1597,9 +1528,6 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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;
} else if (strcmp(buf, "middle") == 0) { } else if (strcmp(buf, "middle") == 0) {
...@@ -1625,9 +1553,6 @@ static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute ...@@ -1625,9 +1553,6 @@ static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
char *s; char *s;
if (aiptek == NULL)
return 0;
switch (aiptek->curSetting.mouseButtonRight) { switch (aiptek->curSetting.mouseButtonRight) {
case AIPTEK_MOUSE_LEFT_BUTTON: case AIPTEK_MOUSE_LEFT_BUTTON:
s = "left"; s = "left";
...@@ -1653,9 +1578,6 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const ...@@ -1653,9 +1578,6 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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;
} else if (strcmp(buf, "middle") == 0) { } else if (strcmp(buf, "middle") == 0) {
...@@ -1679,9 +1601,6 @@ static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *att ...@@ -1679,9 +1601,6 @@ static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *att
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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");
} else { } else {
...@@ -1695,9 +1614,6 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char ...@@ -1695,9 +1614,6 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10); aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10);
return count; return count;
} }
...@@ -1711,11 +1627,6 @@ static DEVICE_ATTR(wheel, ...@@ -1711,11 +1627,6 @@ static DEVICE_ATTR(wheel,
*/ */
static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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...
*/ */
...@@ -1728,9 +1639,6 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha ...@@ -1728,9 +1639,6 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
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.
*/ */
...@@ -1754,9 +1662,6 @@ static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *a ...@@ -1754,9 +1662,6 @@ static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *a
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode); return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode);
} }
...@@ -1770,9 +1675,6 @@ static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute ...@@ -1770,9 +1675,6 @@ static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode); return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode);
} }
...@@ -1786,9 +1688,6 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at ...@@ -1786,9 +1688,6 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek == NULL)
return 0;
return snprintf(buf, PAGE_SIZE, "%04x\n", return snprintf(buf, PAGE_SIZE, "%04x\n",
aiptek->features.firmwareCode); aiptek->features.firmwareCode);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册