aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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");