[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH v3 06/11] export: allow definition default namespaces in Makefiles or sources
+++ Matthias Maennich [21/08/19 12:49 +0100]:
>To avoid excessive usage of EXPORT_SYMBOL_NS(sym, MY_NAMESPACE), where
>MY_NAMESPACE will always be the namespace we are exporting to, allow
>exporting all definitions of EXPORT_SYMBOL() and friends by defining
>For example, to export all symbols defined in usb-common into the
>namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile:
>That is equivalent to changing all EXPORT_SYMBOL(sym) definitions to
>EXPORT_SYMBOL_NS(sym, USB_COMMON). Subsequently all symbol namespaces
>functionality will apply.
>Another way of making use of this feature is to define the namespace
>within source or header files similar to how TRACE_SYSTEM defines are
>Please note that, as opposed to TRACE_SYSTEM, DEFAULT_SYMBOL_NAMESPACE
>has to be defined before including include/linux/export.h.
>If DEFAULT_SYMBOL_NAMESPACE is defined, a symbol can still be exported
>to another namespace by using EXPORT_SYMBOL_NS() and friends with
>explicitly specifying the namespace.

This changelog provides a good summary of how to use
DEFAULT_SYMBOL_NAMESPACE, I wonder if we should explicitly document
its proper usage somewhere? (along with EXPORT_SYMBOL_NS*)
The EXPORT_SYMBOL API is briefly documented in
Documentation/kernel-hacking/hacking.rst - it might be slightly dated,
but perhaps it'd fit there best?

>Suggested-by: Arnd Bergmann <>
>Reviewed-by: Martijn Coenen <>
>Reviewed-by: Greg Kroah-Hartman <>
>Signed-off-by: Matthias Maennich <>
> include/linux/export.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>diff --git a/include/linux/export.h b/include/linux/export.h
>index 8e12e05444d1..1fb243abdbc4 100644
>--- a/include/linux/export.h
>+++ b/include/linux/export.h
>@@ -166,6 +166,12 @@ struct kernel_symbol {
> #endif
>+#undef __EXPORT_SYMBOL
>+#define __EXPORT_SYMBOL(sym, sec) \
> #define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "")
> #define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl")
> #define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future")

 \ /
  Last update: 2019-08-28 12:50    [W:0.317 / U:41.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site