xref: /linux/scripts/coccinelle/misc/add_namespace.cocci (revision 56fb34d86e875dbb0d3e6a81c5d3d035db373031)
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
9@has_ns_import@
10declarer name MODULE_IMPORT_NS;
11identifier virtual.ns;
12@@
13MODULE_IMPORT_NS(ns);
14
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@
18declarer name MODULE_LICENSE;
19expression license;
20identifier virtual.ns;
21@@
22MODULE_LICENSE(license);
23+ MODULE_IMPORT_NS(ns);
24