* [PATCH v2] touchscreen: elants: fix a missing check of return values
@ 2018-12-25 4:36 Kangjie Lu
2018-12-26 20:00 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-25 4:36 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Dmitry Torokhov, Greg Kroah-Hartman, Stephen Boyd,
Joe Perches, linux-input, linux-kernel
elants_i2c_send() may fail, let's check its return values. The fix does
the check and reports an error message upon the failure.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/input/touchscreen/elants_i2c.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index f2cb23121833..8ccba4ccee37 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -245,8 +245,22 @@ static int elants_i2c_calibrate(struct elants_data *ts)
ts->state = ELAN_WAIT_RECALIBRATION;
reinit_completion(&ts->cmd_done);
- elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
- elants_i2c_send(client, rek, sizeof(rek));
+ error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
+ if (error) {
+ dev_err(&client->dev,
+ "error in sending the w_flashkey command for calibration: %d\n",
+ error);
+ enable_irq(client->irq);
+ return error;
+ }
+ error = elants_i2c_send(client, rek, sizeof(rek));
+ if (error) {
+ dev_err(&client->dev,
+ "error in sending the rek command for calibration: %d\n",
+ error);
+ enable_irq(client->irq);
+ return error;
+ }
enable_irq(client->irq);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] touchscreen: elants: fix a missing check of return values
2018-12-25 4:36 [PATCH v2] touchscreen: elants: fix a missing check of return values Kangjie Lu
@ 2018-12-26 20:00 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2018-12-26 20:00 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Greg Kroah-Hartman, Stephen Boyd, Joe Perches,
linux-input, linux-kernel
Hi,
On Mon, Dec 24, 2018 at 10:36:13PM -0600, Kangjie Lu wrote:
> elants_i2c_send() may fail, let's check its return values. The fix does
> the check and reports an error message upon the failure.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/input/touchscreen/elants_i2c.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index f2cb23121833..8ccba4ccee37 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -245,8 +245,22 @@ static int elants_i2c_calibrate(struct elants_data *ts)
> ts->state = ELAN_WAIT_RECALIBRATION;
> reinit_completion(&ts->cmd_done);
>
> - elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> - elants_i2c_send(client, rek, sizeof(rek));
> + error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> + if (error) {
> + dev_err(&client->dev,
> + "error in sending the w_flashkey command for calibration: %d\n",
> + error);
> + enable_irq(client->irq);
> + return error;
> + }
> + error = elants_i2c_send(client, rek, sizeof(rek));
Messed up formatting.
> + if (error) {
> + dev_err(&client->dev,
> + "error in sending the rek command for calibration: %d\n",
> + error);
> + enable_irq(client->irq);
> + return error;
This also leaves the touchscreen in ELAN_WAIT_RECALIBRATION state. I
think all in all I'd rather leave the code as it was.
> + }
>
> enable_irq(client->irq);
>
> --
> 2.17.2 (Apple Git-113)
>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-26 20:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-25 4:36 [PATCH v2] touchscreen: elants: fix a missing check of return values Kangjie Lu
2018-12-26 20:00 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox