diff options
| author | Ping Cheng <pinglinux@gmail.com> | 2012-11-03 15:16:13 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-11-08 12:12:29 -0500 |
| commit | 3699dd7e16a9f68586a44e1efeb9708359f9c2a6 (patch) | |
| tree | 5d13ff90e9895c30a77a3d6cef95c49c6012c1b8 /drivers/input/tablet | |
| parent | 2be975c6d920de989ff5e4bc09ffe87e59d94662 (diff) | |
Input: wacom - clean up device type code
Use switch instead of if statement to verify device types
Signed-off-by: Ping Cheng <pinglinux@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/tablet')
| -rw-r--r-- | drivers/input/tablet/wacom_sys.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 858ad446de9..67442f40917 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
| @@ -386,23 +386,36 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
| 386 | if (usage == WCM_DESKTOP) { | 386 | if (usage == WCM_DESKTOP) { |
| 387 | if (finger) { | 387 | if (finger) { |
| 388 | features->device_type = BTN_TOOL_FINGER; | 388 | features->device_type = BTN_TOOL_FINGER; |
| 389 | if (features->type == TABLETPC2FG) { | 389 | |
| 390 | /* need to reset back */ | 390 | switch (features->type) { |
| 391 | case TABLETPC2FG: | ||
| 391 | features->pktlen = WACOM_PKGLEN_TPC2FG; | 392 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
| 392 | } | 393 | break; |
| 393 | 394 | ||
| 394 | if (features->type == MTSCREEN || features->type == WACOM_24HDT) | 395 | case MTSCREEN: |
| 396 | case WACOM_24HDT: | ||
| 395 | features->pktlen = WACOM_PKGLEN_MTOUCH; | 397 | features->pktlen = WACOM_PKGLEN_MTOUCH; |
| 398 | break; | ||
| 396 | 399 | ||
| 397 | if (features->type == BAMBOO_PT) { | 400 | case BAMBOO_PT: |
| 398 | /* need to reset back */ | ||
| 399 | features->pktlen = WACOM_PKGLEN_BBTOUCH; | 401 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
| 402 | break; | ||
| 403 | |||
| 404 | default: | ||
| 405 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | ||
| 406 | break; | ||
| 407 | } | ||
| 408 | |||
| 409 | switch (features->type) { | ||
| 410 | case BAMBOO_PT: | ||
| 400 | features->x_phy = | 411 | features->x_phy = |
| 401 | get_unaligned_le16(&report[i + 5]); | 412 | get_unaligned_le16(&report[i + 5]); |
| 402 | features->x_max = | 413 | features->x_max = |
| 403 | get_unaligned_le16(&report[i + 8]); | 414 | get_unaligned_le16(&report[i + 8]); |
| 404 | i += 15; | 415 | i += 15; |
| 405 | } else if (features->type == WACOM_24HDT) { | 416 | break; |
| 417 | |||
| 418 | case WACOM_24HDT: | ||
| 406 | features->x_max = | 419 | features->x_max = |
| 407 | get_unaligned_le16(&report[i + 3]); | 420 | get_unaligned_le16(&report[i + 3]); |
| 408 | features->x_phy = | 421 | features->x_phy = |
| @@ -410,7 +423,9 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
| 410 | features->unit = report[i - 1]; | 423 | features->unit = report[i - 1]; |
| 411 | features->unitExpo = report[i - 3]; | 424 | features->unitExpo = report[i - 3]; |
| 412 | i += 12; | 425 | i += 12; |
| 413 | } else { | 426 | break; |
| 427 | |||
| 428 | default: | ||
| 414 | features->x_max = | 429 | features->x_max = |
| 415 | get_unaligned_le16(&report[i + 3]); | 430 | get_unaligned_le16(&report[i + 3]); |
| 416 | features->x_phy = | 431 | features->x_phy = |
| @@ -418,10 +433,11 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
| 418 | features->unit = report[i + 9]; | 433 | features->unit = report[i + 9]; |
| 419 | features->unitExpo = report[i + 11]; | 434 | features->unitExpo = report[i + 11]; |
| 420 | i += 12; | 435 | i += 12; |
| 436 | break; | ||
| 421 | } | 437 | } |
| 422 | } else if (pen) { | 438 | } else if (pen) { |
| 423 | /* penabled only accepts exact bytes of data */ | 439 | /* penabled only accepts exact bytes of data */ |
| 424 | if (features->type == TABLETPC2FG) | 440 | if (features->type >= TABLETPC) |
| 425 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | 441 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
| 426 | features->device_type = BTN_TOOL_PEN; | 442 | features->device_type = BTN_TOOL_PEN; |
| 427 | features->x_max = | 443 | features->x_max = |
| @@ -434,32 +450,39 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
| 434 | case HID_USAGE_Y: | 450 | case HID_USAGE_Y: |
| 435 | if (usage == WCM_DESKTOP) { | 451 | if (usage == WCM_DESKTOP) { |
| 436 | if (finger) { | 452 | if (finger) { |
| 437 | int type = features->type; | 453 | switch (features->type) { |
| 438 | 454 | case TABLETPC2FG: | |
| 439 | if (type == TABLETPC2FG || type == MTSCREEN) { | 455 | case MTSCREEN: |
| 440 | features->y_max = | 456 | features->y_max = |
| 441 | get_unaligned_le16(&report[i + 3]); | 457 | get_unaligned_le16(&report[i + 3]); |
| 442 | features->y_phy = | 458 | features->y_phy = |
| 443 | get_unaligned_le16(&report[i + 6]); | 459 | get_unaligned_le16(&report[i + 6]); |
| 444 | i += 7; | 460 | i += 7; |
| 445 | } else if (type == WACOM_24HDT) { | 461 | break; |
| 462 | |||
| 463 | case WACOM_24HDT: | ||
| 446 | features->y_max = | 464 | features->y_max = |
| 447 | get_unaligned_le16(&report[i + 3]); | 465 | get_unaligned_le16(&report[i + 3]); |
| 448 | features->y_phy = | 466 | features->y_phy = |
| 449 | get_unaligned_le16(&report[i - 2]); | 467 | get_unaligned_le16(&report[i - 2]); |
| 450 | i += 7; | 468 | i += 7; |
| 451 | } else if (type == BAMBOO_PT) { | 469 | break; |
| 470 | |||
| 471 | case BAMBOO_PT: | ||
| 452 | features->y_phy = | 472 | features->y_phy = |
| 453 | get_unaligned_le16(&report[i + 3]); | 473 | get_unaligned_le16(&report[i + 3]); |
| 454 | features->y_max = | 474 | features->y_max = |
| 455 | get_unaligned_le16(&report[i + 6]); | 475 | get_unaligned_le16(&report[i + 6]); |
| 456 | i += 12; | 476 | i += 12; |
| 457 | } else { | 477 | break; |
| 478 | |||
| 479 | default: | ||
| 458 | features->y_max = | 480 | features->y_max = |
| 459 | features->x_max; | 481 | features->x_max; |
| 460 | features->y_phy = | 482 | features->y_phy = |
| 461 | get_unaligned_le16(&report[i + 3]); | 483 | get_unaligned_le16(&report[i + 3]); |
| 462 | i += 4; | 484 | i += 4; |
| 485 | break; | ||
| 463 | } | 486 | } |
| 464 | } else if (pen) { | 487 | } else if (pen) { |
| 465 | features->y_max = | 488 | features->y_max = |
