Commit 823a11fd authored by Dudley Du's avatar Dudley Du Committed by Dmitry Torokhov

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: default avatarDudley Du <dudley.dulixin@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent f68a95cd
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Daniel Kurtz <djkurtz@chromium.org> * Daniel Kurtz <djkurtz@chromium.org>
* Benson Leung <bleung@chromium.org> * Benson Leung <bleung@chromium.org>
* *
* Copyright (C) 2011-2012 Cypress Semiconductor, Inc. * Copyright (C) 2011-2014 Cypress Semiconductor, Inc.
* Copyright (C) 2011-2012 Google, Inc. * Copyright (C) 2011-2012 Google, Inc.
* *
* This file is subject to the terms and conditions of the GNU General Public * 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,8 +421,8 @@ static ssize_t cyapa_read_block(struct cyapa *cyapa, u8 cmd_idx, u8 *values)
*/ */
static int cyapa_get_state(struct cyapa *cyapa) static int cyapa_get_state(struct cyapa *cyapa)
{ {
int ret;
u8 status[BL_STATUS_SIZE]; u8 status[BL_STATUS_SIZE];
int error;
cyapa->state = CYAPA_STATE_NO_DEVICE; cyapa->state = CYAPA_STATE_NO_DEVICE;
...@@ -432,7 +432,7 @@ static int cyapa_get_state(struct cyapa *cyapa) ...@@ -432,7 +432,7 @@ static int cyapa_get_state(struct cyapa *cyapa)
* If the device is in operation mode, this will be the DATA regs. * If the device is in operation mode, this will be the DATA regs.
* *
*/ */
ret = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE, error = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE,
status); status);
/* /*
...@@ -440,10 +440,10 @@ static int cyapa_get_state(struct cyapa *cyapa) ...@@ -440,10 +440,10 @@ static int cyapa_get_state(struct cyapa *cyapa)
* -ETIMEDOUT. In this case, try again using the smbus equivalent * -ETIMEDOUT. In this case, try again using the smbus equivalent
* command. This should return a BL_HEAD indicating CYAPA_STATE_OP. * command. This should return a BL_HEAD indicating CYAPA_STATE_OP.
*/ */
if (cyapa->smbus && (ret == -ETIMEDOUT || ret == -ENXIO)) if (cyapa->smbus && (error == -ETIMEDOUT || error == -ENXIO))
ret = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status); error = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status);
if (ret != BL_STATUS_SIZE) if (error != BL_STATUS_SIZE)
goto error; goto error;
if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) { if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) {
...@@ -453,7 +453,7 @@ static int cyapa_get_state(struct cyapa *cyapa) ...@@ -453,7 +453,7 @@ static int cyapa_get_state(struct cyapa *cyapa)
cyapa->state = CYAPA_STATE_OP; cyapa->state = CYAPA_STATE_OP;
break; break;
default: default:
ret = -EAGAIN; error = -EAGAIN;
goto error; goto error;
} }
} else { } else {
...@@ -467,7 +467,7 @@ static int cyapa_get_state(struct cyapa *cyapa) ...@@ -467,7 +467,7 @@ static int cyapa_get_state(struct cyapa *cyapa)
return 0; return 0;
error: error:
return (ret < 0) ? ret : -EAGAIN; return (error < 0) ? error : -EAGAIN;
} }
/* /*
...@@ -486,31 +486,31 @@ static int cyapa_get_state(struct cyapa *cyapa) ...@@ -486,31 +486,31 @@ static int cyapa_get_state(struct cyapa *cyapa)
*/ */
static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout) static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout)
{ {
int ret; int error;
int tries = timeout / 100; int tries = timeout / 100;
ret = cyapa_get_state(cyapa); error = cyapa_get_state(cyapa);
while ((ret || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) { while ((error || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) {
msleep(100); msleep(100);
ret = cyapa_get_state(cyapa); error = cyapa_get_state(cyapa);
} }
return (ret == -EAGAIN || ret == -ETIMEDOUT) ? -ETIMEDOUT : ret; return (error == -EAGAIN || error == -ETIMEDOUT) ? -ETIMEDOUT : error;
} }
static int cyapa_bl_deactivate(struct cyapa *cyapa) static int cyapa_bl_deactivate(struct cyapa *cyapa)
{ {
int ret; int error;
ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate), error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate),
bl_deactivate); bl_deactivate);
if (ret < 0) if (error)
return ret; return error;
/* wait for bootloader to switch to idle state; should take < 100ms */ /* wait for bootloader to switch to idle state; should take < 100ms */
msleep(100); msleep(100);
ret = cyapa_poll_state(cyapa, 500); error = cyapa_poll_state(cyapa, 500);
if (ret < 0) if (error)
return ret; return error;
if (cyapa->state != CYAPA_STATE_BL_IDLE) if (cyapa->state != CYAPA_STATE_BL_IDLE)
return -EAGAIN; return -EAGAIN;
return 0; return 0;
...@@ -531,11 +531,11 @@ static int cyapa_bl_deactivate(struct cyapa *cyapa) ...@@ -531,11 +531,11 @@ static int cyapa_bl_deactivate(struct cyapa *cyapa)
*/ */
static int cyapa_bl_exit(struct cyapa *cyapa) static int cyapa_bl_exit(struct cyapa *cyapa)
{ {
int ret; int error;
ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit); error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit);
if (ret < 0) if (error)
return ret; return error;
/* /*
* Wait for bootloader to exit, and operation mode to start. * Wait for bootloader to exit, and operation mode to start.
...@@ -547,9 +547,9 @@ static int cyapa_bl_exit(struct cyapa *cyapa) ...@@ -547,9 +547,9 @@ static int cyapa_bl_exit(struct cyapa *cyapa)
* updated to new firmware, it must first calibrate its sensors, which * updated to new firmware, it must first calibrate its sensors, which
* can take up to an additional 2 seconds. * can take up to an additional 2 seconds.
*/ */
ret = cyapa_poll_state(cyapa, 2000); error = cyapa_poll_state(cyapa, 2000);
if (ret < 0) if (error < 0)
return ret; return error;
if (cyapa->state != CYAPA_STATE_OP) if (cyapa->state != CYAPA_STATE_OP)
return -EAGAIN; return -EAGAIN;
...@@ -639,28 +639,28 @@ static int cyapa_check_is_operational(struct cyapa *cyapa) ...@@ -639,28 +639,28 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
{ {
struct device *dev = &cyapa->client->dev; struct device *dev = &cyapa->client->dev;
static const char unique_str[] = "CYTRA"; static const char unique_str[] = "CYTRA";
int ret; int error;
ret = cyapa_poll_state(cyapa, 2000); error = cyapa_poll_state(cyapa, 2000);
if (ret < 0) if (error)
return ret; return error;
switch (cyapa->state) { switch (cyapa->state) {
case CYAPA_STATE_BL_ACTIVE: case CYAPA_STATE_BL_ACTIVE:
ret = cyapa_bl_deactivate(cyapa); error = cyapa_bl_deactivate(cyapa);
if (ret) if (error)
return ret; return error;
/* Fallthrough state */ /* Fallthrough state */
case CYAPA_STATE_BL_IDLE: case CYAPA_STATE_BL_IDLE:
ret = cyapa_bl_exit(cyapa); error = cyapa_bl_exit(cyapa);
if (ret) if (error)
return ret; return error;
/* Fallthrough state */ /* Fallthrough state */
case CYAPA_STATE_OP: case CYAPA_STATE_OP:
ret = cyapa_get_query_data(cyapa); error = cyapa_get_query_data(cyapa);
if (ret < 0) if (error)
return ret; return error;
/* only support firmware protocol gen3 */ /* only support firmware protocol gen3 */
if (cyapa->gen != CYAPA_GEN3) { if (cyapa->gen != CYAPA_GEN3) {
...@@ -790,7 +790,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) ...@@ -790,7 +790,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
input = devm_input_allocate_device(dev); input = devm_input_allocate_device(dev);
if (!input) { if (!input) {
dev_err(dev, "allocate memory for input device failed\n"); dev_err(dev, "failed to allocate memory for input device.\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -798,7 +798,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) ...@@ -798,7 +798,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
input->phys = cyapa->phys; input->phys = cyapa->phys;
input->id.bustype = BUS_I2C; input->id.bustype = BUS_I2C;
input->id.version = 1; input->id.version = 1;
input->id.product = 0; /* means any product in eventcomm. */ input->id.product = 0; /* Means any product in eventcomm. */
input->dev.parent = &cyapa->client->dev; input->dev.parent = &cyapa->client->dev;
input->open = cyapa_open; input->open = cyapa_open;
...@@ -808,7 +808,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa) ...@@ -808,7 +808,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
__set_bit(EV_ABS, input->evbit); __set_bit(EV_ABS, input->evbit);
/* finger position */ /* Finger position */
input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0, input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0,
0); 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cyapa->max_abs_y, 0, 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,7 +830,7 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK) if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK)
__set_bit(INPUT_PROP_BUTTONPAD, input->propbit); __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
/* handle pointer emulation and unused slots in core */ /* Handle pointer emulation and unused slots in core */
error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS, error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS,
INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED); INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED);
if (error) { if (error) {
...@@ -894,7 +894,7 @@ static int cyapa_probe(struct i2c_client *client, ...@@ -894,7 +894,7 @@ static int cyapa_probe(struct i2c_client *client,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"cyapa", cyapa); "cyapa", cyapa);
if (error) { if (error) {
dev_err(dev, "IRQ request failed: %d\n, ", error); dev_err(dev, "failed to request threaded irq: %d\n", error);
return error; return error;
} }
......
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