diff options
author | Harish Zunjarrao <harish.zunjarrao@qlogic.com> | 2010-05-04 18:01:24 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-16 18:21:42 -0400 |
commit | 6a03b4cd78f3f2695a2d0e6343d555b3de0e67c1 (patch) | |
tree | c86750452978aaadca184bbe39d1c969a3b776ab | |
parent | 3e46f031322bdd8d1f11e17fb7cf00c38b08dd55 (diff) |
[SCSI] qla2xxx: Add char device to increase driver use count
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>
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 3 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index edb7a704ed77..d4a53e5549b9 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h | |||
@@ -35,7 +35,8 @@ | |||
35 | 35 | ||
36 | #include "qla_bsg.h" | 36 | #include "qla_bsg.h" |
37 | #include "qla_nx.h" | 37 | #include "qla_nx.h" |
38 | #define QLA2XXX_DRIVER_NAME "qla2xxx" | 38 | #define QLA2XXX_DRIVER_NAME "qla2xxx" |
39 | #define QLA2XXX_APIDEV "ql2xapidev" | ||
39 | 40 | ||
40 | /* | 41 | /* |
41 | * We have MAILBOX_REGISTER_COUNT sized arrays in a few places, | 42 | * We have MAILBOX_REGISTER_COUNT sized arrays in a few places, |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index f2102db03160..10c14af2235b 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -24,6 +24,8 @@ | |||
24 | */ | 24 | */ |
25 | char qla2x00_version_str[40]; | 25 | char qla2x00_version_str[40]; |
26 | 26 | ||
27 | static int apidev_major; | ||
28 | |||
27 | /* | 29 | /* |
28 | * SRB allocation cache | 30 | * SRB allocation cache |
29 | */ | 31 | */ |
@@ -3763,6 +3765,10 @@ static struct pci_driver qla2xxx_pci_driver = { | |||
3763 | .err_handler = &qla2xxx_err_handler, | 3765 | .err_handler = &qla2xxx_err_handler, |
3764 | }; | 3766 | }; |
3765 | 3767 | ||
3768 | static struct file_operations apidev_fops = { | ||
3769 | .owner = THIS_MODULE, | ||
3770 | }; | ||
3771 | |||
3766 | /** | 3772 | /** |
3767 | * qla2x00_module_init - Module initialization. | 3773 | * qla2x00_module_init - Module initialization. |
3768 | **/ | 3774 | **/ |
@@ -3791,6 +3797,13 @@ qla2x00_module_init(void) | |||
3791 | kmem_cache_destroy(srb_cachep); | 3797 | kmem_cache_destroy(srb_cachep); |
3792 | return -ENODEV; | 3798 | return -ENODEV; |
3793 | } | 3799 | } |
3800 | |||
3801 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); | ||
3802 | if (apidev_major < 0) { | ||
3803 | printk(KERN_WARNING "qla2xxx: Unable to register char device " | ||
3804 | "%s\n", QLA2XXX_APIDEV); | ||
3805 | } | ||
3806 | |||
3794 | qla2xxx_transport_vport_template = | 3807 | qla2xxx_transport_vport_template = |
3795 | fc_attach_transport(&qla2xxx_transport_vport_functions); | 3808 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
3796 | if (!qla2xxx_transport_vport_template) { | 3809 | if (!qla2xxx_transport_vport_template) { |
@@ -3816,6 +3829,7 @@ qla2x00_module_init(void) | |||
3816 | static void __exit | 3829 | static void __exit |
3817 | qla2x00_module_exit(void) | 3830 | qla2x00_module_exit(void) |
3818 | { | 3831 | { |
3832 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); | ||
3819 | pci_unregister_driver(&qla2xxx_pci_driver); | 3833 | pci_unregister_driver(&qla2xxx_pci_driver); |
3820 | qla2x00_release_firmware(); | 3834 | qla2x00_release_firmware(); |
3821 | kmem_cache_destroy(srb_cachep); | 3835 | kmem_cache_destroy(srb_cachep); |