linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] TSC-40: Improve EEPROM error handling
@ 2011-09-13  8:18 Christian Gmeiner
  2011-09-13  8:50 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Gmeiner @ 2011-09-13  8:18 UTC (permalink / raw)
  To: linux-input; +Cc: bigeasy

>From 30b11594207afd8a3075d3115678cd7013d380d8 Mon Sep 17 00:00:00 2001
From: Christian Gmeiner <christian.gmeiner@gmail.com>
Date: Wed, 7 Sep 2011 14:29:10 +0200
Subject: [PATCH 3/3] TSC40: Improve EEPROM error handling

It could happen that the internal EEPROM does not contain any
calibration data and as a result of this the driver will fail.
With this patch we simply ignore an empty EEPROM, as the touch
controller runs in 'Coordinate data mode' (raw data).

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
drivers/input/touchscreen/tsc40.c |   21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc40.c
b/drivers/input/touchscreen/tsc40.c
index b73ef2f..d914522 100644
--- a/drivers/input/touchscreen/tsc40.c
+++ b/drivers/input/touchscreen/tsc40.c
@@ -49,7 +49,6 @@ struct tsc_ser {

 #define RESPONSE_ACK   0x06
#define RESPONSE_NAK    0x15
-#define NACK_DETAIL_NT (1 << 3)

 #define ID_EPROM_UNUSED        (1 << 7)

@@ -96,11 +95,25 @@ static void handle_reset(struct serio *serio,
unsigned char data)

       /* NAK + EEPROM available */
       if (ptsc->idx == 1) {
-               if (!(data & NACK_DETAIL_NT)) {
+               if (data & (1 << 0)) {
+                       dev_warn(&serio->dev, "EEPROM data empty\n");
+                       state_after_reset(ptsc, 1);
+                       return;
+               } else if (data & (1 << 1)) {
+                       dev_warn(&serio->dev, "EEPROM data abnormal\n");
                       state_after_reset(ptsc, 0);
                       return;
-               }
-               state_after_reset(ptsc, 0);
+               } else if (data & (1 << 2)) {
+                       dev_warn(&serio->dev, "EEPROM write error\n");
+                       state_after_reset(ptsc, 0);
+                       return;
+               } else if (data & (1 << 3)) {
+                       dev_warn(&serio->dev, "Touch screen not connected\n");
+                       state_after_reset(ptsc, 0);
+                       return;
+               } else
+                       BUG_ON(1);
+
               return;
       }

--
1.7.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] TSC-40: Improve EEPROM error handling
  2011-09-13  8:18 [PATCH 3/3] TSC-40: Improve EEPROM error handling Christian Gmeiner
@ 2011-09-13  8:50 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-09-13  8:50 UTC (permalink / raw)
  To: Christian Gmeiner; +Cc: linux-input

* Christian Gmeiner | 2011-09-13 10:18:41 [+0200]:

>diff --git a/drivers/input/touchscreen/tsc40.c
>b/drivers/input/touchscreen/tsc40.c
>index b73ef2f..d914522 100644
>--- a/drivers/input/touchscreen/tsc40.c
>+++ b/drivers/input/touchscreen/tsc40.c
>@@ -49,7 +49,6 @@ struct tsc_ser {
>
> #define RESPONSE_ACK   0x06
>#define RESPONSE_NAK    0x15
>-#define NACK_DETAIL_NT (1 << 3)
>
> #define ID_EPROM_UNUSED        (1 << 7)
>
>@@ -96,11 +95,25 @@ static void handle_reset(struct serio *serio,
>unsigned char data)
>
>       /* NAK + EEPROM available */
>       if (ptsc->idx == 1) {
>-               if (!(data & NACK_DETAIL_NT)) {
>+               if (data & (1 << 0)) {
>+                       dev_warn(&serio->dev, "EEPROM data empty\n");
>+                       state_after_reset(ptsc, 1);
>+                       return;
>+               } else if (data & (1 << 1)) {
>+                       dev_warn(&serio->dev, "EEPROM data abnormal\n");
>                       state_after_reset(ptsc, 0);
>                       return;
>-               }
>-               state_after_reset(ptsc, 0);
>+               } else if (data & (1 << 2)) {
>+                       dev_warn(&serio->dev, "EEPROM write error\n");
>+                       state_after_reset(ptsc, 0);
>+                       return;
>+               } else if (data & (1 << 3)) {
>+                       dev_warn(&serio->dev, "Touch screen not connected\n");
>+                       state_after_reset(ptsc, 0);
>+                       return;
>+               } else
>+                       BUG_ON(1);
>+

That BUG() isn't really nice. Since you in probe at this time, couldn't
you print something and abort loading the driver?

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-13  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13  8:18 [PATCH 3/3] TSC-40: Improve EEPROM error handling Christian Gmeiner
2011-09-13  8:50 ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).