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>
This commit is contained in:
parent
3bf4e03d19
commit
419cac572b
|
@ -35,7 +35,6 @@ struct gpio_charger {
|
||||||
struct power_supply *charger;
|
struct power_supply *charger;
|
||||||
struct power_supply_desc charger_desc;
|
struct power_supply_desc charger_desc;
|
||||||
struct gpio_desc *gpiod;
|
struct gpio_desc *gpiod;
|
||||||
bool legacy_gpio_requested;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static irqreturn_t gpio_charger_irq(int irq, void *devid)
|
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");
|
dev_err(&pdev->dev, "Invalid gpio pin in pdata\n");
|
||||||
return -EINVAL;
|
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) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "Failed to request gpio pin: %d\n",
|
dev_err(&pdev->dev, "Failed to request gpio pin: %d\n",
|
||||||
ret);
|
ret);
|
||||||
return 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 */
|
/* Then convert this to gpiod for now */
|
||||||
gpio_charger->gpiod = gpio_to_desc(pdata->gpio);
|
gpio_charger->gpiod = gpio_to_desc(pdata->gpio);
|
||||||
} else if (IS_ERR(gpio_charger->gpiod)) {
|
} 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.of_node = pdev->dev.of_node;
|
||||||
psy_cfg.drv_data = gpio_charger;
|
psy_cfg.drv_data = gpio_charger;
|
||||||
|
|
||||||
gpio_charger->pdata = pdata;
|
gpio_charger->charger = devm_power_supply_register(&pdev->dev,
|
||||||
|
|
||||||
gpio_charger->charger = power_supply_register(&pdev->dev,
|
|
||||||
charger_desc, &psy_cfg);
|
charger_desc, &psy_cfg);
|
||||||
if (IS_ERR(gpio_charger->charger)) {
|
if (IS_ERR(gpio_charger->charger)) {
|
||||||
ret = PTR_ERR(gpio_charger->charger);
|
ret = PTR_ERR(gpio_charger->charger);
|
||||||
dev_err(&pdev->dev, "Failed to register power supply: %d\n",
|
dev_err(&pdev->dev, "Failed to register power supply: %d\n",
|
||||||
ret);
|
ret);
|
||||||
goto err_gpio_free;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
irq = gpiod_to_irq(gpio_charger->gpiod);
|
irq = gpiod_to_irq(gpio_charger->gpiod);
|
||||||
if (irq > 0) {
|
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,
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||||
dev_name(&pdev->dev), gpio_charger->charger);
|
dev_name(&pdev->dev), gpio_charger->charger);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -222,26 +214,6 @@ static int gpio_charger_probe(struct platform_device *pdev)
|
||||||
device_init_wakeup(&pdev->dev, 1);
|
device_init_wakeup(&pdev->dev, 1);
|
||||||
|
|
||||||
return 0;
|
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
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
@ -280,7 +252,6 @@ MODULE_DEVICE_TABLE(of, gpio_charger_match);
|
||||||
|
|
||||||
static struct platform_driver gpio_charger_driver = {
|
static struct platform_driver gpio_charger_driver = {
|
||||||
.probe = gpio_charger_probe,
|
.probe = gpio_charger_probe,
|
||||||
.remove = gpio_charger_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "gpio-charger",
|
.name = "gpio-charger",
|
||||||
.pm = &gpio_charger_pm_ops,
|
.pm = &gpio_charger_pm_ops,
|
||||||
|
|
Loading…
Reference in New Issue