diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2018-01-17 23:31:14 +0300 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2018-02-13 15:48:23 +0300 |
commit | 419cac572b79eda70f796c452895fefeee86a79a (patch) | |
tree | 1a0d0d5c6ce4cc1fae8135e6bbb4e255560799e8 /drivers | |
parent | 3bf4e03d199f7f2871919e33e7bfc6e3d4c3368f (diff) | |
download | linux-419cac572b79eda70f796c452895fefeee86a79a.tar.xz |
power: supply: gpio-charger: Drop driver remove function
Simplify error unwinding using devm_* allocators. This also
makes driver remove function empty, so remove it.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/supply/gpio-charger.c | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c index 001731e88718..666abc23e2ee 100644 --- a/drivers/power/supply/gpio-charger.c +++ b/drivers/power/supply/gpio-charger.c @@ -35,7 +35,6 @@ struct gpio_charger { struct power_supply *charger; struct power_supply_desc charger_desc; struct gpio_desc *gpiod; - bool legacy_gpio_requested; }; static irqreturn_t gpio_charger_irq(int irq, void *devid) @@ -159,19 +158,13 @@ static int gpio_charger_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Invalid gpio pin in pdata\n"); return -EINVAL; } - ret = gpio_request(pdata->gpio, dev_name(&pdev->dev)); + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio, GPIOF_IN, + dev_name(&pdev->dev)); if (ret) { dev_err(&pdev->dev, "Failed to request gpio pin: %d\n", ret); return ret; } - gpio_charger->legacy_gpio_requested = true; - ret = gpio_direction_input(pdata->gpio); - if (ret) { - dev_err(&pdev->dev, "Failed to set gpio to input: %d\n", - ret); - goto err_gpio_free; - } /* Then convert this to gpiod for now */ gpio_charger->gpiod = gpio_to_desc(pdata->gpio); } else if (IS_ERR(gpio_charger->gpiod)) { @@ -195,20 +188,19 @@ static int gpio_charger_probe(struct platform_device *pdev) psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = gpio_charger; - gpio_charger->pdata = pdata; - - gpio_charger->charger = power_supply_register(&pdev->dev, - charger_desc, &psy_cfg); + gpio_charger->charger = devm_power_supply_register(&pdev->dev, + charger_desc, &psy_cfg); if (IS_ERR(gpio_charger->charger)) { ret = PTR_ERR(gpio_charger->charger); dev_err(&pdev->dev, "Failed to register power supply: %d\n", ret); - goto err_gpio_free; + return ret; } irq = gpiod_to_irq(gpio_charger->gpiod); if (irq > 0) { - ret = request_any_context_irq(irq, gpio_charger_irq, + ret = devm_request_any_context_irq(&pdev->dev, irq, + gpio_charger_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, dev_name(&pdev->dev), gpio_charger->charger); if (ret < 0) @@ -222,26 +214,6 @@ static int gpio_charger_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); return 0; - -err_gpio_free: - if (gpio_charger->legacy_gpio_requested) - gpio_free(pdata->gpio); - return ret; -} - -static int gpio_charger_remove(struct platform_device *pdev) -{ - struct gpio_charger *gpio_charger = platform_get_drvdata(pdev); - - if (gpio_charger->irq) - free_irq(gpio_charger->irq, gpio_charger->charger); - - power_supply_unregister(gpio_charger->charger); - - if (gpio_charger->legacy_gpio_requested) - gpio_free(gpio_charger->pdata->gpio); - - return 0; } #ifdef CONFIG_PM_SLEEP @@ -280,7 +252,6 @@ MODULE_DEVICE_TABLE(of, gpio_charger_match); static struct platform_driver gpio_charger_driver = { .probe = gpio_charger_probe, - .remove = gpio_charger_remove, .driver = { .name = "gpio-charger", .pm = &gpio_charger_pm_ops, |