Merge https://gitlab.denx.de/u-boot/custodians/u-boot-mpc85xx
[platform/kernel/u-boot.git] / scripts / checkpatch.pl
index 2654f9e..edba365 100755 (executable)
@@ -2255,6 +2255,24 @@ sub u_boot_line {
                WARN("LIVETREE",
                     "Use the livetree API (dev_read_...)\n" . $herecurr);
        }
+
+       # add tests for new commands
+       if ($line =~ /^\+.*do_($Ident)\(struct cmd_tbl.*/) {
+               WARN("CMD_TEST",
+                    "Possible new command - make sure you add a test\n" . $herecurr);
+       }
+
+       # use if instead of #if
+       if ($line =~ /^\+#if.*CONFIG.*/) {
+               WARN("PREFER_IF",
+                    "Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible\n" . $herecurr);
+       }
+
+       # use defconfig to manage CONFIG_CMD options
+       if ($line =~ /\+\s*#\s*(define|undef)\s+(CONFIG_CMD\w*)\b/) {
+               ERROR("DEFINE_CONFIG_CMD",
+                     "All commands are managed by Kconfig\n" . $herecurr);
+       }
 }
 
 sub process {