Commit ced38c8c00962c9b6c1fcd330572406162d150b9
Committed by
Nicholas Bellinger
1 parent
77271de645
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 10 additions and 12 deletions Side-by-side Diff
Documentation/target/tcm_mod_builder.py
... | ... | @@ -255,7 +255,7 @@ |
255 | 255 | buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" |
256 | 256 | buf += " return ERR_PTR(-EINVAL); */\n" |
257 | 257 | buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" |
258 | - buf += " if (!(se_nacl_new))\n" | |
258 | + buf += " if (!se_nacl_new)\n" | |
259 | 259 | buf += " return ERR_PTR(-ENOMEM);\n" |
260 | 260 | buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" |
261 | 261 | buf += " nexus_depth = 1;\n" |
... | ... | @@ -303,7 +303,7 @@ |
303 | 303 | buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" |
304 | 304 | buf += " return ERR_PTR(-EINVAL);\n\n" |
305 | 305 | buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" |
306 | - buf += " if (!(tpg)) {\n" | |
306 | + buf += " if (!tpg) {\n" | |
307 | 307 | buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" |
308 | 308 | buf += " return ERR_PTR(-ENOMEM);\n" |
309 | 309 | buf += " }\n" |
... | ... | @@ -339,7 +339,7 @@ |
339 | 339 | buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" |
340 | 340 | buf += " return ERR_PTR(-EINVAL); */\n\n" |
341 | 341 | buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" |
342 | - buf += " if (!(" + fabric_mod_port + ")) {\n" | |
342 | + buf += " if (!" + fabric_mod_port + ") {\n" | |
343 | 343 | buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" |
344 | 344 | buf += " return ERR_PTR(-ENOMEM);\n" |
345 | 345 | buf += " }\n" |
... | ... | @@ -347,7 +347,7 @@ |
347 | 347 | if proto_ident == "FC" or proto_ident == "SAS": |
348 | 348 | buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" |
349 | 349 | |
350 | - buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n" | |
350 | + buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" | |
351 | 351 | buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" |
352 | 352 | buf += "}\n\n" |
353 | 353 | buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" |
354 | 354 | |
... | ... | @@ -431,9 +431,9 @@ |
431 | 431 | buf += " * Register the top level struct config_item_type with TCM core\n" |
432 | 432 | buf += " */\n" |
433 | 433 | buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" |
434 | - buf += " if (!(fabric)) {\n" | |
434 | + buf += " if (IS_ERR(fabric)) {\n" | |
435 | 435 | buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" |
436 | - buf += " return -ENOMEM;\n" | |
436 | + buf += " return PTR_ERR(fabric);\n" | |
437 | 437 | buf += " }\n" |
438 | 438 | buf += " /*\n" |
439 | 439 | buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" |
440 | 440 | |
... | ... | @@ -467,9 +467,9 @@ |
467 | 467 | buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" |
468 | 468 | buf += " return 0;\n" |
469 | 469 | buf += "};\n\n" |
470 | - buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n" | |
470 | + buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n" | |
471 | 471 | buf += "{\n" |
472 | - buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n" | |
472 | + buf += " if (!" + fabric_mod_name + "_fabric_configfs)\n" | |
473 | 473 | buf += " return;\n\n" |
474 | 474 | buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" |
475 | 475 | buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" |
476 | 476 | |
477 | 477 | |
... | ... | @@ -484,17 +484,15 @@ |
484 | 484 | buf += " return ret;\n\n" |
485 | 485 | buf += " return 0;\n" |
486 | 486 | buf += "};\n\n" |
487 | - buf += "static void " + fabric_mod_name + "_exit(void)\n" | |
487 | + buf += "static void __exit " + fabric_mod_name + "_exit(void)\n" | |
488 | 488 | buf += "{\n" |
489 | 489 | buf += " " + fabric_mod_name + "_deregister_configfs();\n" |
490 | 490 | buf += "};\n\n" |
491 | 491 | |
492 | - buf += "#ifdef MODULE\n" | |
493 | 492 | buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" |
494 | 493 | buf += "MODULE_LICENSE(\"GPL\");\n" |
495 | 494 | buf += "module_init(" + fabric_mod_name + "_init);\n" |
496 | 495 | buf += "module_exit(" + fabric_mod_name + "_exit);\n" |
497 | - buf += "#endif\n" | |
498 | 496 | |
499 | 497 | ret = p.write(buf) |
500 | 498 | if ret: |
... | ... | @@ -776,7 +774,7 @@ |
776 | 774 | buf += "{\n" |
777 | 775 | buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" |
778 | 776 | buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" |
779 | - buf += " if (!(nacl)) {\n" | |
777 | + buf += " if (!nacl) {\n" | |
780 | 778 | buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n" |
781 | 779 | buf += " return NULL;\n" |
782 | 780 | buf += " }\n\n" |