Message ID | 20190813121733.52480-7-maennich@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,01/10] module: support reading multiple values per modinfo tag | expand |
On Tue, Aug 13, 2019 at 01:17:03PM +0100, Matthias Maennich wrote: > 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 > DEFAULT_SYMBOL_NAMESPACE. > > 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: > > ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON I thought we were trying to get away from cflags :( > > 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 > used: > #undef DEFAULT_SYMBOL_NAMESPACE > #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON > > 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. Ok, good, hopefully the cflags stuff will not be the default for people. thanks, greg k-h
On Tue, Aug 13, 2019 at 01:17:03PM +0100, Matthias Maennich wrote: > 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 > DEFAULT_SYMBOL_NAMESPACE. > > 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: > > ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON > > 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 > used: > #undef DEFAULT_SYMBOL_NAMESPACE > #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON > > 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. > > Suggested-by: Arnd Bergmann <arnd@arndb.de> > Reviewed-by: Martijn Coenen <maco@android.com> > Signed-off-by: Matthias Maennich <maennich@google.com> > --- > 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 { > #define __EXPORT_SYMBOL ___EXPORT_SYMBOL > #endif > > +#ifdef DEFAULT_SYMBOL_NAMESPACE > +#undef __EXPORT_SYMBOL > +#define __EXPORT_SYMBOL(sym, sec) \ > + __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) > +#endif > + > #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") > -- > 2.23.0.rc1.153.gdeed80330f-goog > Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 { #define __EXPORT_SYMBOL ___EXPORT_SYMBOL #endif +#ifdef DEFAULT_SYMBOL_NAMESPACE +#undef __EXPORT_SYMBOL +#define __EXPORT_SYMBOL(sym, sec) \ + __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) +#endif + #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")