target: tcm_mod_builder: small fixups
This includes: - remove on _ in "__NAMELEN" in $fabric _make_tport - target_fabric_configfs_init() returns an error pointer and not NULL anymore. Consider that. - replace (!(var_name)) with (!var_name). The extra () are not required - remove #ifdef MODULE. If the code is builtin it needs an init function or the code is useless - put exit/clean functions into __exit Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
77271de645
commit
ced38c8c00
1 changed files with 10 additions and 12 deletions
|
@ -255,7 +255,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
|
||||
buf += " return ERR_PTR(-EINVAL); */\n"
|
||||
buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n"
|
||||
buf += " if (!(se_nacl_new))\n"
|
||||
buf += " if (!se_nacl_new)\n"
|
||||
buf += " return ERR_PTR(-ENOMEM);\n"
|
||||
buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n"
|
||||
buf += " nexus_depth = 1;\n"
|
||||
|
@ -303,7 +303,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n"
|
||||
buf += " return ERR_PTR(-EINVAL);\n\n"
|
||||
buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n"
|
||||
buf += " if (!(tpg)) {\n"
|
||||
buf += " if (!tpg) {\n"
|
||||
buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n"
|
||||
buf += " return ERR_PTR(-ENOMEM);\n"
|
||||
buf += " }\n"
|
||||
|
@ -339,7 +339,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
|
||||
buf += " return ERR_PTR(-EINVAL); */\n\n"
|
||||
buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n"
|
||||
buf += " if (!(" + fabric_mod_port + ")) {\n"
|
||||
buf += " if (!" + fabric_mod_port + ") {\n"
|
||||
buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n"
|
||||
buf += " return ERR_PTR(-ENOMEM);\n"
|
||||
buf += " }\n"
|
||||
|
@ -347,7 +347,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
if proto_ident == "FC" or proto_ident == "SAS":
|
||||
buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n"
|
||||
|
||||
buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n"
|
||||
buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
|
||||
buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n"
|
||||
buf += "}\n\n"
|
||||
buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n"
|
||||
|
@ -431,9 +431,9 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " * Register the top level struct config_item_type with TCM core\n"
|
||||
buf += " */\n"
|
||||
buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n"
|
||||
buf += " if (!(fabric)) {\n"
|
||||
buf += " if (IS_ERR(fabric)) {\n"
|
||||
buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n"
|
||||
buf += " return -ENOMEM;\n"
|
||||
buf += " return PTR_ERR(fabric);\n"
|
||||
buf += " }\n"
|
||||
buf += " /*\n"
|
||||
buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n"
|
||||
|
@ -467,9 +467,9 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n"
|
||||
buf += " return 0;\n"
|
||||
buf += "};\n\n"
|
||||
buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n"
|
||||
buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n"
|
||||
buf += "{\n"
|
||||
buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n"
|
||||
buf += " if (!" + fabric_mod_name + "_fabric_configfs)\n"
|
||||
buf += " return;\n\n"
|
||||
buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n"
|
||||
buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n"
|
||||
|
@ -484,17 +484,15 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " return ret;\n\n"
|
||||
buf += " return 0;\n"
|
||||
buf += "};\n\n"
|
||||
buf += "static void " + fabric_mod_name + "_exit(void)\n"
|
||||
buf += "static void __exit " + fabric_mod_name + "_exit(void)\n"
|
||||
buf += "{\n"
|
||||
buf += " " + fabric_mod_name + "_deregister_configfs();\n"
|
||||
buf += "};\n\n"
|
||||
|
||||
buf += "#ifdef MODULE\n"
|
||||
buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
|
||||
buf += "MODULE_LICENSE(\"GPL\");\n"
|
||||
buf += "module_init(" + fabric_mod_name + "_init);\n"
|
||||
buf += "module_exit(" + fabric_mod_name + "_exit);\n"
|
||||
buf += "#endif\n"
|
||||
|
||||
ret = p.write(buf)
|
||||
if ret:
|
||||
|
@ -776,7 +774,7 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += "{\n"
|
||||
buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n"
|
||||
buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n"
|
||||
buf += " if (!(nacl)) {\n"
|
||||
buf += " if (!nacl) {\n"
|
||||
buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n"
|
||||
buf += " return NULL;\n"
|
||||
buf += " }\n\n"
|
||||
|
|
Loading…
Reference in a new issue