From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

The driver remove function is not the right place to cleanup resources
allocated in the driver module init.The cleanup is moved from remove
method to module exit as appropriate.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
        v2:Addressed Dan Carpenters review comment on unregistering the
driver based on dgap_numboards in the module exit routine.Registration
of the PCI driver is not dependent on this and hence unregister also
shouldn't depend on this varaible.
---
 drivers/staging/dgap/dgap.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 26b0446..d3eda62 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -7007,21 +7007,6 @@ static void dgap_cleanup_board(struct board_t *brd)
 static void dgap_remove_one(struct pci_dev *dev)
 {
        unsigned int i;
-       ulong lock_flags;
-       struct pci_driver *drv = to_pci_driver(dev->dev.driver);
-
-       spin_lock_irqsave(&dgap_poll_lock, lock_flags);
-       dgap_poll_stop = 1;
-       spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
-
-       /* Turn off poller right away. */
-       del_timer_sync(&dgap_poll_timer);
-
-       dgap_remove_driver_sysfiles(drv);
-
-       device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
-       class_destroy(dgap_class);
-       unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
 
        for (i = 0; i < dgap_numboards; ++i) {
                dgap_remove_ports_sysfiles(dgap_board[i]);
@@ -7159,8 +7144,9 @@ err_stop:
  */
 static void dgap_cleanup_module(void)
 {
-       if (dgap_numboards)
-               pci_unregister_driver(&dgap_driver);
+       dgap_remove_driver_sysfiles(&dgap_driver);
+       pci_unregister_driver(&dgap_driver);
+       dgap_stop();
 }
 
 module_init(dgap_init_module);
-- 
1.9.1
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to