diff options
author | Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> | 2015-01-18 06:39:33 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-01-21 11:45:11 -0500 |
commit | 257e10752c13f2698d53e5df1744f4d7e41fdfa7 (patch) | |
tree | 7eea4518ffa1b107815910f56a101c043d5eaa51 /drivers/gpio | |
parent | 0da094d82c2741c58eb298d13386a95c7ab92dc7 (diff) |
gpio: mpc8xxx: Use of_mm_gpiochip_remove
Since d621e8bae5ac9c67 (Create of_mm_gpiochip_remove), there is a
counterpart for of_mm_gpiochip_add.
This patch implements the remove function of the driver making use of
it.
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-mpc8xxx.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 57eb794b6fc9..a6952ba343a8 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c | |||
@@ -40,6 +40,7 @@ struct mpc8xxx_gpio_chip { | |||
40 | */ | 40 | */ |
41 | u32 data; | 41 | u32 data; |
42 | struct irq_domain *irq; | 42 | struct irq_domain *irq; |
43 | unsigned int irqn; | ||
43 | const void *of_dev_id_data; | 44 | const void *of_dev_id_data; |
44 | }; | 45 | }; |
45 | 46 | ||
@@ -350,13 +351,14 @@ static int mpc8xxx_probe(struct platform_device *pdev) | |||
350 | struct of_mm_gpio_chip *mm_gc; | 351 | struct of_mm_gpio_chip *mm_gc; |
351 | struct gpio_chip *gc; | 352 | struct gpio_chip *gc; |
352 | const struct of_device_id *id; | 353 | const struct of_device_id *id; |
353 | unsigned hwirq; | ||
354 | int ret; | 354 | int ret; |
355 | 355 | ||
356 | mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); | 356 | mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); |
357 | if (!mpc8xxx_gc) | 357 | if (!mpc8xxx_gc) |
358 | return -ENOMEM; | 358 | return -ENOMEM; |
359 | 359 | ||
360 | platform_set_drvdata(pdev, mpc8xxx_gc); | ||
361 | |||
360 | spin_lock_init(&mpc8xxx_gc->lock); | 362 | spin_lock_init(&mpc8xxx_gc->lock); |
361 | 363 | ||
362 | mm_gc = &mpc8xxx_gc->mm_gc; | 364 | mm_gc = &mpc8xxx_gc->mm_gc; |
@@ -377,8 +379,8 @@ static int mpc8xxx_probe(struct platform_device *pdev) | |||
377 | if (ret) | 379 | if (ret) |
378 | return ret; | 380 | return ret; |
379 | 381 | ||
380 | hwirq = irq_of_parse_and_map(np, 0); | 382 | mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0); |
381 | if (hwirq == NO_IRQ) | 383 | if (mpc8xxx_gc->irqn == NO_IRQ) |
382 | return 0; | 384 | return 0; |
383 | 385 | ||
384 | mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, | 386 | mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, |
@@ -394,14 +396,30 @@ static int mpc8xxx_probe(struct platform_device *pdev) | |||
394 | out_be32(mm_gc->regs + GPIO_IER, 0xffffffff); | 396 | out_be32(mm_gc->regs + GPIO_IER, 0xffffffff); |
395 | out_be32(mm_gc->regs + GPIO_IMR, 0); | 397 | out_be32(mm_gc->regs + GPIO_IMR, 0); |
396 | 398 | ||
397 | irq_set_handler_data(hwirq, mpc8xxx_gc); | 399 | irq_set_handler_data(mpc8xxx_gc->irqn, mpc8xxx_gc); |
398 | irq_set_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade); | 400 | irq_set_chained_handler(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade); |
401 | |||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | static int mpc8xxx_remove(struct platform_device *pdev) | ||
406 | { | ||
407 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev); | ||
408 | |||
409 | if (mpc8xxx_gc->irq) { | ||
410 | irq_set_handler_data(mpc8xxx_gc->irqn, NULL); | ||
411 | irq_set_chained_handler(mpc8xxx_gc->irqn, NULL); | ||
412 | irq_domain_remove(mpc8xxx_gc->irq); | ||
413 | } | ||
414 | |||
415 | of_mm_gpiochip_remove(&mpc8xxx_gc->mm_gc); | ||
399 | 416 | ||
400 | return 0; | 417 | return 0; |
401 | } | 418 | } |
402 | 419 | ||
403 | static struct platform_driver mpc8xxx_plat_driver = { | 420 | static struct platform_driver mpc8xxx_plat_driver = { |
404 | .probe = mpc8xxx_probe, | 421 | .probe = mpc8xxx_probe, |
422 | .remove = mpc8xxx_remove, | ||
405 | .driver = { | 423 | .driver = { |
406 | .name = "gpio-mpc8xxx", | 424 | .name = "gpio-mpc8xxx", |
407 | .of_match_table = mpc8xxx_gpio_ids, | 425 | .of_match_table = mpc8xxx_gpio_ids, |