diff options
Diffstat (limited to 'drivers/char/pc8736x_gpio.c')
-rw-r--r-- | drivers/char/pc8736x_gpio.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 5b09efcf60a6..bfc45e0cc602 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c | |||
@@ -3,18 +3,18 @@ | |||
3 | National Semiconductor PC8736x GPIO driver. Allows a user space | 3 | National Semiconductor PC8736x GPIO driver. Allows a user space |
4 | process to play with the GPIO pins. | 4 | process to play with the GPIO pins. |
5 | 5 | ||
6 | Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com> | 6 | Copyright (c) 2005,2006 Jim Cromie <jim.cromie@gmail.com> |
7 | 7 | ||
8 | adapted from linux/drivers/char/scx200_gpio.c | 8 | adapted from linux/drivers/char/scx200_gpio.c |
9 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>, | 9 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>, |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/config.h> | ||
13 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
15 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/cdev.h> | ||
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/ioport.h> | 19 | #include <linux/ioport.h> |
20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
@@ -255,6 +255,8 @@ static void __init pc8736x_init_shadow(void) | |||
255 | 255 | ||
256 | } | 256 | } |
257 | 257 | ||
258 | static struct cdev pc8736x_gpio_cdev; | ||
259 | |||
258 | static int __init pc8736x_gpio_init(void) | 260 | static int __init pc8736x_gpio_init(void) |
259 | { | 261 | { |
260 | int rc = 0; | 262 | int rc = 0; |
@@ -308,7 +310,7 @@ static int __init pc8736x_gpio_init(void) | |||
308 | rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); | 310 | rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); |
309 | if (rc < 0) { | 311 | if (rc < 0) { |
310 | dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); | 312 | dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); |
311 | goto undo_platform_dev_add; | 313 | goto undo_request_region; |
312 | } | 314 | } |
313 | if (!major) { | 315 | if (!major) { |
314 | major = rc; | 316 | major = rc; |
@@ -318,6 +320,8 @@ static int __init pc8736x_gpio_init(void) | |||
318 | pc8736x_init_shadow(); | 320 | pc8736x_init_shadow(); |
319 | return 0; | 321 | return 0; |
320 | 322 | ||
323 | undo_request_region: | ||
324 | release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE); | ||
321 | undo_platform_dev_add: | 325 | undo_platform_dev_add: |
322 | platform_device_del(pdev); | 326 | platform_device_del(pdev); |
323 | undo_platform_dev_alloc: | 327 | undo_platform_dev_alloc: |
@@ -328,11 +332,14 @@ undo_platform_dev_alloc: | |||
328 | 332 | ||
329 | static void __exit pc8736x_gpio_cleanup(void) | 333 | static void __exit pc8736x_gpio_cleanup(void) |
330 | { | 334 | { |
331 | dev_dbg(&pdev->dev, " cleanup\n"); | 335 | dev_dbg(&pdev->dev, "cleanup\n"); |
332 | 336 | ||
333 | release_region(pc8736x_gpio_base, 16); | 337 | cdev_del(&pc8736x_gpio_cdev); |
338 | unregister_chrdev_region(MKDEV(major,0), PC8736X_GPIO_CT); | ||
339 | release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE); | ||
334 | 340 | ||
335 | unregister_chrdev(major, DEVNAME); | 341 | platform_device_del(pdev); |
342 | platform_device_put(pdev); | ||
336 | } | 343 | } |
337 | 344 | ||
338 | EXPORT_SYMBOL(pc8736x_access); | 345 | EXPORT_SYMBOL(pc8736x_access); |