Commit 93e6d5ab authored by Robert Love's avatar Robert Love Committed by James Bottomley

[SCSI] libfc: Move libfc_init and libfc_exit to fc_libfc.c

These routines are for the libfc kernel module and should be in
the libfc .c file.

Moving the libfc __init routine into fc_libfc.c caused the creation
of the fc_setup_fcp() and fc_destroy_fcp() routines so that
scsi_pkt_cachep was not exposed outside of fc_fcp.c.
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 8866a5d9
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "fc_libfc.h" #include "fc_libfc.h"
static struct kmem_cache *scsi_pkt_cachep; struct kmem_cache *scsi_pkt_cachep;
/* SRB state definitions */ /* SRB state definitions */
#define FC_SRB_FREE 0 /* cmd is free */ #define FC_SRB_FREE 0 /* cmd is free */
...@@ -2072,6 +2072,28 @@ void fc_fcp_destroy(struct fc_lport *lp) ...@@ -2072,6 +2072,28 @@ void fc_fcp_destroy(struct fc_lport *lp)
} }
EXPORT_SYMBOL(fc_fcp_destroy); EXPORT_SYMBOL(fc_fcp_destroy);
int fc_setup_fcp()
{
int rc = 0;
scsi_pkt_cachep = kmem_cache_create("libfc_fcp_pkt",
sizeof(struct fc_fcp_pkt),
0, SLAB_HWCACHE_ALIGN, NULL);
if (!scsi_pkt_cachep) {
printk(KERN_ERR "libfc: Unable to allocate SRB cache, "
"module load failed!");
rc = -ENOMEM;
}
return rc;
}
void fc_destroy_fcp()
{
if (scsi_pkt_cachep)
kmem_cache_destroy(scsi_pkt_cachep);
}
int fc_fcp_init(struct fc_lport *lp) int fc_fcp_init(struct fc_lport *lp)
{ {
int rc; int rc;
...@@ -2104,42 +2126,3 @@ int fc_fcp_init(struct fc_lport *lp) ...@@ -2104,42 +2126,3 @@ int fc_fcp_init(struct fc_lport *lp)
return rc; return rc;
} }
EXPORT_SYMBOL(fc_fcp_init); EXPORT_SYMBOL(fc_fcp_init);
static int __init libfc_init(void)
{
int rc;
scsi_pkt_cachep = kmem_cache_create("libfc_fcp_pkt",
sizeof(struct fc_fcp_pkt),
0, SLAB_HWCACHE_ALIGN, NULL);
if (scsi_pkt_cachep == NULL) {
printk(KERN_ERR "libfc: Unable to allocate SRB cache, "
"module load failed!");
return -ENOMEM;
}
rc = fc_setup_exch_mgr();
if (rc)
goto destroy_pkt_cache;
rc = fc_setup_rport();
if (rc)
goto destroy_em;
return rc;
destroy_em:
fc_destroy_exch_mgr();
destroy_pkt_cache:
kmem_cache_destroy(scsi_pkt_cachep);
return rc;
}
static void __exit libfc_exit(void)
{
kmem_cache_destroy(scsi_pkt_cachep);
fc_destroy_exch_mgr();
fc_destroy_rport();
}
module_init(libfc_init);
module_exit(libfc_exit);
...@@ -33,3 +33,42 @@ MODULE_LICENSE("GPL v2"); ...@@ -33,3 +33,42 @@ MODULE_LICENSE("GPL v2");
unsigned int fc_debug_logging; unsigned int fc_debug_logging;
module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR); module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
/**
* libfc_init() - Initialize libfc.ko
*/
static int __init libfc_init(void)
{
int rc = 0;
rc = fc_setup_fcp();
if (rc)
return rc;
rc = fc_setup_exch_mgr();
if (rc)
goto destroy_pkt_cache;
rc = fc_setup_rport();
if (rc)
goto destroy_em;
return rc;
destroy_em:
fc_destroy_exch_mgr();
destroy_pkt_cache:
fc_destroy_fcp();
return rc;
}
module_init(libfc_init);
/**
* libfc_exit() - Tear down libfc.ko
*/
static void __exit libfc_exit(void)
{
fc_destroy_fcp();
fc_destroy_exch_mgr();
fc_destroy_rport();
}
module_exit(libfc_exit);
...@@ -93,6 +93,8 @@ int fc_setup_exch_mgr(void); ...@@ -93,6 +93,8 @@ int fc_setup_exch_mgr(void);
void fc_destroy_exch_mgr(void); void fc_destroy_exch_mgr(void);
int fc_setup_rport(void); int fc_setup_rport(void);
void fc_destroy_rport(void); void fc_destroy_rport(void);
int fc_setup_fcp(void);
void fc_destroy_fcp(void);
/* /*
* Internal libfc functions * Internal libfc functions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment