Commit fbc8ab2c authored by Andrew Davis's avatar Andrew Davis Committed by Bartosz Golaszewski

gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path

Use devm version of gpiochip add function to handle removal for us.
Signed-off-by: default avatarAndrew Davis <afd@ti.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 2148a7ac
...@@ -492,18 +492,6 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, ...@@ -492,18 +492,6 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev,
return omap_twl_info; return omap_twl_info;
} }
/* Cannot use as gpio_twl4030_probe() calls us */
static int gpio_twl4030_remove(struct platform_device *pdev)
{
struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev);
gpiochip_remove(&priv->gpio_chip);
/* REVISIT no support yet for deregistering all the IRQs */
WARN_ON(!is_module());
return 0;
}
static int gpio_twl4030_probe(struct platform_device *pdev) static int gpio_twl4030_probe(struct platform_device *pdev)
{ {
struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
...@@ -577,16 +565,13 @@ static int gpio_twl4030_probe(struct platform_device *pdev) ...@@ -577,16 +565,13 @@ static int gpio_twl4030_probe(struct platform_device *pdev)
if (pdata->use_leds) if (pdata->use_leds)
priv->gpio_chip.ngpio += 2; priv->gpio_chip.ngpio += 2;
ret = gpiochip_add_data(&priv->gpio_chip, priv); ret = devm_gpiochip_add_data(&pdev->dev, &priv->gpio_chip, priv);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
priv->gpio_chip.ngpio = 0; priv->gpio_chip.ngpio = 0;
gpio_twl4030_remove(pdev); return ret;
goto out;
} }
platform_set_drvdata(pdev, priv);
if (pdata->setup) { if (pdata->setup) {
int status; int status;
...@@ -596,8 +581,7 @@ static int gpio_twl4030_probe(struct platform_device *pdev) ...@@ -596,8 +581,7 @@ static int gpio_twl4030_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "setup --> %d\n", status); dev_dbg(&pdev->dev, "setup --> %d\n", status);
} }
out: return 0;
return ret;
} }
static const struct of_device_id twl_gpio_match[] = { static const struct of_device_id twl_gpio_match[] = {
...@@ -615,7 +599,6 @@ static struct platform_driver gpio_twl4030_driver = { ...@@ -615,7 +599,6 @@ static struct platform_driver gpio_twl4030_driver = {
.of_match_table = twl_gpio_match, .of_match_table = twl_gpio_match,
}, },
.probe = gpio_twl4030_probe, .probe = gpio_twl4030_probe,
.remove = gpio_twl4030_remove,
}; };
static int __init gpio_twl4030_init(void) static int __init gpio_twl4030_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment