diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-02-10 18:30:29 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-02-12 17:55:08 -0500 |
commit | f7bf6f58675a76c08e6eee7fa5c264884eb5c599 (patch) | |
tree | f388e4c8c4799286b85f471326422237ed1a0e7f | |
parent | 449aa83e69ff10d77fe088eadacafe1e97937c14 (diff) |
Input: tsc2004/5 - fix regulator handling
In case of an optional regulator missing, regulator core will return
ERR_PTR(-ENOENT) and not NULL, so the check for missing regulator is
incorrect. Also, the regulator is not optional, it may simply be missing
from platform description, so let's use devm_regulator_get() and rely on
regulator core to give us dummy supply when real one is not available.
Fixes: d257f2980feb ("Input: tsc2005 - convert to gpiod")
Acked-By: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/tsc200x-core.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c index b7059ed8872e..1c14a38e3748 100644 --- a/drivers/input/touchscreen/tsc200x-core.c +++ b/drivers/input/touchscreen/tsc200x-core.c | |||
@@ -527,10 +527,10 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
527 | return error; | 527 | return error; |
528 | } | 528 | } |
529 | 529 | ||
530 | ts->vio = devm_regulator_get_optional(dev, "vio"); | 530 | ts->vio = devm_regulator_get(dev, "vio"); |
531 | if (IS_ERR(ts->vio)) { | 531 | if (IS_ERR(ts->vio)) { |
532 | error = PTR_ERR(ts->vio); | 532 | error = PTR_ERR(ts->vio); |
533 | dev_err(dev, "vio regulator missing (%d)", error); | 533 | dev_err(dev, "error acquiring vio regulator: %d", error); |
534 | return error; | 534 | return error; |
535 | } | 535 | } |
536 | 536 | ||
@@ -587,12 +587,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
587 | return error; | 587 | return error; |
588 | } | 588 | } |
589 | 589 | ||
590 | /* enable regulator for DT */ | 590 | error = regulator_enable(ts->vio); |
591 | if (ts->vio) { | 591 | if (error) |
592 | error = regulator_enable(ts->vio); | 592 | return error; |
593 | if (error) | ||
594 | return error; | ||
595 | } | ||
596 | 593 | ||
597 | dev_set_drvdata(dev, ts); | 594 | dev_set_drvdata(dev, ts); |
598 | error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); | 595 | error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); |
@@ -615,8 +612,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
615 | err_remove_sysfs: | 612 | err_remove_sysfs: |
616 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); | 613 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); |
617 | disable_regulator: | 614 | disable_regulator: |
618 | if (ts->vio) | 615 | regulator_disable(ts->vio); |
619 | regulator_disable(ts->vio); | ||
620 | return error; | 616 | return error; |
621 | } | 617 | } |
622 | EXPORT_SYMBOL_GPL(tsc200x_probe); | 618 | EXPORT_SYMBOL_GPL(tsc200x_probe); |
@@ -627,8 +623,7 @@ int tsc200x_remove(struct device *dev) | |||
627 | 623 | ||
628 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); | 624 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); |
629 | 625 | ||
630 | if (ts->vio) | 626 | regulator_disable(ts->vio); |
631 | regulator_disable(ts->vio); | ||
632 | 627 | ||
633 | return 0; | 628 | return 0; |
634 | } | 629 | } |