aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2015-01-18 06:39:26 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-01-20 05:18:28 -0500
commitf91b2dbba5fdbe2d211aa8a4b353a8d3b5126f45 (patch)
tree417fdefc3db6157aa3c3452f2c8f3d447d29083a /drivers/gpio
parent1dfb4a0d7615811ec4a61b0a7631c8ddc0baf335 (diff)
gpio: mpc5200: 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: Alexandre Courbot <gnurou@gmail.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> 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-mpc5200.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c
index 8ce6c9510035..4c542153e923 100644
--- a/drivers/gpio/gpio-mpc5200.c
+++ b/drivers/gpio/gpio-mpc5200.c
@@ -155,10 +155,12 @@ static int mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev)
155 struct gpio_chip *gc; 155 struct gpio_chip *gc;
156 int ret; 156 int ret;
157 157
158 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 158 chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL);
159 if (!chip) 159 if (!chip)
160 return -ENOMEM; 160 return -ENOMEM;
161 161
162 platform_set_drvdata(ofdev, chip);
163
162 gc = &chip->mmchip.gc; 164 gc = &chip->mmchip.gc;
163 165
164 gc->ngpio = 8; 166 gc->ngpio = 8;
@@ -181,7 +183,11 @@ static int mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev)
181 183
182static int mpc52xx_gpiochip_remove(struct platform_device *ofdev) 184static int mpc52xx_gpiochip_remove(struct platform_device *ofdev)
183{ 185{
184 return -EBUSY; 186 struct mpc52xx_gpiochip *chip = platform_get_drvdata(ofdev);
187
188 of_mm_gpiochip_remove(&chip->mmchip);
189
190 return 0;
185} 191}
186 192
187static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = { 193static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = {
@@ -314,10 +320,12 @@ static int mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev)
314 struct mpc52xx_gpio __iomem *regs; 320 struct mpc52xx_gpio __iomem *regs;
315 int ret; 321 int ret;
316 322
317 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 323 chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL);
318 if (!chip) 324 if (!chip)
319 return -ENOMEM; 325 return -ENOMEM;
320 326
327 platform_set_drvdata(ofdev, chip);
328
321 gc = &chip->mmchip.gc; 329 gc = &chip->mmchip.gc;
322 330
323 gc->ngpio = 32; 331 gc->ngpio = 32;
@@ -363,11 +371,16 @@ static int __init mpc52xx_gpio_init(void)
363 return 0; 371 return 0;
364} 372}
365 373
366
367/* Make sure we get initialised before anyone else tries to use us */ 374/* Make sure we get initialised before anyone else tries to use us */
368subsys_initcall(mpc52xx_gpio_init); 375subsys_initcall(mpc52xx_gpio_init);
369 376
370/* No exit call at the moment as we cannot unregister of gpio chips */ 377static void __exit mpc52xx_gpio_exit(void)
378{
379 platform_driver_unregister(&mpc52xx_wkup_gpiochip_driver);
380
381 platform_driver_unregister(&mpc52xx_simple_gpiochip_driver);
382}
383module_exit(mpc52xx_gpio_exit);
371 384
372MODULE_DESCRIPTION("Freescale MPC52xx gpio driver"); 385MODULE_DESCRIPTION("Freescale MPC52xx gpio driver");
373MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de"); 386MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");