diff options
author | Dudley Du <dudley.dulixin@gmail.com> | 2014-12-04 10:00:03 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-12-04 12:26:40 -0500 |
commit | 823a11fdbde32f9efba48093dca74fe81010a265 (patch) | |
tree | 7bc95bd7490a9a3ce3c2ddea1da59153fbecf4a4 /drivers/input | |
parent | f68a95cda6a483110e391ac2b8dd2092502c09fe (diff) |
Input: cyapa - use 'error' for error codes
Let's use 'error' variable instead of 'ret' when we need to store erro
codes.
Signed-off-by: Dudley Du <dudley.dulixin@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/cyapa.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index 94e73275af04..1bece8cad46f 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Daniel Kurtz <djkurtz@chromium.org> | 6 | * Daniel Kurtz <djkurtz@chromium.org> |
7 | * Benson Leung <bleung@chromium.org> | 7 | * Benson Leung <bleung@chromium.org> |
8 | * | 8 | * |
9 | * Copyright (C) 2011-2012 Cypress Semiconductor, Inc. | 9 | * Copyright (C) 2011-2014 Cypress Semiconductor, Inc. |
10 | * Copyright (C) 2011-2012 Google, Inc. | 10 | * Copyright (C) 2011-2012 Google, Inc. |
11 | * | 11 | * |
12 | * This file is subject to the terms and conditions of the GNU General Public | 12 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -421,8 +421,8 @@ static ssize_t cyapa_read_block(struct cyapa *cyapa, u8 cmd_idx, u8 *values) | |||
421 | */ | 421 | */ |
422 | static int cyapa_get_state(struct cyapa *cyapa) | 422 | static int cyapa_get_state(struct cyapa *cyapa) |
423 | { | 423 | { |
424 | int ret; | ||
425 | u8 status[BL_STATUS_SIZE]; | 424 | u8 status[BL_STATUS_SIZE]; |
425 | int error; | ||
426 | 426 | ||
427 | cyapa->state = CYAPA_STATE_NO_DEVICE; | 427 | cyapa->state = CYAPA_STATE_NO_DEVICE; |
428 | 428 | ||
@@ -432,18 +432,18 @@ static int cyapa_get_state(struct cyapa *cyapa) | |||
432 | * If the device is in operation mode, this will be the DATA regs. | 432 | * If the device is in operation mode, this will be the DATA regs. |
433 | * | 433 | * |
434 | */ | 434 | */ |
435 | ret = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE, | 435 | error = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE, |
436 | status); | 436 | status); |
437 | 437 | ||
438 | /* | 438 | /* |
439 | * On smbus systems in OP mode, the i2c_reg_read will fail with | 439 | * On smbus systems in OP mode, the i2c_reg_read will fail with |
440 | * -ETIMEDOUT. In this case, try again using the smbus equivalent | 440 | * -ETIMEDOUT. In this case, try again using the smbus equivalent |
441 | * command. This should return a BL_HEAD indicating CYAPA_STATE_OP. | 441 | * command. This should return a BL_HEAD indicating CYAPA_STATE_OP. |
442 | */ | 442 | */ |
443 | if (cyapa->smbus && (ret == -ETIMEDOUT || ret == -ENXIO)) | 443 | if (cyapa->smbus && (error == -ETIMEDOUT || error == -ENXIO)) |
444 | ret = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status); | 444 | error = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status); |
445 | 445 | ||
446 | if (ret != BL_STATUS_SIZE) | 446 | if (error != BL_STATUS_SIZE) |
447 | goto error; | 447 | goto error; |
448 | 448 | ||
449 | if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) { | 449 | if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) { |
@@ -453,7 +453,7 @@ static int cyapa_get_state(struct cyapa *cyapa) | |||
453 | cyapa->state = CYAPA_STATE_OP; | 453 | cyapa->state = CYAPA_STATE_OP; |
454 | break; | 454 | break; |
455 | default: | 455 | default: |
456 | ret = -EAGAIN; | 456 | error = -EAGAIN; |
457 | goto error; | 457 | goto error; |
458 | } | 458 | } |
459 | } else { | 459 | } else { |
@@ -467,7 +467,7 @@ static int cyapa_get_state(struct cyapa *cyapa) | |||
467 | 467 | ||
468 | return 0; | 468 | return 0; |
469 | error: | 469 | error: |
470 | return (ret < 0) ? ret : -EAGAIN; | 470 | return (error < 0) ? error : -EAGAIN; |
471 | } | 471 | } |
472 | 472 | ||
473 | /* | 473 | /* |
@@ -486,31 +486,31 @@ error: | |||
486 | */ | 486 | */ |
487 | static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout) | 487 | static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout) |
488 | { | 488 | { |
489 | int ret; | 489 | int error; |
490 | int tries = timeout / 100; | 490 | int tries = timeout / 100; |
491 | 491 | ||
492 | ret = cyapa_get_state(cyapa); | 492 | error = cyapa_get_state(cyapa); |
493 | while ((ret || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) { | 493 | while ((error || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) { |
494 | msleep(100); | 494 | msleep(100); |
495 | ret = cyapa_get_state(cyapa); | 495 | error = cyapa_get_state(cyapa); |
496 | } | 496 | } |
497 | return (ret == -EAGAIN || ret == -ETIMEDOUT) ? -ETIMEDOUT : ret; | 497 | return (error == -EAGAIN || error == -ETIMEDOUT) ? -ETIMEDOUT : error; |
498 | } | 498 | } |
499 | 499 | ||
500 | static int cyapa_bl_deactivate(struct cyapa *cyapa) | 500 | static int cyapa_bl_deactivate(struct cyapa *cyapa) |
501 | { | 501 | { |
502 | int ret; | 502 | int error; |
503 | 503 | ||
504 | ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate), | 504 | error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate), |
505 | bl_deactivate); | 505 | bl_deactivate); |
506 | if (ret < 0) | 506 | if (error) |
507 | return ret; | 507 | return error; |
508 | 508 | ||
509 | /* wait for bootloader to switch to idle state; should take < 100ms */ | 509 | /* wait for bootloader to switch to idle state; should take < 100ms */ |
510 | msleep(100); | 510 | msleep(100); |
511 | ret = cyapa_poll_state(cyapa, 500); | 511 | error = cyapa_poll_state(cyapa, 500); |
512 | if (ret < 0) | 512 | if (error) |
513 | return ret; | 513 | return error; |
514 | if (cyapa->state != CYAPA_STATE_BL_IDLE) | 514 | if (cyapa->state != CYAPA_STATE_BL_IDLE) |
515 | return -EAGAIN; | 515 | return -EAGAIN; |
516 | return 0; | 516 | return 0; |
@@ -531,11 +531,11 @@ static int cyapa_bl_deactivate(struct cyapa *cyapa) | |||
531 | */ | 531 | */ |
532 | static int cyapa_bl_exit(struct cyapa *cyapa) | 532 | static int cyapa_bl_exit(struct cyapa *cyapa) |
533 | { | 533 | { |
534 | int ret; | 534 | int error; |
535 | 535 | ||
536 | ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit); | 536 | error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit); |
537 | if (ret < 0) | 537 | if (error) |
538 | return ret; | 538 | return error; |
539 | 539 | ||
540 | /* | 540 | /* |
541 | * Wait for bootloader to exit, and operation mode to start. | 541 | * Wait for bootloader to exit, and operation mode to start. |
@@ -547,9 +547,9 @@ static int cyapa_bl_exit(struct cyapa *cyapa) | |||
547 | * updated to new firmware, it must first calibrate its sensors, which | 547 | * updated to new firmware, it must first calibrate its sensors, which |
548 | * can take up to an additional 2 seconds. | 548 | * can take up to an additional 2 seconds. |
549 | */ | 549 | */ |
550 | ret = cyapa_poll_state(cyapa, 2000); | 550 | error = cyapa_poll_state(cyapa, 2000); |
551 | if (ret < 0) | 551 | if (error < 0) |
552 | return ret; | 552 | return error; |
553 | if (cyapa->state != CYAPA_STATE_OP) | 553 | if (cyapa->state != CYAPA_STATE_OP) |
554 | return -EAGAIN; | 554 | return -EAGAIN; |
555 | 555 | ||
@@ -639,28 +639,28 @@ static int cyapa_check_is_operational(struct cyapa *cyapa) | |||
639 | { | 639 | { |
640 | struct device *dev = &cyapa->client->dev; | 640 | struct device *dev = &cyapa->client->dev; |
641 | static const char unique_str[] = "CYTRA"; | 641 | static const char unique_str[] = "CYTRA"; |
642 | int ret; | 642 | int error; |
643 | 643 | ||
644 | ret = cyapa_poll_state(cyapa, 2000); | 644 | error = cyapa_poll_state(cyapa, 2000); |
645 | if (ret < 0) | 645 | if (error) |
646 | return ret; | 646 | return error; |
647 | switch (cyapa->state) { | 647 | switch (cyapa->state) { |
648 | case CYAPA_STATE_BL_ACTIVE: | 648 | case CYAPA_STATE_BL_ACTIVE: |
649 | ret = cyapa_bl_deactivate(cyapa); | 649 | error = cyapa_bl_deactivate(cyapa); |
650 | if (ret) | 650 | if (error) |
651 | return ret; | 651 | return error; |
652 | 652 | ||
653 | /* Fallthrough state */ | 653 | /* Fallthrough state */ |
654 | case CYAPA_STATE_BL_IDLE: | 654 | case CYAPA_STATE_BL_IDLE: |
655 | ret = cyapa_bl_exit(cyapa); | 655 | error = cyapa_bl_exit(cyapa); |
656 | if (ret) | 656 | if (error) |
657 | return ret; | 657 | return error; |
658 | 658 | ||
659 | /* Fallthrough state */ | 659 | /* Fallthrough state */ |
660 | case CYAPA_STATE_OP: | 660 | case CYAPA_STATE_OP: |
661 | ret = cyapa_get_query_data(cyapa); | 661 | error = cyapa_get_query_data(cyapa); |
662 | if (ret < 0) | 662 | if (error) |
663 | return ret; | 663 | return error; |
664 | 664 | ||
665 | /* only support firmware protocol gen3 */ | 665 | /* only support firmware protocol gen3 */ |
666 | if (cyapa->gen != CYAPA_GEN3) { | 666 | if (cyapa->gen != CYAPA_GEN3) { |
@@ -790,7 +790,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) | |||
790 | 790 | ||
791 | input = devm_input_allocate_device(dev); | 791 | input = devm_input_allocate_device(dev); |
792 | if (!input) { | 792 | if (!input) { |
793 | dev_err(dev, "allocate memory for input device failed\n"); | 793 | dev_err(dev, "failed to allocate memory for input device.\n"); |
794 | return -ENOMEM; | 794 | return -ENOMEM; |
795 | } | 795 | } |
796 | 796 | ||
@@ -798,7 +798,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) | |||
798 | input->phys = cyapa->phys; | 798 | input->phys = cyapa->phys; |
799 | input->id.bustype = BUS_I2C; | 799 | input->id.bustype = BUS_I2C; |
800 | input->id.version = 1; | 800 | input->id.version = 1; |
801 | input->id.product = 0; /* means any product in eventcomm. */ | 801 | input->id.product = 0; /* Means any product in eventcomm. */ |
802 | input->dev.parent = &cyapa->client->dev; | 802 | input->dev.parent = &cyapa->client->dev; |
803 | 803 | ||
804 | input->open = cyapa_open; | 804 | input->open = cyapa_open; |
@@ -808,7 +808,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) | |||
808 | 808 | ||
809 | __set_bit(EV_ABS, input->evbit); | 809 | __set_bit(EV_ABS, input->evbit); |
810 | 810 | ||
811 | /* finger position */ | 811 | /* Finger position */ |
812 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0, | 812 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0, |
813 | 0); | 813 | 0); |
814 | input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cyapa->max_abs_y, 0, | 814 | input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cyapa->max_abs_y, 0, |
@@ -830,7 +830,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) | |||
830 | if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK) | 830 | if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK) |
831 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); | 831 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); |
832 | 832 | ||
833 | /* handle pointer emulation and unused slots in core */ | 833 | /* Handle pointer emulation and unused slots in core */ |
834 | error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS, | 834 | error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS, |
835 | INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED); | 835 | INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED); |
836 | if (error) { | 836 | if (error) { |
@@ -894,7 +894,7 @@ static int cyapa_probe(struct i2c_client *client, | |||
894 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | 894 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
895 | "cyapa", cyapa); | 895 | "cyapa", cyapa); |
896 | if (error) { | 896 | if (error) { |
897 | dev_err(dev, "IRQ request failed: %d\n, ", error); | 897 | dev_err(dev, "failed to request threaded irq: %d\n", error); |
898 | return error; | 898 | return error; |
899 | } | 899 | } |
900 | 900 | ||