scripts: Coccinelle script for namespace dependencies.
A script that uses the '<module>.ns_deps' files generated by modpost to automatically add the required symbol namespace dependencies to each module. Usage: 1) Move some symbols to a namespace with EXPORT_SYMBOL_NS() or define DEFAULT_SYMBOL_NAMESPACE 2) Run 'make' (or 'make modules') and get warnings about modules not importing that namespace. 3) Run 'make nsdeps' to automatically add required import statements to said modules. This makes it easer for subsystem maintainers to introduce and maintain symbol namespaces into their codebase. Co-developed-by: Martijn Coenen <maco@android.com> Signed-off-by: Martijn Coenen <maco@android.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
This commit is contained in:

committed by
Jessica Yu

parent
1d082773ff
commit
eb8305aecb
23
scripts/coccinelle/misc/add_namespace.cocci
Normal file
23
scripts/coccinelle/misc/add_namespace.cocci
Normal file
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
//
|
||||
/// Adds missing MODULE_IMPORT_NS statements to source files
|
||||
///
|
||||
/// This script is usually called from scripts/nsdeps with -D ns=<namespace> to
|
||||
/// add a missing namespace tag to a module source file.
|
||||
///
|
||||
|
||||
@has_ns_import@
|
||||
declarer name MODULE_IMPORT_NS;
|
||||
identifier virtual.ns;
|
||||
@@
|
||||
MODULE_IMPORT_NS(ns);
|
||||
|
||||
// Add missing imports, but only adjacent to a MODULE_LICENSE statement.
|
||||
// That ensures we are adding it only to the main module source file.
|
||||
@do_import depends on !has_ns_import@
|
||||
declarer name MODULE_LICENSE;
|
||||
expression license;
|
||||
identifier virtual.ns;
|
||||
@@
|
||||
MODULE_LICENSE(license);
|
||||
+ MODULE_IMPORT_NS(ns);
|
Reference in New Issue
Block a user