add_namespace.cocci 837 B

12345678910111213141516171819202122232425262728293031
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. //
  3. /// Adds missing MODULE_IMPORT_NS statements to source files
  4. ///
  5. /// This script is usually called from scripts/nsdeps with -D ns=<namespace> to
  6. /// add a missing namespace tag to a module source file.
  7. ///
  8. virtual nsdeps
  9. virtual report
  10. @has_ns_import@
  11. declarer name MODULE_IMPORT_NS;
  12. identifier virtual.ns;
  13. @@
  14. MODULE_IMPORT_NS(ns);
  15. // Add missing imports, but only adjacent to a MODULE_LICENSE statement.
  16. // That ensures we are adding it only to the main module source file.
  17. @do_import depends on !has_ns_import && nsdeps@
  18. declarer name MODULE_LICENSE;
  19. expression license;
  20. identifier virtual.ns;
  21. @@
  22. MODULE_LICENSE(license);
  23. + MODULE_IMPORT_NS(ns);
  24. // Dummy rule for report mode that would otherwise be empty and make spatch
  25. // fail ("No rules apply.")
  26. @script:python depends on report@
  27. @@