Skip to content

Commit

Permalink
[PATCH] cs5535_gpio.c: call cdev_del() during module_exit to unmap ko…
Browse files Browse the repository at this point in the history
…bject references and other cleanups

During module unloading, cdev_del() must be called to unmap cdev related
kobject references and other cleanups(such as inode->i_cdev being set to
NULL) which prevents the OOPS upon subsequent loading, usage and unloading
of modules(as seen in the mail thread
http://marc.theaimsgroup.com/?l=linux-kernel&m=114533640609018&w=2).

Also, remove unneeded test of gpio_base.

Signed-off-by: Thayumanavar Sachithanantham <thayumk@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Thayumanavar Sachithanantham authored and Linus Torvalds committed Apr 20, 2006
1 parent c16c556 commit 0324680
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/char/cs5535_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ static int __init cs5535_gpio_init(void)
static void __exit cs5535_gpio_cleanup(void)
{
dev_t dev_id = MKDEV(major, 0);

cdev_del(&cs5535_gpio_cdev);
unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT);
if (gpio_base != 0)
release_region(gpio_base, CS5535_GPIO_SIZE);
release_region(gpio_base, CS5535_GPIO_SIZE);
}

module_init(cs5535_gpio_init);
Expand Down

0 comments on commit 0324680

Please sign in to comment.