2022-06-13 09:29:07

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 7/7] brcmfmac: introduce BRCMFMAC exported symbols namespace

Instead of using EXPORT_SYMBOL() use namespace variant and only if
build vendor-specific code as separate module.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c | 1 +
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h | 6 ++++++
.../net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c | 1 +
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c | 4 ++--
.../net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c | 1 +
5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c
index 790116a735c7..d55f3271d619 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c
@@ -21,6 +21,7 @@ static void __exit brcmf_bca_exit(void)
}

MODULE_LICENSE("Dual BSD/GPL");
+MODULE_IMPORT_NS(BRCMFMAC);

module_init(brcmf_bca_init);
module_exit(brcmf_bca_exit);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index 5d627b8dbb50..8cafe59c089d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -13,6 +13,12 @@
#include <net/cfg80211.h>
#include "fweh.h"

+#if IS_ENABLED(CONFIG_BRCMFMAC_VENDOR_MODULES)
+#define BRCMF_EXPORT_SYMBOL_GPL(__sym) EXPORT_SYMBOL_NS_GPL(__sym, BRCMFMAC)
+#else
+#define BRCMF_EXPORT_SYMBOL(__sym)
+#endif
+
#define TOE_TX_CSUM_OL 0x00000001
#define TOE_RX_CSUM_OL 0x00000002

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c
index 34294724a1f8..f82fbbe3ecef 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c
@@ -21,6 +21,7 @@ static void __exit brcmf_cyw_exit(void)
}

MODULE_LICENSE("Dual BSD/GPL");
+MODULE_IMPORT_NS(BRCMFMAC);

module_init(brcmf_cyw_init);
module_exit(brcmf_cyw_exit);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c
index d0ba2aba093b..be72203f4e0b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c
@@ -112,7 +112,7 @@ int brcmf_fwvid_register_vendor(enum
brcmf_fwvendor fwvid, struct module *vmod,

return 0;
}
-EXPORT_SYMBOL(brcmf_fwvid_register_vendor);
+BRCMF_EXPORT_SYMBOL_GPL(brcmf_fwvid_register_vendor);

int brcmf_fwvid_unregister_vendor(enum brcmf_fwvendor fwvid, struct
module *mod)
{
@@ -145,7 +145,7 @@ int brcmf_fwvid_unregister_vendor(enum
brcmf_fwvendor fwvid, struct module *mod)

return 0;
}
-EXPORT_SYMBOL(brcmf_fwvid_unregister_vendor);
+BRCMF_EXPORT_SYMBOL_GPL(brcmf_fwvid_unregister_vendor);
#else
static inline int brcmf_fwvid_request_module(enum brcmf_fwvendor fwvid)
{
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c
index 23e3a4557880..02918d434556 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c
@@ -21,6 +21,7 @@ static void __exit brcmf_wcc_exit(void)
}

MODULE_LICENSE("Dual BSD/GPL");
+MODULE_IMPORT_NS(BRCMFMAC);

module_init(brcmf_wcc_init);
module_exit(brcmf_wcc_exit);
--
2.32.0


2022-07-28 09:50:38

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 7/7] brcmfmac: introduce BRCMFMAC exported symbols namespace

[email protected] writes:

> Instead of using EXPORT_SYMBOL() use namespace variant and only if
> build vendor-specific code as separate module.

The commit log should always answer to the question "why?".

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-07-29 09:39:38

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH 7/7] brcmfmac: introduce BRCMFMAC exported symbols namespace

On 7/28/2022 11:39 AM, Kalle Valo wrote:
> [email protected] writes:
>
>> Instead of using EXPORT_SYMBOL() use namespace variant and only if
>> build vendor-specific code as separate module.
>
> The commit log should always answer to the question "why?".

Let me try:

Exported symbols are usable from any kernel module. Using the namespace
variant requires the caller to explicitly import the symbols. This makes
it more clear that these are only intended to be used by brcmfmac
driver. When vendor-support is built-in there is no reason to export the
symbols at all.

If the above is acceptable I will use that when resending the patch series.

Regards,
Arend