]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
Input: tsc2004/5 - fix regulator handling
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 10 Feb 2017 23:30:29 +0000 (15:30 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 12 Feb 2017 22:55:08 +0000 (14:55 -0800)
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>
drivers/input/touchscreen/tsc200x-core.c

index b7059ed8872e40b77eed45e33808ba4b135485c4..1c14a38e37483b5749139528b478c712dbb6693c 100644 (file)
@@ -527,10 +527,10 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
                return error;
        }
 
-       ts->vio = devm_regulator_get_optional(dev, "vio");
+       ts->vio = devm_regulator_get(dev, "vio");
        if (IS_ERR(ts->vio)) {
                error = PTR_ERR(ts->vio);
-               dev_err(dev, "vio regulator missing (%d)", error);
+               dev_err(dev, "error acquiring vio regulator: %d", error);
                return error;
        }
 
@@ -587,12 +587,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
                return error;
        }
 
-       /* enable regulator for DT */
-       if (ts->vio) {
-               error = regulator_enable(ts->vio);
-               if (error)
-                       return error;
-       }
+       error = regulator_enable(ts->vio);
+       if (error)
+               return error;
 
        dev_set_drvdata(dev, ts);
        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,
 err_remove_sysfs:
        sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
 disable_regulator:
-       if (ts->vio)
-               regulator_disable(ts->vio);
+       regulator_disable(ts->vio);
        return error;
 }
 EXPORT_SYMBOL_GPL(tsc200x_probe);
@@ -627,8 +623,7 @@ int tsc200x_remove(struct device *dev)
 
        sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
 
-       if (ts->vio)
-               regulator_disable(ts->vio);
+       regulator_disable(ts->vio);
 
        return 0;
 }