Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+4 -36
-6
drivers/input/touchscreen/tsc2004.c
··· 42 42 tsc2004_cmd); 43 43 } 44 44 45 - static void tsc2004_remove(struct i2c_client *i2c) 46 - { 47 - tsc200x_remove(&i2c->dev); 48 - } 49 - 50 45 static const struct i2c_device_id tsc2004_idtable[] = { 51 46 { "tsc2004" }, 52 47 { } ··· 65 70 }, 66 71 .id_table = tsc2004_idtable, 67 72 .probe = tsc2004_probe, 68 - .remove = tsc2004_remove, 69 73 }; 70 74 module_i2c_driver(tsc2004_driver); 71 75
-6
drivers/input/touchscreen/tsc2005.c
··· 64 64 tsc2005_cmd); 65 65 } 66 66 67 - static void tsc2005_remove(struct spi_device *spi) 68 - { 69 - tsc200x_remove(&spi->dev); 70 - } 71 - 72 67 #ifdef CONFIG_OF 73 68 static const struct of_device_id tsc2005_of_match[] = { 74 69 { .compatible = "ti,tsc2005" }, ··· 80 85 .pm = pm_sleep_ptr(&tsc200x_pm_ops), 81 86 }, 82 87 .probe = tsc2005_probe, 83 - .remove = tsc2005_remove, 84 88 }; 85 89 module_spi_driver(tsc2005_driver); 86 90
+4 -23
drivers/input/touchscreen/tsc200x-core.c
··· 104 104 105 105 bool pen_down; 106 106 107 - struct regulator *vio; 108 - 109 107 struct gpio_desc *reset_gpio; 110 108 int (*tsc200x_cmd)(struct device *dev, u8 cmd); 111 109 int irq; ··· 493 495 return error; 494 496 } 495 497 496 - ts->vio = devm_regulator_get(dev, "vio"); 497 - if (IS_ERR(ts->vio)) { 498 - error = PTR_ERR(ts->vio); 499 - dev_err(dev, "error acquiring vio regulator: %d", error); 498 + error = devm_regulator_get_enable(dev, "vio"); 499 + if (error) { 500 + dev_err(dev, "error acquiring vio regulator: %d\n", error); 500 501 return error; 501 502 } 502 503 ··· 551 554 return error; 552 555 } 553 556 554 - error = regulator_enable(ts->vio); 555 - if (error) 556 - return error; 557 - 558 557 dev_set_drvdata(dev, ts); 559 558 560 559 error = input_register_device(ts->idev); 561 560 if (error) { 562 561 dev_err(dev, 563 562 "Failed to register input device, err: %d\n", error); 564 - goto disable_regulator; 563 + return error; 565 564 } 566 565 567 566 irq_set_irq_wake(irq, 1); 568 567 return 0; 569 - 570 - disable_regulator: 571 - regulator_disable(ts->vio); 572 - return error; 573 568 } 574 569 EXPORT_SYMBOL_GPL(tsc200x_probe); 575 - 576 - void tsc200x_remove(struct device *dev) 577 - { 578 - struct tsc200x *ts = dev_get_drvdata(dev); 579 - 580 - regulator_disable(ts->vio); 581 - } 582 - EXPORT_SYMBOL_GPL(tsc200x_remove); 583 570 584 571 static int tsc200x_suspend(struct device *dev) 585 572 {
-1
drivers/input/touchscreen/tsc200x-core.h
··· 75 75 int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, 76 76 struct regmap *regmap, 77 77 int (*tsc200x_cmd)(struct device *dev, u8 cmd)); 78 - void tsc200x_remove(struct device *dev); 79 78 80 79 #endif