LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Nuno Lucas" <ntlucas@gmail.com>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Dmitry Torokhov" <dtor@mail.ru>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: [PATCH] linux-input: TSC-10 DM USB touchscreen driver assume 2-byte response from controller
Date: Thu, 6 Nov 2008 15:25:40 +0000	[thread overview]
Message-ID: <c4f20e170811060725v2ae331f9t7b1ba48059f93170@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]

The usbtouchscreen module implements a driver for the TSC-10 DM USB
touchscreen controllers, but assumes a 2-byte response for the
CMD_RESET and CMD_RATE commands, when they can be only a single byte
when no EEPROM is connected.

The driver worked with an earlier controller revision, but new
revisions of the controller fail.

It seems the problem is that the early controller had the
SEL4/EEPROM-CS pin high, but the new controller has it down, making
the response different.

Without the fix, the controller would answer the single byte 0x06
(ACK), making the init fail with -ENODEV because buf[1] is 0xFF (as
initialized before).

As the single byte is the only thing we need to check it was ok, there
is no need to verify the second byte.

The [0x15 0x01] case is the NAK [0x15] response for when there is no
data in the EEPROM [bit-0 of second byte set], so I let that be, as I
don't have any controller with an EEPROM.

With this patch, both the earlier and latest controller work the same.

Note: This was previously submited as BUG #11961 [1] on the bugzilla
tracker, but rebased to version 2.6.27.4 and with unnecessary comments
and printk's removed.


Signed-off-by: Nuno Lucas <ntlucas@gmail.com>


[1] http://bugzilla.kernel.org/show_bug.cgi?id=11961

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-fix_for_some_tsc205_controllers.diff --]
[-- Type: text/x-patch; name=patch-fix_for_some_tsc205_controllers.diff, Size: 956 bytes --]

diff -urNp linux-2.6.27.4/drivers/input/touchscreen/usbtouchscreen.c linux-2.6.27.4-patched/drivers/input/touchscreen/usbtouchscreen.c
--- linux-2.6.27.4/drivers/input/touchscreen/usbtouchscreen.c	2008-10-25 23:05:07.000000000 +0100
+++ linux-2.6.27.4-patched/drivers/input/touchscreen/usbtouchscreen.c	2008-11-06 15:07:49.000000000 +0000
@@ -424,7 +424,7 @@ static int dmc_tsc10_init(struct usbtouc
 	                      0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
 	if (ret < 0)
 		goto err_out;
-	if (buf[0] != 0x06 || buf[1] != 0x00) {
+	if (buf[0] != 0x06) {
 		ret = -ENODEV;
 		goto err_out;
 	}
@@ -437,8 +437,7 @@ static int dmc_tsc10_init(struct usbtouc
 	                      TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
 	if (ret < 0)
 		goto err_out;
-	if ((buf[0] != 0x06 || buf[1] != 0x00) &&
-	    (buf[0] != 0x15 || buf[1] != 0x01)) {
+	if ((buf[0] != 0x06) && (buf[0] != 0x15 || buf[1] != 0x01)) {
 		ret = -ENODEV;
 		goto err_out;
 	}

             reply	other threads:[~2008-11-06 15:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-06 15:25 Nuno Lucas [this message]
2008-11-11 21:52 ` Dmitry Torokhov
2008-11-11 22:54   ` Daniel Ritz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4f20e170811060725v2ae331f9t7b1ba48059f93170@mail.gmail.com \
    --to=ntlucas@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dtor@mail.ru \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] linux-input: TSC-10 DM USB touchscreen driver assume 2-byte response from controller' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).