
< static int gpio_chrdev_release(struct inode *inode, struct file *file)
< {
<     struct gpio_chardev_data *cdev = file->private_data;
<     struct gpio_device *gdev = cdev->gdev;
< 
<     bitmap_free(cdev->watched_lines);
<     blocking_notifier_chain_unregister(&gdev->device_notifier,
<                                        &cdev->device_unregistered_nb);
<     blocking_notifier_chain_unregister(&gdev->line_state_notifier,
<                                        &cdev->lineinfo_changed_nb);
<     gpio_device_put(gdev);
<     kfree(cdev);
< 
<     return 0;
< }
---
> static void gpio_chardev_cleanup(struct gpio_chardev_data *cdev)
> {
>     if (cdev) {
>         struct gpio_device *gdev = cdev->gdev;
>         if (gdev) {
>             blocking_notifier_chain_unregister(&gdev->device_notifier,
>                                                &cdev->device_unregistered_nb);
>             blocking_notifier_chain_unregister(&gdev->line_state_notifier,
>                                                &cdev->lineinfo_changed_nb);
>             gpio_device_put(gdev);
>         }
>         bitmap_free(cdev->watched_lines);
>         kfree(cdev);
>     }
> }
> 
> static int gpio_chrdev_release(struct inode *inode, struct file *file)
> {
>     struct gpio_chardev_data *cdev = file->private_data;
>     gpio_chardev_cleanup(cdev);
>     file->private_data = NULL;
>     return 0;
> }
