Skip to content

Commit

Permalink
gpio: mpc8xxx: Use of_mm_gpiochip_remove
Browse files Browse the repository at this point in the history
Since d621e8b (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 <[email protected]>
Cc: Alexandre Courbot <[email protected]>
Cc: Peter Korsgaard <[email protected]>
Signed-off-by: Ricardo Ribalda Delgado <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
ribalda authored and linusw committed Jan 21, 2015
1 parent 0da094d commit 257e107
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions drivers/gpio/gpio-mpc8xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct mpc8xxx_gpio_chip {
*/
u32 data;
struct irq_domain *irq;
unsigned int irqn;
const void *of_dev_id_data;
};

Expand Down Expand Up @@ -350,13 +351,14 @@ static int mpc8xxx_probe(struct platform_device *pdev)
struct of_mm_gpio_chip *mm_gc;
struct gpio_chip *gc;
const struct of_device_id *id;
unsigned hwirq;
int ret;

mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL);
if (!mpc8xxx_gc)
return -ENOMEM;

platform_set_drvdata(pdev, mpc8xxx_gc);

spin_lock_init(&mpc8xxx_gc->lock);

mm_gc = &mpc8xxx_gc->mm_gc;
Expand All @@ -377,8 +379,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
if (ret)
return ret;

hwirq = irq_of_parse_and_map(np, 0);
if (hwirq == NO_IRQ)
mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0);
if (mpc8xxx_gc->irqn == NO_IRQ)
return 0;

mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS,
Expand All @@ -394,14 +396,30 @@ static int mpc8xxx_probe(struct platform_device *pdev)
out_be32(mm_gc->regs + GPIO_IER, 0xffffffff);
out_be32(mm_gc->regs + GPIO_IMR, 0);

irq_set_handler_data(hwirq, mpc8xxx_gc);
irq_set_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade);
irq_set_handler_data(mpc8xxx_gc->irqn, mpc8xxx_gc);
irq_set_chained_handler(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade);

return 0;
}

static int mpc8xxx_remove(struct platform_device *pdev)
{
struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);

if (mpc8xxx_gc->irq) {
irq_set_handler_data(mpc8xxx_gc->irqn, NULL);
irq_set_chained_handler(mpc8xxx_gc->irqn, NULL);
irq_domain_remove(mpc8xxx_gc->irq);
}

of_mm_gpiochip_remove(&mpc8xxx_gc->mm_gc);

return 0;
}

static struct platform_driver mpc8xxx_plat_driver = {
.probe = mpc8xxx_probe,
.remove = mpc8xxx_remove,
.driver = {
.name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids,
Expand Down

0 comments on commit 257e107

Please sign in to comment.