[SCSI] qla2xxx: Add char device to increase driver use count
authorHarish Zunjarrao <harish.zunjarrao@qlogic.com>
Tue, 4 May 2010 22:01:24 +0000 (15:01 -0700)
committerJames Bottomley <James.Bottomley@suse.de>
Sun, 16 May 2010 22:21:42 +0000 (18:21 -0400)
The driver should not be unloaded if any application is using it.
To disallow driver unload, driver use count must be incremented.
Application uses this char device as handle and increases driver
use count to avoid possible driver unload.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_os.c

index edb7a704ed775ef26d66a4ebc435e72ad95e7e2e..d4a53e5549b9c44bd6b64dc89fff1c463b9e4968 100644 (file)
@@ -35,7 +35,8 @@
 
 #include "qla_bsg.h"
 #include "qla_nx.h"
-#define QLA2XXX_DRIVER_NAME  "qla2xxx"
+#define QLA2XXX_DRIVER_NAME    "qla2xxx"
+#define QLA2XXX_APIDEV         "ql2xapidev"
 
 /*
  * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
index f2102db0316060aa64aeebf7e466f4cf475d527e..10c14af2235b34d0e48ca6e9302aa6d869801b80 100644 (file)
@@ -24,6 +24,8 @@
  */
 char qla2x00_version_str[40];
 
+static int apidev_major;
+
 /*
  * SRB allocation cache
  */
@@ -3763,6 +3765,10 @@ static struct pci_driver qla2xxx_pci_driver = {
        .err_handler    = &qla2xxx_err_handler,
 };
 
+static struct file_operations apidev_fops = {
+       .owner = THIS_MODULE,
+};
+
 /**
  * qla2x00_module_init - Module initialization.
  **/
@@ -3791,6 +3797,13 @@ qla2x00_module_init(void)
                kmem_cache_destroy(srb_cachep);
                return -ENODEV;
        }
+
+       apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops);
+       if (apidev_major < 0) {
+               printk(KERN_WARNING "qla2xxx: Unable to register char device "
+                   "%s\n", QLA2XXX_APIDEV);
+       }
+
        qla2xxx_transport_vport_template =
            fc_attach_transport(&qla2xxx_transport_vport_functions);
        if (!qla2xxx_transport_vport_template) {
@@ -3816,6 +3829,7 @@ qla2x00_module_init(void)
 static void __exit
 qla2x00_module_exit(void)
 {
+       unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
        pci_unregister_driver(&qla2xxx_pci_driver);
        qla2x00_release_firmware();
        kmem_cache_destroy(srb_cachep);
This page took 0.030996 seconds and 5 git commands to generate.