Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2111723ybe; Tue, 3 Sep 2019 08:09:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZJAGPdG19TSGJJY5dfpVQBKJXbZGroDNYTH5U/k0DQKqSfjw5CsE98KwbiQXwWT1FR3kX X-Received: by 2002:a17:902:3003:: with SMTP id u3mr35125785plb.161.1567523369868; Tue, 03 Sep 2019 08:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567523369; cv=none; d=google.com; s=arc-20160816; b=TPzvNsyD7tKVKWrcrIjHiAnmhp6UrIy1uh+X7zmT/2D1AnTuc8LfglecQero0R+EK8 xdzt9aIkP8TZ5/QVaDxkS4CW4/UvmfQZLMsf4/q1aWrR/kfTsR7gBM3g80Mrlkjc+qXw b1gFuWvlb4H3qYIZwA+nypxOQGDQBzgWzJ/dHI9aY8deSDgdoPxW0NOslx2cSL0ZAsFL M4umb6bngKa7Zlu1iMpCQGPTPwVRgJeZ0RO2yYfsa1e7zCT9L9GrWvUEJrNiw5Hia2lI oRAXOs+tQa+lUthKbiSWTUwypC7qxOtrSAgyBsSIRXqO4bkGaZ8ytr/FLymWfPOCvd4C QlIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=QzLwUka7MndmPbLBfBjtnVUWcO8y+yUapUjSVd2AkdE=; b=AgdlTOxtqgFyAk0JUqvAWikhec/TKrrKkomrkoW5Sssav17o5mgHJKqId5smM70qvS N5P9nCHkRC8MIDLarHt7yTw8y/Mm/YfAl8yuk5r4ON4gGanNiZbHjOZfvmna4WfoT2Z8 FmkLVLP4ReVfdo/lxh1Lib30jXOTvH0d0ThrU7Ptv2M1bMnhKhd4lADA9Xmv0bgAgj9I 0OF5XZOzRLnAsBnIxAb77ZqDN3CXSWjhB3lRN4Bp1gxdwrvz5UICg4jSjXwUmJnt8/JU d+Kl4xof8A3CFcPp5Cp0p1PtuHZ55P/7K1qqw+VB9HamwMDbFEVUxjVu10e+j2+kq96H rGXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PB5Ah+kY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s20si14715088pgi.499.2019.09.03.08.09.13; Tue, 03 Sep 2019 08:09:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PB5Ah+kY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729864AbfICPHn (ORCPT + 99 others); Tue, 3 Sep 2019 11:07:43 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:48780 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729854AbfICPHm (ORCPT ); Tue, 3 Sep 2019 11:07:42 -0400 Received: by mail-yw1-f74.google.com with SMTP id l16so10006249ywb.15 for ; Tue, 03 Sep 2019 08:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QzLwUka7MndmPbLBfBjtnVUWcO8y+yUapUjSVd2AkdE=; b=PB5Ah+kYC1m4B/Vqzh02d5Dma2M2yVL7Bdqf/cgU5C5/QHZXWWxWusz5yxJTxv/UaW cPQ+if9lMxNZfGZL8S6lAAv/KZXOdRW/TgOTyyk2SxYWVb84rGwfPhHTdzrwyml3fyYR zMB9ShCEW07O4VXQZsewgm0bwovFzEdsUHPpP51HT13xk3Eva1qhEajcX6jZ8XP0Sq9l WK3aEEJXUIn/x+ktaxUYG8u++q7nTs10fbIeFJFJgHQ61R003giZa7EC3s1heJ+v3BkU DhFAq5i9QktVcROUV7GZTvihIhoDpLPBW6QkwLuwo8b24v/88OsKzS4oZLrp9/OjXMdl ZYLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QzLwUka7MndmPbLBfBjtnVUWcO8y+yUapUjSVd2AkdE=; b=fsNK9iqnXdcZTlL/+DzVZaI6GtKaP8hytMeFinW+VitTg4iRKS+4ER7Zsc/ldd6B+7 Rsl7tRYhELvgjh7KYe35+TKn3e7z1B/cTLF/JGZhJPXWgIb4go5oksEUGCMVvz8xo9Oy cpzOC83ZnglGSnZI3rVflvJBO1m+pHMaZnxw9z/I3oB4LkitIvNx9DO8KHBPZI2alhQI jz0z/8/Fh6GMmON9smAz+PVvH2ttVzQo7QY0FlWtGH1IcSMb9JOrZRzIo3whGVvjscxE i130ll412lqd9qdjpT9KTqvBOQPPKycWydfMULbY9XjfHmyA3mYbs8xZ3FAwtJM5FvM+ SXgw== X-Gm-Message-State: APjAAAVxcWgkNb7UkrokhqlSy5piCygD6Rh4X8FTcHE8H1MafPalHexi RPq6EnQZQsCGCrTMqPm9yX2avFj1zaT2Oiy33uNPfcIcJHncGgxrM6Ve+9OW08TYSKXwi0Ox3H7 fBWMTYwhAcGcSKo6+WHlN/ZMX2VTD4OdRqLmxmt4q1W5UwGLrXPSjI8ofhFuVf97FtqVeDzg5jV I= X-Received: by 2002:a81:9ac2:: with SMTP id r185mr25908588ywg.210.1567523261200; Tue, 03 Sep 2019 08:07:41 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:32 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-7-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 06/12] export: allow definition default namespaces in Makefiles or sources From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 d59461e71478..2c5468d8ea9a 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.187.g17f5b7556c-goog