linux-omap 2.6.39: initial add with beagleboard support
[openembedded.git] / recipes / linux / linux-omap-2.6.39 / sakoman / 0009-drivers-input-touchscreen-ads7846-return-ENODEV-if-d.patch
blob042ab44ad0339bcfdd96190116b93643fd414ac9
1 From b1515f616ee48452a7cb2c5d0f31b1f8f4463f94 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 09/28] 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 1de1c19..097db10 100644
13 --- a/drivers/input/touchscreen/ads7846.c
14 +++ b/drivers/input/touchscreen/ads7846.c
15 @@ -1338,11 +1338,18 @@ static int __devinit ads7846_probe(struct spi_device *spi)
16 * the touchscreen, in case it's not connected.
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 + }
33 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
34 if (err)
35 goto err_remove_hwmon;
36 @@ -1366,7 +1373,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->get_pendown_state)
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