Commit d95f0c4e authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: tsc2004/5 - fix handling of VIO power supply

The chip needs to be powered up before calling tsc200x_stop_scan() which
communicates with it; move the call to enable the regulator earlier in
tsc200x_probe().

At the same time switch to using devm_regulator_get_enable() to simplify
error handling. This also makes sure that regulator is not shut off too
early when unbinding the driver.

Link: https://lore.kernel.org/r/20240711172719.1248373-1-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 8bd2aa85
...@@ -42,11 +42,6 @@ static int tsc2004_probe(struct i2c_client *i2c) ...@@ -42,11 +42,6 @@ static int tsc2004_probe(struct i2c_client *i2c)
tsc2004_cmd); tsc2004_cmd);
} }
static void tsc2004_remove(struct i2c_client *i2c)
{
tsc200x_remove(&i2c->dev);
}
static const struct i2c_device_id tsc2004_idtable[] = { static const struct i2c_device_id tsc2004_idtable[] = {
{ "tsc2004" }, { "tsc2004" },
{ } { }
...@@ -70,7 +65,6 @@ static struct i2c_driver tsc2004_driver = { ...@@ -70,7 +65,6 @@ static struct i2c_driver tsc2004_driver = {
}, },
.id_table = tsc2004_idtable, .id_table = tsc2004_idtable,
.probe = tsc2004_probe, .probe = tsc2004_probe,
.remove = tsc2004_remove,
}; };
module_i2c_driver(tsc2004_driver); module_i2c_driver(tsc2004_driver);
......
...@@ -64,11 +64,6 @@ static int tsc2005_probe(struct spi_device *spi) ...@@ -64,11 +64,6 @@ static int tsc2005_probe(struct spi_device *spi)
tsc2005_cmd); tsc2005_cmd);
} }
static void tsc2005_remove(struct spi_device *spi)
{
tsc200x_remove(&spi->dev);
}
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id tsc2005_of_match[] = { static const struct of_device_id tsc2005_of_match[] = {
{ .compatible = "ti,tsc2005" }, { .compatible = "ti,tsc2005" },
...@@ -85,7 +80,6 @@ static struct spi_driver tsc2005_driver = { ...@@ -85,7 +80,6 @@ static struct spi_driver tsc2005_driver = {
.pm = pm_sleep_ptr(&tsc200x_pm_ops), .pm = pm_sleep_ptr(&tsc200x_pm_ops),
}, },
.probe = tsc2005_probe, .probe = tsc2005_probe,
.remove = tsc2005_remove,
}; };
module_spi_driver(tsc2005_driver); module_spi_driver(tsc2005_driver);
......
...@@ -104,8 +104,6 @@ struct tsc200x { ...@@ -104,8 +104,6 @@ struct tsc200x {
bool pen_down; bool pen_down;
struct regulator *vio;
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
int (*tsc200x_cmd)(struct device *dev, u8 cmd); int (*tsc200x_cmd)(struct device *dev, u8 cmd);
int irq; int irq;
...@@ -495,10 +493,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, ...@@ -495,10 +493,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error; return error;
} }
ts->vio = devm_regulator_get(dev, "vio"); error = devm_regulator_get_enable(dev, "vio");
if (IS_ERR(ts->vio)) { if (error) {
error = PTR_ERR(ts->vio); dev_err(dev, "error acquiring vio regulator: %d\n", error);
dev_err(dev, "error acquiring vio regulator: %d", error);
return error; return error;
} }
...@@ -554,36 +551,20 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, ...@@ -554,36 +551,20 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error; return error;
} }
error = regulator_enable(ts->vio);
if (error)
return error;
dev_set_drvdata(dev, ts); dev_set_drvdata(dev, ts);
error = input_register_device(ts->idev); error = input_register_device(ts->idev);
if (error) { if (error) {
dev_err(dev, dev_err(dev,
"Failed to register input device, err: %d\n", error); "Failed to register input device, err: %d\n", error);
goto disable_regulator; return error;
} }
irq_set_irq_wake(irq, 1); irq_set_irq_wake(irq, 1);
return 0; return 0;
disable_regulator:
regulator_disable(ts->vio);
return error;
} }
EXPORT_SYMBOL_GPL(tsc200x_probe); EXPORT_SYMBOL_GPL(tsc200x_probe);
void tsc200x_remove(struct device *dev)
{
struct tsc200x *ts = dev_get_drvdata(dev);
regulator_disable(ts->vio);
}
EXPORT_SYMBOL_GPL(tsc200x_remove);
static int tsc200x_suspend(struct device *dev) static int tsc200x_suspend(struct device *dev)
{ {
struct tsc200x *ts = dev_get_drvdata(dev); struct tsc200x *ts = dev_get_drvdata(dev);
......
...@@ -75,6 +75,5 @@ extern const struct attribute_group *tsc200x_groups[]; ...@@ -75,6 +75,5 @@ extern const struct attribute_group *tsc200x_groups[];
int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
struct regmap *regmap, struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd)); int (*tsc200x_cmd)(struct device *dev, u8 cmd));
void tsc200x_remove(struct device *dev);
#endif #endif
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