aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2015-01-18 06:39:32 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-01-20 05:19:01 -0500
commit98686d9a52eeeab83a33fca5c19448954d109458 (patch)
tree98131a7804fdc378c388499050dc56c69bf43388 /drivers/gpio
parentff00be69fd95ea02b1274ea2ea1474727adeffd5 (diff)
gpio: mpc8xxx: Convert to platform device interface.
This way we do not need to transverse the device tree manually. Cc: Grant Likely <grant.likely@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: devicetree@vger.kernel.org Acked-by: Peter Korsgaard <peter@korsgaard.com> Acked-by: Alexandre Courbot <acourbot@nvidia.com> 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.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index d1ff879e6ff2..57eb794b6fc9 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -15,6 +15,7 @@
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_gpio.h> 16#include <linux/of_gpio.h>
17#include <linux/of_irq.h> 17#include <linux/of_irq.h>
18#include <linux/of_platform.h>
18#include <linux/gpio.h> 19#include <linux/gpio.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
20#include <linux/irq.h> 21#include <linux/irq.h>
@@ -342,8 +343,9 @@ static struct of_device_id mpc8xxx_gpio_ids[] __initdata = {
342 {} 343 {}
343}; 344};
344 345
345static void __init mpc8xxx_add_controller(struct device_node *np) 346static int mpc8xxx_probe(struct platform_device *pdev)
346{ 347{
348 struct device_node *np = pdev->dev.of_node;
347 struct mpc8xxx_gpio_chip *mpc8xxx_gc; 349 struct mpc8xxx_gpio_chip *mpc8xxx_gc;
348 struct of_mm_gpio_chip *mm_gc; 350 struct of_mm_gpio_chip *mm_gc;
349 struct gpio_chip *gc; 351 struct gpio_chip *gc;
@@ -351,11 +353,9 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
351 unsigned hwirq; 353 unsigned hwirq;
352 int ret; 354 int ret;
353 355
354 mpc8xxx_gc = kzalloc(sizeof(*mpc8xxx_gc), GFP_KERNEL); 356 mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL);
355 if (!mpc8xxx_gc) { 357 if (!mpc8xxx_gc)
356 ret = -ENOMEM; 358 return -ENOMEM;
357 goto err;
358 }
359 359
360 spin_lock_init(&mpc8xxx_gc->lock); 360 spin_lock_init(&mpc8xxx_gc->lock);
361 361
@@ -375,16 +375,16 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
375 375
376 ret = of_mm_gpiochip_add(np, mm_gc); 376 ret = of_mm_gpiochip_add(np, mm_gc);
377 if (ret) 377 if (ret)
378 goto err; 378 return ret;
379 379
380 hwirq = irq_of_parse_and_map(np, 0); 380 hwirq = irq_of_parse_and_map(np, 0);
381 if (hwirq == NO_IRQ) 381 if (hwirq == NO_IRQ)
382 goto skip_irq; 382 return 0;
383 383
384 mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, 384 mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS,
385 &mpc8xxx_gpio_irq_ops, mpc8xxx_gc); 385 &mpc8xxx_gpio_irq_ops, mpc8xxx_gc);
386 if (!mpc8xxx_gc->irq) 386 if (!mpc8xxx_gc->irq)
387 goto skip_irq; 387 return 0;
388 388
389 id = of_match_node(mpc8xxx_gpio_ids, np); 389 id = of_match_node(mpc8xxx_gpio_ids, np);
390 if (id) 390 if (id)
@@ -397,24 +397,20 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
397 irq_set_handler_data(hwirq, mpc8xxx_gc); 397 irq_set_handler_data(hwirq, mpc8xxx_gc);
398 irq_set_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade); 398 irq_set_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade);
399 399
400skip_irq: 400 return 0;
401 return;
402
403err:
404 pr_err("%s: registration failed with status %d\n",
405 np->full_name, ret);
406 kfree(mpc8xxx_gc);
407
408 return;
409} 401}
410 402
411static int __init mpc8xxx_add_gpiochips(void) 403static struct platform_driver mpc8xxx_plat_driver = {
412{ 404 .probe = mpc8xxx_probe,
413 struct device_node *np; 405 .driver = {
414 406 .name = "gpio-mpc8xxx",
415 for_each_matching_node(np, mpc8xxx_gpio_ids) 407 .of_match_table = mpc8xxx_gpio_ids,
416 mpc8xxx_add_controller(np); 408 },
409};
417 410
418 return 0; 411static int __init mpc8xxx_init(void)
412{
413 return platform_driver_register(&mpc8xxx_plat_driver);
419} 414}
420arch_initcall(mpc8xxx_add_gpiochips); 415
416arch_initcall(mpc8xxx_init);