From: Imre Deak Date: Fri, 10 Feb 2006 15:40:49 +0000 (+0200) Subject: ads7846: add pen_down sysfs attribute X-Git-Tag: v2.6.16-omap1~66 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=8d40dae80bda99f88304c43782a8b7a63c797cb9;p=linux-2.6-omap-h63xx.git ads7846: add pen_down sysfs attribute User-space needs to know about the pen down status for detecting whether the touchscreen is "stuck" (i.e. is shortcircuited). Signed-off-by: Imre Deak Signed-off-by: Juha Yrjölä --- diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 54462cc1e50..45823dce755 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -235,6 +235,21 @@ SHOW(temp1) SHOW(vaux) SHOW(vbatt) +static int is_pen_down(struct device *dev) +{ + struct ads7846 *ts = dev_get_drvdata(dev); + + return ts->pendown; +} + +static ssize_t ads7846_pen_down_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", is_pen_down(dev)); +} + +static DEVICE_ATTR(pen_down, S_IRUGO, ads7846_pen_down_show, NULL); + /*--------------------------------------------------------------------------*/ /* @@ -573,6 +588,8 @@ static int __devinit ads7846_probe(struct spi_device *spi) device_create_file(&spi->dev, &dev_attr_vbatt); device_create_file(&spi->dev, &dev_attr_vaux); + device_create_file(&spi->dev, &dev_attr_pen_down); + err = input_register_device(input_dev); if (err) goto err_free_irq; @@ -596,6 +613,8 @@ static int __devexit ads7846_remove(struct spi_device *spi) if (ts->irq_disabled) enable_irq(ts->spi->irq); + device_remove_file(&spi->dev, &dev_attr_pen_down); + if (ts->model == 7846) { device_remove_file(&spi->dev, &dev_attr_temp0); device_remove_file(&spi->dev, &dev_attr_temp1);