Commit 2a9a2cca authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Bartosz Golaszewski

gpio: stmpe: fully use convert probe to device-managed

The IRQ is registered via devm_request_threaded_irq(), making the driver
only partially device-managed. This changeset converts the entire driver
to using only devres APIs.

This change also removes platform_set_drvdata() since the information is
never retrieved to be used in the driver.
Signed-off-by: default avatarAlexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
[Bart: tweaked the commit message]
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 6453b953
...@@ -449,6 +449,11 @@ static void stmpe_init_irq_valid_mask(struct gpio_chip *gc, ...@@ -449,6 +449,11 @@ static void stmpe_init_irq_valid_mask(struct gpio_chip *gc,
} }
} }
static void stmpe_gpio_disable(void *stmpe)
{
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
}
static int stmpe_gpio_probe(struct platform_device *pdev) static int stmpe_gpio_probe(struct platform_device *pdev)
{ {
struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
...@@ -461,7 +466,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) ...@@ -461,7 +466,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL); stmpe_gpio = devm_kzalloc(&pdev->dev, sizeof(*stmpe_gpio), GFP_KERNEL);
if (!stmpe_gpio) if (!stmpe_gpio)
return -ENOMEM; return -ENOMEM;
...@@ -489,7 +494,11 @@ static int stmpe_gpio_probe(struct platform_device *pdev) ...@@ -489,7 +494,11 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO); ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO);
if (ret) if (ret)
goto out_free; return ret;
ret = devm_add_action_or_reset(&pdev->dev, stmpe_gpio_disable, stmpe);
if (ret)
return ret;
if (irq > 0) { if (irq > 0) {
struct gpio_irq_chip *girq; struct gpio_irq_chip *girq;
...@@ -499,7 +508,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) ...@@ -499,7 +508,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
"stmpe-gpio", stmpe_gpio); "stmpe-gpio", stmpe_gpio);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to get irq: %d\n", ret); dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
goto out_disable; return ret;
} }
girq = &stmpe_gpio->chip.irq; girq = &stmpe_gpio->chip.irq;
...@@ -514,22 +523,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) ...@@ -514,22 +523,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
girq->init_valid_mask = stmpe_init_irq_valid_mask; girq->init_valid_mask = stmpe_init_irq_valid_mask;
} }
ret = gpiochip_add_data(&stmpe_gpio->chip, stmpe_gpio); return devm_gpiochip_add_data(&pdev->dev, &stmpe_gpio->chip, stmpe_gpio);
if (ret) {
dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
goto out_disable;
}
platform_set_drvdata(pdev, stmpe_gpio);
return 0;
out_disable:
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
gpiochip_remove(&stmpe_gpio->chip);
out_free:
kfree(stmpe_gpio);
return ret;
} }
static struct platform_driver stmpe_gpio_driver = { static struct platform_driver stmpe_gpio_driver = {
......
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