diff options
author | Robert Chiras <robert.chiras@nxp.com> | 2017-03-16 12:20:45 +0200 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | fc45a5929e113631e44222cb680eb056cc1e459d (patch) | |
tree | f3721da3e0a6c7848c4170f36ba04ca520b3969c /drivers/input/touchscreen | |
parent | dd0b689deb778ba075270a7eaab625f14c239e84 (diff) |
MLK-14473: touchscreen: Fix return type
The touchscreen driver, max11801, which is on 12c2 bus, won't be probed
when using the hdcp specific DTS (this is disabling 12c2, since it
will acquire it for DDC communications). Since this driver won't be
probed, it will spam the dmesg with the pr_err from max11801_read_adc()
function. This function is periodically called by the battery driver. For
this reason, I removed the pr_err() call.
Also, to be noticed that the function signature is u32, but in case of an
error it will return a negative integer. In order to correctly propagate
errors, I changed the function signature to int. This is safe, since the
read value from i2c is on 16 bits (MSB and LSB on 8 bits).
Also, the function calibration_voltage is calling max11801_read_adc from
touchscreen driverm which can return negative values in case of an
error. I case of an error, just stop reading ADC data and return 0 as
voltage_data.
Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/max11801_ts.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c index d0cb96597f5e..4c4d559e0d04 100644 --- a/drivers/input/touchscreen/max11801_ts.c +++ b/drivers/input/touchscreen/max11801_ts.c @@ -114,26 +114,28 @@ static int max11801_dcm_write_command(struct i2c_client *client, int command) return i2c_smbus_write_byte(client, command); } -static u32 max11801_dcm_sample_aux(struct i2c_client *client) +static int max11801_dcm_sample_aux(struct i2c_client *client) { int ret; int aux = 0; - u32 sample_data; + int sample_data; /* AUX_measurement */ max11801_dcm_write_command(client, AUX_measurement); mdelay(5); ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_AUX_MSB, 1, &aux_buf[0]); - if (ret < 1) { - dev_err(&client->dev, "FIFO_RD_AUX_MSB read fails\n"); + if (ret < 0) { + dev_err(&client->dev, "FIFO_RD_AUX_MSB read failed (%d)\n", + ret); return ret; } mdelay(5); ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_AUX_LSB, 1, &aux_buf[1]); - if (ret < 1) { - dev_err(&client->dev, "FIFO_RD_AUX_LSB read fails\n"); + if (ret < 0) { + dev_err(&client->dev, "FIFO_RD_AUX_LSB read failed (%d)\n", + ret); return ret; } @@ -149,14 +151,12 @@ static u32 max11801_dcm_sample_aux(struct i2c_client *client) return sample_data; } -u32 max11801_read_adc(void) +int max11801_read_adc(void) { - u32 adc_data; + int adc_data; - if (!max11801_client) { - pr_err("FAIL max11801_client not initialize\n"); - return -1; - } + if (!max11801_client) + return -ENODEV; adc_data = max11801_dcm_sample_aux(max11801_client); return adc_data; |