Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dudley Du and committed by
Dmitry Torokhov
823a11fd f68a95cd

+47 -47
+47 -47
drivers/input/mouse/cyapa.c
··· 6 6 * Daniel Kurtz <djkurtz@chromium.org> 7 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 10 * Copyright (C) 2011-2012 Google, Inc. 11 11 * 12 12 * This file is subject to the terms and conditions of the GNU General Public ··· 421 421 */ 422 422 static int cyapa_get_state(struct cyapa *cyapa) 423 423 { 424 - int ret; 425 424 u8 status[BL_STATUS_SIZE]; 425 + int error; 426 426 427 427 cyapa->state = CYAPA_STATE_NO_DEVICE; 428 428 ··· 432 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, 436 - status); 435 + error = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE, 436 + status); 437 437 438 438 /* 439 439 * On smbus systems in OP mode, the i2c_reg_read will fail with 440 440 * -ETIMEDOUT. In this case, try again using the smbus equivalent 441 441 * command. This should return a BL_HEAD indicating CYAPA_STATE_OP. 442 442 */ 443 - if (cyapa->smbus && (ret == -ETIMEDOUT || ret == -ENXIO)) 444 - ret = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status); 443 + if (cyapa->smbus && (error == -ETIMEDOUT || error == -ENXIO)) 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 447 goto error; 448 448 449 449 if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) { ··· 453 453 cyapa->state = CYAPA_STATE_OP; 454 454 break; 455 455 default: 456 - ret = -EAGAIN; 456 + error = -EAGAIN; 457 457 goto error; 458 458 } 459 459 } else { ··· 467 467 468 468 return 0; 469 469 error: 470 - return (ret < 0) ? ret : -EAGAIN; 470 + return (error < 0) ? error : -EAGAIN; 471 471 } 472 472 473 473 /* ··· 486 486 */ 487 487 static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout) 488 488 { 489 - int ret; 489 + int error; 490 490 int tries = timeout / 100; 491 491 492 - ret = cyapa_get_state(cyapa); 493 - while ((ret || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) { 492 + error = cyapa_get_state(cyapa); 493 + while ((error || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) { 494 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 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), 505 - bl_deactivate); 506 - if (ret < 0) 507 - return ret; 504 + error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate), 505 + bl_deactivate); 506 + if (error) 507 + return error; 508 508 509 509 /* wait for bootloader to switch to idle state; should take < 100ms */ 510 510 msleep(100); 511 - ret = cyapa_poll_state(cyapa, 500); 512 - if (ret < 0) 513 - return ret; 511 + error = cyapa_poll_state(cyapa, 500); 512 + if (error) 513 + return error; 514 514 if (cyapa->state != CYAPA_STATE_BL_IDLE) 515 515 return -EAGAIN; 516 516 return 0; ··· 531 531 */ 532 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); 537 - if (ret < 0) 538 - return ret; 536 + error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit); 537 + if (error) 538 + return error; 539 539 540 540 /* 541 541 * Wait for bootloader to exit, and operation mode to start. ··· 547 547 * updated to new firmware, it must first calibrate its sensors, which 548 548 * can take up to an additional 2 seconds. 549 549 */ 550 - ret = cyapa_poll_state(cyapa, 2000); 551 - if (ret < 0) 552 - return ret; 550 + error = cyapa_poll_state(cyapa, 2000); 551 + if (error < 0) 552 + return error; 553 553 if (cyapa->state != CYAPA_STATE_OP) 554 554 return -EAGAIN; 555 555 ··· 639 639 { 640 640 struct device *dev = &cyapa->client->dev; 641 641 static const char unique_str[] = "CYTRA"; 642 - int ret; 642 + int error; 643 643 644 - ret = cyapa_poll_state(cyapa, 2000); 645 - if (ret < 0) 646 - return ret; 644 + error = cyapa_poll_state(cyapa, 2000); 645 + if (error) 646 + return error; 647 647 switch (cyapa->state) { 648 648 case CYAPA_STATE_BL_ACTIVE: 649 - ret = cyapa_bl_deactivate(cyapa); 650 - if (ret) 651 - return ret; 649 + error = cyapa_bl_deactivate(cyapa); 650 + if (error) 651 + return error; 652 652 653 653 /* Fallthrough state */ 654 654 case CYAPA_STATE_BL_IDLE: 655 - ret = cyapa_bl_exit(cyapa); 656 - if (ret) 657 - return ret; 655 + error = cyapa_bl_exit(cyapa); 656 + if (error) 657 + return error; 658 658 659 659 /* Fallthrough state */ 660 660 case CYAPA_STATE_OP: 661 - ret = cyapa_get_query_data(cyapa); 662 - if (ret < 0) 663 - return ret; 661 + error = cyapa_get_query_data(cyapa); 662 + if (error) 663 + return error; 664 664 665 665 /* only support firmware protocol gen3 */ 666 666 if (cyapa->gen != CYAPA_GEN3) { ··· 790 790 791 791 input = devm_input_allocate_device(dev); 792 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 794 return -ENOMEM; 795 795 } 796 796 ··· 798 798 input->phys = cyapa->phys; 799 799 input->id.bustype = BUS_I2C; 800 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 802 input->dev.parent = &cyapa->client->dev; 803 803 804 804 input->open = cyapa_open; ··· 808 808 809 809 __set_bit(EV_ABS, input->evbit); 810 810 811 - /* finger position */ 811 + /* Finger position */ 812 812 input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0, 813 813 0); 814 814 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cyapa->max_abs_y, 0, ··· 830 830 if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK) 831 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 834 error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS, 835 835 INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED); 836 836 if (error) { ··· 894 894 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 895 895 "cyapa", cyapa); 896 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 898 return error; 899 899 } 900 900