diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2006-07-10 07:45:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 16:24:26 -0400 |
commit | 27385085f19a9bc9b147905554e6e2509fdaceb2 (patch) | |
tree | 07a4308f9e29bfae55d6c6cc0119794f9f8fe993 /drivers/char | |
parent | 4f197842d0f3dd994882407f8760f2eda9005191 (diff) |
[PATCH] pc8736x_gpio: fix re-modprobe errors: undo region reservation
Fix module-init-func by repairing usage of platform_device_del/put in
module-exit-func. IOW, it imitates Ingo's 'mishaps' patch, which fixed the
module-init-func's undo handling.
Also fixes lack of release_region to undo the earlier registration.
Also starts to 'use a cdev' which was originally intended (its present in
scx200_gpio). Code compiles and runs, exhibits a lesser error than
previously. (re-register-chrdev fails)
Since I had to add "include <linux/cdev.h>", I went ahead and made 2
tweaks that fell into diff-context-window:
- remove include <linux/config.h> everyone's doing it
- copyright updates - current date is 'wrong'
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-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); |