@@ -531,6 +531,9 @@ static ssize_t ads7846_disable_store(struct device *dev,
if (strict_strtoul(buf, 10, &i))
return -EINVAL;
+ if (!i)
+ regulator_enable(ts->reg);
+
spin_lock_irq(&ts->lock);
if (i)
@@ -540,6 +543,9 @@ static ssize_t ads7846_disable_store(struct device *dev,
spin_unlock_irq(&ts->lock);
+ if (i)
+ regulator_disable(ts->reg);
+
return count;
}
@@ -855,8 +861,6 @@ 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
*/
@@ -868,8 +872,6 @@ 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);
@@ -886,6 +888,8 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
spin_unlock_irq(&ts->lock);
+ regulator_disable(ts->reg);
+
if (device_may_wakeup(&ts->spi->dev))
enable_irq_wake(ts->spi->irq);
@@ -900,6 +904,8 @@ static int ads7846_resume(struct spi_device *spi)
if (device_may_wakeup(&ts->spi->dev))
disable_irq_wake(ts->spi->irq);
+ regulator_enable(ts->reg);
+
spin_lock_irq(&ts->lock);
ts->is_suspended = 0;