efefda5c2f9a57cc6ee944e92eed2dca122c7ad6
[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap-2.6.37rc / 0013-drivers-input-touchscreen-ads7846-return-ENODEV-if-d.patch
1 From 43b7984021e30a9aa9b97c2cf9a9ceb806372709 Mon Sep 17 00:00:00 2001
2 From: Steve Sakoman <sakoman@gmail.com>
3 Date: Tue, 15 Dec 2009 15:24:10 -0800
4 Subject: [PATCH 13/29] drivers: input: touchscreen: ads7846: return ENODEV if device is not found
6 Signed-off-by: Steve Sakoman <sakoman@gmail.com>
7 ---
8 drivers/input/touchscreen/ads7846.c | 13 ++++++++++---
9 1 files changed, 10 insertions(+), 3 deletions(-)
11 diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
12 index 14ea54b..c775e38 100644
13 --- a/drivers/input/touchscreen/ads7846.c
14 +++ b/drivers/input/touchscreen/ads7846.c
15 @@ -1325,11 +1325,18 @@ static int __devinit ads7846_probe(struct spi_device *spi)
16 * the touchscreen, in case it's not connected.
17 */
18 if (ts->model == 7845)
19 - ads7845_read12_ser(&spi->dev, PWRDOWN);
20 + err = ads7845_read12_ser(&spi->dev, PWRDOWN);
21 else
22 - (void) ads7846_read12_ser(&spi->dev,
23 + err = ads7846_read12_ser(&spi->dev,
24 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
26 + /* if sample is all 0's or all 1's then there is no device on spi */
27 + if ( (err == 0x000) || (err == 0xfff)) {
28 + dev_info(&spi->dev, "no device detected, test read result was 0x%08X\n", err);
29 + err = -ENODEV;
30 + goto err_free_irq;
31 + }
32 +
33 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
34 if (err)
35 goto err_remove_hwmon;
36 @@ -1353,7 +1360,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
37 err_put_regulator:
38 regulator_put(ts->reg);
39 err_free_gpio:
40 - if (ts->gpio_pendown != -1)
41 + if (!ts->get_pendown_state && ts->gpio_pendown != -1)
42 gpio_free(ts->gpio_pendown);
43 err_cleanup_filter:
44 if (ts->filter_cleanup)
45 --
46 1.6.6.1