Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp778147ybl; Wed, 21 Aug 2019 05:31:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzanWyOiQBl2s4EKmqOoYi5eHWWZV+L6qb+GhlHkDdxc0GvelYtVFGZvJG6u7x7Ggi0mt/o X-Received: by 2002:a62:db86:: with SMTP id f128mr34697517pfg.159.1566390686534; Wed, 21 Aug 2019 05:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566390686; cv=none; d=google.com; s=arc-20160816; b=Q+pRqmpweE/T934oHm86U39mUmx3DuPksSaUaQe2iiQxr7DHfuBAXBiqLpe129s+tA W+vIQFf/JrDmlZ430kQGX+HVJickjpKeg77yNbgeeS5jbpyV/YC8qack8SN9IOXu8+qw NwsF/FRuVMmFnMKVi6w8FTfIbl0ZH0vusnz/VFtnRklu4lb0/3GcqShn9WhcMh9HxNBr meVBVCyw9RqdZnThhv8YrBESjvUQBL3HDI4u06k/BuNsWlrNC89LMq9ECL+JAbwyLnt7 PJZg1dZch2MgUfFdVfCyuJksELG9YieIIw64Gq0pUpXVz58gxJERKeG3gbSWJntM1bhl HEKg== 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=rT0KSU6kg1U7KAakAlt0j+Yalj1dCKE373XdhjaHS/Y=; b=xZQ2aDbbw689/hKWmCrKpqyvkWRKJRXeABupO2ubmr2mRrDtSeOxVSzbFGS8w0SceG b0JJHx5k88Nm0Y7WRNrglrrn7uKpg6gFZu3hDx7TslCyqYQWK7fGfA8MKSEUBXScrVQN scLvhNp0d7Lt0gDrasQHhD96ppxkRiFU0hhyWKqWxx4RiD7G/t6wnu9DA+K1/u6d69NV nGdz4BFD852zyVatKRzB9L4YQTP5VHB7CJwohLGC8aF1cYIeQ+nuS99VYJys9iNza44G gWjQRs6HNfXOxQG/AeZaqehJX+dExqyJYObUBaNw0NdVB8k8nkcBVOlUMqiLR/iBnaVX /g9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sL78SFBJ; 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 d7si2153712pjx.68.2019.08.21.05.31.07; Wed, 21 Aug 2019 05:31:26 -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=sL78SFBJ; 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 S1727949AbfHULyd (ORCPT + 99 others); Wed, 21 Aug 2019 07:54:33 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:43200 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727953AbfHULyc (ORCPT ); Wed, 21 Aug 2019 07:54:32 -0400 Received: by mail-vk1-f202.google.com with SMTP id s17so807891vkm.10 for ; Wed, 21 Aug 2019 04:54:31 -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=rT0KSU6kg1U7KAakAlt0j+Yalj1dCKE373XdhjaHS/Y=; b=sL78SFBJ7FLQgHM0KvFFBQfHGyZBRIG9AKMMPahPrreho6GZ7q/hi1HXcChLC7EStO Ojrr18OFXwtTmjjJGN2mirgUwSuhnghkVNaYnBO9OFrTnLuS2GdPAaYBmv4cqljzY8Jl EbcPdMJPRYjW4xTocUDZ0DUWLHN7qa3uA82NvUxR8jbI+KfBdv4C/qi0yrz6m1JKUJV3 APKYs3B0H/xC+dXi9Or4SKjhuHehlV48wcTBTXAIe4N3IU/1KA+PGO9xSwfC//sr9iTR 13qg8sPQBD24vebJsBEVWuh2b3IIdnKFAhy7luPXgP+dREwvWqQStxe9jGj+9mGONgEh OHkg== 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=rT0KSU6kg1U7KAakAlt0j+Yalj1dCKE373XdhjaHS/Y=; b=qjxaN5j/WWD/fdfvSdqRMKoYRFrHrtEBgW1MUdx0u2jxRNzOqV7HTjpjeoOHETJWz/ JDKnK974xzfxSA96A6Mz9QKBPgg07Fb7x2fQKBikAdU320GqxhW9DP0Mt21wumgA5OL/ SpgRFPV0y1jcce03qHiliBwXpW5QaDREVfP4IPwghfkoFUTPBwgFoVxHY3KCgRY9olqa vat1EGcentr1Dr6h3OgE65IZrsF6Gal8FYZXr7syDl4xU/olBUHunIOifKDJuq2IdYP8 9krIAaY8Iqt422hq33d+qH9VRnladdNjMo+QINtpx4ZQDB1sNq9I6WYmxmd7eaF0PEDr t+kQ== X-Gm-Message-State: APjAAAVtg9RUPwExYxbPEIYZXUe3XcwCizuv3LQYJOMgyHlaJl39PPvS XpDGL6iRYPnci+kjxxzqEAx2jf80yXBRSRIqvG3ZVFKUelSUqD3iLh+mSNYjWx7x98f+8/pxmN4 9lt2HSsdFJ1NbfA+ioFVnfYedPWUWZht404v46MNuZC9+J+jF/vjMJhztiXDlkZ+qYgamBkkY5i A= X-Received: by 2002:ab0:5fd4:: with SMTP id g20mr2062332uaj.111.1566388470706; Wed, 21 Aug 2019 04:54:30 -0700 (PDT) Date: Wed, 21 Aug 2019 12:49:21 +0100 In-Reply-To: <20190821114955.12788-1-maennich@google.com> Message-Id: <20190821114955.12788-7-maennich@google.com> Mime-Version: 1.0 References: <20190813121733.52480-1-maennich@google.com> <20190821114955.12788-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v3 06/11] 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, geert@linux-m68k.org, gregkh@linuxfoundation.org, hpa@zytor.com, jeyu@kernel.org, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@android.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com, Michael Ellerman , Ingo Molnar , Ard Biesheuvel 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 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