Commit ae25dbac authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: cyttsp - use devm_regulator_bulk_get_enable()

The driver does not try to power down the rails at system suspend or
when touchscreen is not in use, but rather enables regulators at probe
time. Power savings are achieved by requesting the controller to enter
low power mode.

Switch to devm_regulator_bulk_get_enable() instead of separately
requesting regulators, enabling them, and installing a custom
devm-action to disable them on unbind/remove, which simplifies the
code.
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/ZrAgj9rG6oVqfdoK@google.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 7925312e
...@@ -614,17 +614,14 @@ static int cyttsp_parse_properties(struct cyttsp *ts) ...@@ -614,17 +614,14 @@ static int cyttsp_parse_properties(struct cyttsp *ts)
return 0; return 0;
} }
static void cyttsp_disable_regulators(void *_ts)
{
struct cyttsp *ts = _ts;
regulator_bulk_disable(ARRAY_SIZE(ts->regulators),
ts->regulators);
}
struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
struct device *dev, int irq, size_t xfer_buf_size) struct device *dev, int irq, size_t xfer_buf_size)
{ {
/*
* VCPIN is the analog voltage supply
* VDD is the digital voltage supply
*/
static const char * const supplies[] = { "vcpin", "vdd" };
struct cyttsp *ts; struct cyttsp *ts;
struct input_dev *input_dev; struct input_dev *input_dev;
int error; int error;
...@@ -642,29 +639,10 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, ...@@ -642,29 +639,10 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
ts->bus_ops = bus_ops; ts->bus_ops = bus_ops;
ts->irq = irq; ts->irq = irq;
/* error = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
* VCPIN is the analog voltage supply supplies);
* VDD is the digital voltage supply
*/
ts->regulators[0].supply = "vcpin";
ts->regulators[1].supply = "vdd";
error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators),
ts->regulators);
if (error) {
dev_err(dev, "Failed to get regulators: %d\n", error);
return ERR_PTR(error);
}
error = regulator_bulk_enable(ARRAY_SIZE(ts->regulators),
ts->regulators);
if (error) {
dev_err(dev, "Cannot enable regulators: %d\n", error);
return ERR_PTR(error);
}
error = devm_add_action_or_reset(dev, cyttsp_disable_regulators, ts);
if (error) { if (error) {
dev_err(dev, "failed to install chip disable handler\n"); dev_err(dev, "Failed to enable regulators: %d\n", error);
return ERR_PTR(error); return ERR_PTR(error);
} }
......
...@@ -122,7 +122,6 @@ struct cyttsp { ...@@ -122,7 +122,6 @@ struct cyttsp {
enum cyttsp_state state; enum cyttsp_state state;
bool suspended; bool suspended;
struct regulator_bulk_data regulators[2];
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
bool use_hndshk; bool use_hndshk;
u8 act_dist; u8 act_dist;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment