Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ricardo Ribalda Delgado and committed by
Linus Walleij
f91b2dbb 1dfb4a0d

+18 -5
+18 -5
drivers/gpio/gpio-mpc5200.c
··· 155 155 struct gpio_chip *gc; 156 156 int ret; 157 157 158 - chip = kzalloc(sizeof(*chip), GFP_KERNEL); 158 + chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL); 159 159 if (!chip) 160 160 return -ENOMEM; 161 + 162 + platform_set_drvdata(ofdev, chip); 161 163 162 164 gc = &chip->mmchip.gc; 163 165 ··· 183 181 184 182 static int mpc52xx_gpiochip_remove(struct platform_device *ofdev) 185 183 { 186 - return -EBUSY; 184 + struct mpc52xx_gpiochip *chip = platform_get_drvdata(ofdev); 185 + 186 + of_mm_gpiochip_remove(&chip->mmchip); 187 + 188 + return 0; 187 189 } 188 190 189 191 static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = { ··· 320 314 struct mpc52xx_gpio __iomem *regs; 321 315 int ret; 322 316 323 - chip = kzalloc(sizeof(*chip), GFP_KERNEL); 317 + chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL); 324 318 if (!chip) 325 319 return -ENOMEM; 320 + 321 + platform_set_drvdata(ofdev, chip); 326 322 327 323 gc = &chip->mmchip.gc; 328 324 ··· 371 363 return 0; 372 364 } 373 365 374 - 375 366 /* Make sure we get initialised before anyone else tries to use us */ 376 367 subsys_initcall(mpc52xx_gpio_init); 377 368 378 - /* No exit call at the moment as we cannot unregister of gpio chips */ 369 + static void __exit mpc52xx_gpio_exit(void) 370 + { 371 + platform_driver_unregister(&mpc52xx_wkup_gpiochip_driver); 372 + 373 + platform_driver_unregister(&mpc52xx_simple_gpiochip_driver); 374 + } 375 + module_exit(mpc52xx_gpio_exit); 379 376 380 377 MODULE_DESCRIPTION("Freescale MPC52xx gpio driver"); 381 378 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");