diff options
Diffstat (limited to 'drivers/regulator/fixed.c')
-rw-r--r-- | drivers/regulator/fixed.c | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index ae16df8a0c..0edb5ceb10 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -9,13 +9,10 @@ #include <init.h> #include <regulator.h> #include <of.h> -#include <of_gpio.h> -#include <gpio.h> -#include <gpiod.h> +#include <linux/gpio/consumer.h> struct regulator_fixed { - int gpio; - int always_on; + struct gpio_desc *gpio; struct regulator_dev rdev; struct regulator_desc rdesc; }; @@ -24,23 +21,14 @@ static int regulator_fixed_enable(struct regulator_dev *rdev) { struct regulator_fixed *fix = container_of(rdev, struct regulator_fixed, rdev); - if (!gpio_is_valid(fix->gpio)) - return 0; - - return gpio_direction_active(fix->gpio, true); + return gpiod_direction_output(fix->gpio, true); } static int regulator_fixed_disable(struct regulator_dev *rdev) { struct regulator_fixed *fix = container_of(rdev, struct regulator_fixed, rdev); - if (fix->always_on) - return 0; - - if (!gpio_is_valid(fix->gpio)) - return 0; - - return gpio_direction_active(fix->gpio, false); + return gpiod_direction_output(fix->gpio, false); } const static struct regulator_ops fixed_ops = { @@ -48,25 +36,22 @@ const static struct regulator_ops fixed_ops = { .disable = regulator_fixed_disable, }; -static int regulator_fixed_probe(struct device_d *dev) +static int regulator_fixed_probe(struct device *dev) { - struct device_node *np = dev->device_node; + struct device_node *np = dev->of_node; struct regulator_fixed *fix; u32 delay; int ret; - if (!dev->device_node) + if (!dev->of_node) return -EINVAL; fix = xzalloc(sizeof(*fix)); - fix->gpio = -EINVAL; - - if (of_get_property(np, "gpio", NULL)) { - fix->gpio = gpiod_get(dev, NULL, GPIOD_ASIS); - if (fix->gpio < 0) { - ret = fix->gpio; - goto err; - } + + fix->gpio = gpiod_get_optional(dev, NULL, GPIOD_ASIS); + if (IS_ERR(fix->gpio)) { + ret = PTR_ERR(fix->gpio); + goto err; } fix->rdesc.ops = &fixed_ops; @@ -76,15 +61,12 @@ static int regulator_fixed_probe(struct device_d *dev) if (!of_property_read_u32(np, "off-on-delay-us", &delay)) fix->rdesc.off_on_delay = delay; - if (of_find_property(np, "regulator-always-on", NULL) || - of_find_property(np, "regulator-boot-on", NULL)) { - fix->always_on = 1; - regulator_fixed_enable(&fix->rdev); - } + if (of_find_property(np, "vin-supply", NULL)) + fix->rdesc.supply_name = "vin"; ret = of_regulator_register(&fix->rdev, np); if (ret) - return ret; + goto err; return 0; err: @@ -97,8 +79,9 @@ static struct of_device_id regulator_fixed_of_ids[] = { { .compatible = "regulator-fixed", }, { } }; +MODULE_DEVICE_TABLE(of, regulator_fixed_of_ids); -static struct driver_d regulator_fixed_driver = { +static struct driver regulator_fixed_driver = { .name = "regulator-fixed", .probe = regulator_fixed_probe, .of_compatible = DRV_OF_COMPAT(regulator_fixed_of_ids), |