input: touchscreen: correct probe error path for ITE tech driver

ITE tech touch driver dynamically detects the controller attached
to the device in its probe. And if the driver fails to identify
the controller, it exits the probe with the error code. But in the
probe error path, it doesn't retain the error code, replace it
with zero and registers the device instead of failing.
This change corrects the probe error path of ITE tech touch driver
and makes sure it returns the error code if it fails.

Change-Id: I8f193ee10076b6cf058b0a6940db54f71f70b758
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
This commit is contained in:
Shantanu Jain 2015-10-12 22:20:06 +05:30 committed by Abinaya P
parent aacc5edd8c
commit 3d4fb6fef8

View file

@ -1117,7 +1117,7 @@ static void IT7260_ts_work_func(struct work_struct *work)
pm_relax(&gl_ts->client->dev);
}
static bool IT7260_chipIdentify(void)
static int IT7260_chipIdentify(void)
{
static const uint8_t cmd_ident[] = {CMD_IDENT_CHIP};
static const uint8_t expected_id[] = {0x0A, 'I', 'T', 'E', '7',
@ -1129,7 +1129,7 @@ static bool IT7260_chipIdentify(void)
if (!IT7260_i2cWriteNoReadyCheck(BUF_COMMAND, cmd_ident,
sizeof(cmd_ident))) {
dev_err(&gl_ts->client->dev, "failed to write CMD_IDENT_CHIP\n");
return false;
return -ENODEV;
}
IT7260_waitDeviceReady(false, false);
@ -1137,7 +1137,7 @@ static bool IT7260_chipIdentify(void)
if (!IT7260_i2cReadNoReadyCheck(BUF_RESPONSE, chip_id,
sizeof(chip_id))) {
dev_err(&gl_ts->client->dev, "failed to read chip-id\n");
return false;
return -ENODEV;
}
dev_info(&gl_ts->client->dev,
"IT7260_chipIdentify read id: %02X %c%c%c%c%c%c%c %c%c\n",
@ -1145,7 +1145,7 @@ static bool IT7260_chipIdentify(void)
chip_id[5], chip_id[6], chip_id[7], chip_id[8], chip_id[9]);
if (memcmp(chip_id, expected_id, sizeof(expected_id)))
return false;
return -EINVAL;
if (chip_id[8] == '5' && chip_id[9] == '6')
dev_info(&gl_ts->client->dev, "rev BX3 found\n");
@ -1155,7 +1155,7 @@ static bool IT7260_chipIdentify(void)
dev_info(&gl_ts->client->dev, "unknown revision (0x%02X 0x%02X) found\n",
chip_id[8], chip_id[9]);
return true;
return 0;
}
static int reg_set_optimum_mode_check(struct regulator *reg, int load_uA)
@ -1572,7 +1572,7 @@ static int IT7260_ts_probe(struct i2c_client *client,
static const uint8_t cmd_start[] = {CMD_UNKNOWN_7};
struct IT7260_ts_platform_data *pdata;
uint8_t rsp[2];
int ret = -1;
int ret = -1, err;
struct dentry *temp;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@ -1641,8 +1641,9 @@ static int IT7260_ts_probe(struct i2c_client *client,
}
}
if (!IT7260_chipIdentify()) {
dev_err(&client->dev, "Failed to identify chip!!!");
ret = IT7260_chipIdentify();
if (ret) {
dev_err(&client->dev, "Failed to identify chip %d!!!", ret);
goto err_identification_fail;
}
@ -1768,12 +1769,12 @@ err_identification_fail:
devm_pinctrl_put(gl_ts->ts_pinctrl);
gl_ts->ts_pinctrl = NULL;
} else {
ret = pinctrl_select_state(gl_ts->ts_pinctrl,
err = pinctrl_select_state(gl_ts->ts_pinctrl,
gl_ts->pinctrl_state_release);
if (ret)
if (err)
dev_err(&gl_ts->client->dev,
"failed to select relase pinctrl state %d\n",
ret);
err);
}
} else {
if (gpio_is_valid(pdata->reset_gpio))