Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 183142
b: refs/heads/master
c: 9114337
h: refs/heads/master
v: v3
  • Loading branch information
Grazvydas Ignotas authored and Dmitry Torokhov committed Feb 25, 2010
1 parent 2c26130 commit b04364f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a1e1274747b2741188b554e35dc5d4056ef7beac
refs/heads/master: 91143379b01b2020d8878d627ebe9dfb9d6eb4c8
28 changes: 27 additions & 1 deletion trunk/drivers/input/touchscreen/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
#include <linux/regulator/consumer.h>
#include <asm/irq.h>

/*
Expand Down Expand Up @@ -85,6 +86,7 @@ struct ads7846 {
char name[32];

struct spi_device *spi;
struct regulator *reg;

#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
struct attribute_group *attr_group;
Expand Down Expand Up @@ -788,6 +790,8 @@ static void ads7846_disable(struct ads7846 *ts)
}
}

regulator_disable(ts->reg);

/* we know the chip's in lowpower mode since we always
* leave it that way after every request
*/
Expand All @@ -799,6 +803,8 @@ static void ads7846_enable(struct ads7846 *ts)
if (!ts->disabled)
return;

regulator_enable(ts->reg);

ts->disabled = 0;
ts->irq_disabled = 0;
enable_irq(ts->spi->irq);
Expand Down Expand Up @@ -1139,6 +1145,19 @@ static int __devinit ads7846_probe(struct spi_device *spi)

ts->last_msg = m;

ts->reg = regulator_get(&spi->dev, "vcc");
if (IS_ERR(ts->reg)) {
dev_err(&spi->dev, "unable to get regulator: %ld\n",
PTR_ERR(ts->reg));
goto err_free_gpio;
}

err = regulator_enable(ts->reg);
if (err) {
dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
goto err_put_regulator;
}

if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
spi->dev.driver->name, ts)) {
dev_info(&spi->dev,
Expand All @@ -1148,7 +1167,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
spi->dev.driver->name, ts);
if (err) {
dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
goto err_free_gpio;
goto err_disable_regulator;
}
}

Expand Down Expand Up @@ -1180,6 +1199,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
ads784x_hwmon_unregister(spi, ts);
err_free_irq:
free_irq(spi->irq, ts);
err_disable_regulator:
regulator_disable(ts->reg);
err_put_regulator:
regulator_put(ts->reg);
err_free_gpio:
if (ts->gpio_pendown != -1)
gpio_free(ts->gpio_pendown);
Expand Down Expand Up @@ -1208,6 +1231,9 @@ static int __devexit ads7846_remove(struct spi_device *spi)
/* suspend left the IRQ disabled */
enable_irq(ts->spi->irq);

regulator_disable(ts->reg);
regulator_put(ts->reg);

if (ts->gpio_pendown != -1)
gpio_free(ts->gpio_pendown);

Expand Down

0 comments on commit b04364f

Please sign in to comment.