wok-current rev 25643

Update broadcom-wl driver for kernel 4.x
author Stanislas Leduc <shann@slitaz.org>
date Fri Jan 19 12:44:23 2024 +0000 (5 months ago)
parents 26e9e18d7c1d
children 0f3d33956b41
files broadcom-wl-pae/receipt broadcom-wl-pae/stuff/001-null-pointer-fix.patch broadcom-wl-pae/stuff/002-rdtscl.patch broadcom-wl-pae/stuff/003-linux47.patch broadcom-wl-pae/stuff/004-linux48.patch broadcom-wl-pae/stuff/005-debian-fix-kernel-warnings.patch broadcom-wl-pae/stuff/006-linux411.patch broadcom-wl-pae/stuff/007-linux412.patch broadcom-wl-pae/stuff/008-linux415.patch broadcom-wl-pae/stuff/009-fix_mac_profile_discrepancy.patch broadcom-wl-pae/stuff/014-linux414.patch broadcom-wl-pae/stuff/015-linux419.patch broadcom-wl-pae/stuff/016-linux51.patch broadcom-wl-pae/stuff/017-get-rid-of-get_fs-set_fs-calls.patch broadcom-wl/receipt broadcom-wl/stuff/001-null-pointer-fix.patch broadcom-wl/stuff/002-rdtscl.patch broadcom-wl/stuff/003-linux47.patch broadcom-wl/stuff/004-linux48.patch broadcom-wl/stuff/005-debian-fix-kernel-warnings.patch broadcom-wl/stuff/006-linux411.patch broadcom-wl/stuff/007-linux412.patch broadcom-wl/stuff/008-linux415.patch broadcom-wl/stuff/009-fix_mac_profile_discrepancy.patch broadcom-wl/stuff/014-linux414.patch broadcom-wl/stuff/015-linux419.patch broadcom-wl/stuff/016-linux51.patch broadcom-wl/stuff/017-get-rid-of-get_fs-set_fs-calls.patch broadcom-wl64/receipt broadcom-wl64/stuff/001-null-pointer-fix.patch broadcom-wl64/stuff/002-rdtscl.patch broadcom-wl64/stuff/003-linux47.patch broadcom-wl64/stuff/004-linux48.patch broadcom-wl64/stuff/005-debian-fix-kernel-warnings.patch broadcom-wl64/stuff/006-linux411.patch broadcom-wl64/stuff/007-linux412.patch broadcom-wl64/stuff/008-linux415.patch broadcom-wl64/stuff/009-fix_mac_profile_discrepancy.patch broadcom-wl64/stuff/014-linux414.patch broadcom-wl64/stuff/015-linux419.patch broadcom-wl64/stuff/016-linux51.patch broadcom-wl64/stuff/017-get-rid-of-get_fs-set_fs-calls.patch
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/broadcom-wl-pae/receipt	Fri Jan 19 12:44:23 2024 +0000
     1.3 @@ -0,0 +1,65 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="broadcom-wl-pae"
     1.7 +VERSION="6_30_223_271"
     1.8 +CATEGORY="network"
     1.9 +MAINTAINER="maintainer@slitaz.org"
    1.10 +LICENSE="other"
    1.11 +SHORT_DESC="Broadcom 802.11abg Linux STA Networking Drivers"
    1.12 +WEB_SITE="https://www.broadcom.com/support/download-search/?pf=Wireless+LAN+Infrastructure"
    1.13 +TARBALL="hybrid-v35-nodebug-pcoem-$VERSION.tar.gz"
    1.14 +WGET_URL="https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/$TARBALL"
    1.15 +TAGS="wireless wifi driver"
    1.16 +PROVIDE="broadcom-wl:linux-pae"
    1.17 +
    1.18 +DEPENDS="linux"
    1.19 +BUILD_DEPENDS="linux-pae-module-headers xz"
    1.20 +
    1.21 +# Rules to configure and make the package.
    1.22 +compile_rules()
    1.23 +{
    1.24 +    # Use wlan instead eth
    1.25 +    sed -i -e '/BRCM_WLAN_IFNAME/s/eth/wlan/' src/wl/sys/wl_linux.c
    1.26 +
    1.27 +    while read file; do                                
    1.28 +        [ -f done.$file ] && continue                       
    1.29 +        echo "Apply $file..."        
    1.30 +        patch -p1 < $stuff/$file || return 1
    1.31 +        cp $stuff/$file done.$file          
    1.32 +    done <<EOT
    1.33 +001-null-pointer-fix.patch
    1.34 +002-rdtscl.patch
    1.35 +003-linux47.patch
    1.36 +004-linux48.patch
    1.37 +005-debian-fix-kernel-warnings.patch
    1.38 +006-linux411.patch
    1.39 +007-linux412.patch
    1.40 +008-linux415.patch
    1.41 +009-fix_mac_profile_discrepancy.patch
    1.42 +014-linux414.patch
    1.43 +EOT
    1.44 +
    1.45 +    KBUILD_NOPEDANTIC=1 make -C /usr/src/linux M=`pwd`
    1.46 +    xz wl.ko
    1.47 +}
    1.48 +
    1.49 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.50 +genpkg_rules()
    1.51 +{
    1.52 +    EXTRAVERSION=_${kvers}
    1.53 +    mkdir -p $fs/lib/modules/${kvers}-slitaz-pae/kernel/drivers/net/wireless
    1.54 +    # Compress and install module
    1.55 +    install -o root -m 0644 $src/wl.ko.xz \
    1.56 +        $fs/lib/modules/${kvers}-slitaz-pae/kernel/drivers/net/wireless/wl.ko.xz
    1.57 +}
    1.58 +
    1.59 +# Post install/remove commands for Tazpkg.
    1.60 +post_install()
    1.61 +{
    1.62 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz-pae
    1.63 +}
    1.64 +
    1.65 +post_remove()
    1.66 +{
    1.67 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz-pae
    1.68 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/broadcom-wl-pae/stuff/001-null-pointer-fix.patch	Fri Jan 19 12:44:23 2024 +0000
     2.3 @@ -0,0 +1,27 @@
     2.4 +Description: Fixing null pointer crash
     2.5 +
     2.6 +Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773713
     2.7 +Bug-Ubuntu: https://launchpad.net/bugs/1415880
     2.8 +Last-Update: 2015-08-18
     2.9 +
    2.10 +---
    2.11 + src/wl/sys/wl_linux.c | 2 +-
    2.12 + 1 file changed, 1 insertion(+), 1 deletion(-)
    2.13 +
    2.14 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
    2.15 +index 860b935..295156f 100644
    2.16 +--- a/src/wl/sys/wl_linux.c
    2.17 ++++ b/src/wl/sys/wl_linux.c
    2.18 +@@ -2157,8 +2157,8 @@ wl_start(struct sk_buff *skb, struct net_device *dev)
    2.19 + 	wlif = WL_DEV_IF(dev);
    2.20 + 	wl = WL_INFO(dev);
    2.21 + 
    2.22 ++	skb->prev = NULL;
    2.23 + 	if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) {
    2.24 +-		skb->prev = NULL;
    2.25 + 
    2.26 + 		TXQ_LOCK(wl);
    2.27 + 
    2.28 +-- 
    2.29 +1.9.1
    2.30 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/broadcom-wl-pae/stuff/002-rdtscl.patch	Fri Jan 19 12:44:23 2024 +0000
     3.3 @@ -0,0 +1,22 @@
     3.4 +Since Linux 4.3, rdtscl() is no longer available and native_read_tsc()
     3.5 +is renamed to rdtsc(). Move the macro contents in-line and call the
     3.6 +new function. References:
     3.7 +
     3.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=fe47ae6e1a5005b2e82f7eab57b5c3820453293a
     3.9 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=4ea1636b04dbd66536fa387bae2eea463efc705b
    3.10 +
    3.11 +diff -ru a/src/shared/linux_osl.c b/src/shared/linux_osl.c
    3.12 +--- a/src/shared/linux_osl.c	2015-09-19 01:47:15.000000000 +0300
    3.13 ++++ b/src/shared/linux_osl.c	2015-11-21 15:20:30.585902518 +0200
    3.14 +@@ -932,7 +932,11 @@
    3.15 + 	uint cycles;
    3.16 + 
    3.17 + #if defined(__i386__)
    3.18 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
    3.19 ++	cycles = (u32)rdtsc();
    3.20 ++#else
    3.21 + 	rdtscl(cycles);
    3.22 ++#endif
    3.23 + #else
    3.24 + 	cycles = 0;
    3.25 + #endif 
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/broadcom-wl-pae/stuff/003-linux47.patch	Fri Jan 19 12:44:23 2024 +0000
     4.3 @@ -0,0 +1,109 @@
     4.4 +Since Linux 4.7, the enum ieee80211_band is no longer used
     4.5 +
     4.6 +This shall cause no problem's since both enums ieee80211_band
     4.7 +and nl80211_band were added in the same commit:
     4.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=13ae75b103e07304a34ab40c9136e9f53e06475c
     4.9 +
    4.10 +This patch refactors the references of IEEE80211_BAND_* to NL80211_BAND_*
    4.11 +
    4.12 +Reference:
    4.13 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=57fbcce37be7c1d2622b56587c10ade00e96afa3
    4.14 +
    4.15 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:57:36.159340297 -0500
    4.16 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:58:18.442323435 -0500
    4.17 +@@ -236,7 +236,7 @@
    4.18 + #endif				
    4.19 + 
    4.20 + #define CHAN2G(_channel, _freq, _flags) {			\
    4.21 +-	.band			= IEEE80211_BAND_2GHZ,		\
    4.22 ++	.band			= NL80211_BAND_2GHZ,		\
    4.23 + 	.center_freq		= (_freq),			\
    4.24 + 	.hw_value		= (_channel),			\
    4.25 + 	.flags			= (_flags),			\
    4.26 +@@ -245,7 +245,7 @@
    4.27 + }
    4.28 + 
    4.29 + #define CHAN5G(_channel, _flags) {				\
    4.30 +-	.band			= IEEE80211_BAND_5GHZ,		\
    4.31 ++	.band			= NL80211_BAND_5GHZ,		\
    4.32 + 	.center_freq		= 5000 + (5 * (_channel)),	\
    4.33 + 	.hw_value		= (_channel),			\
    4.34 + 	.flags			= (_flags),			\
    4.35 +@@ -379,7 +379,7 @@
    4.36 + };
    4.37 + 
    4.38 + static struct ieee80211_supported_band __wl_band_2ghz = {
    4.39 +-	.band = IEEE80211_BAND_2GHZ,
    4.40 ++	.band = NL80211_BAND_2GHZ,
    4.41 + 	.channels = __wl_2ghz_channels,
    4.42 + 	.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
    4.43 + 	.bitrates = wl_g_rates,
    4.44 +@@ -387,7 +387,7 @@
    4.45 + };
    4.46 + 
    4.47 + static struct ieee80211_supported_band __wl_band_5ghz_a = {
    4.48 +-	.band = IEEE80211_BAND_5GHZ,
    4.49 ++	.band = NL80211_BAND_5GHZ,
    4.50 + 	.channels = __wl_5ghz_a_channels,
    4.51 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
    4.52 + 	.bitrates = wl_a_rates,
    4.53 +@@ -395,7 +395,7 @@
    4.54 + };
    4.55 + 
    4.56 + static struct ieee80211_supported_band __wl_band_5ghz_n = {
    4.57 +-	.band = IEEE80211_BAND_5GHZ,
    4.58 ++	.band = NL80211_BAND_5GHZ,
    4.59 + 	.channels = __wl_5ghz_n_channels,
    4.60 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_n_channels),
    4.61 + 	.bitrates = wl_a_rates,
    4.62 +@@ -1876,8 +1876,8 @@
    4.63 + 	wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
    4.64 + #endif
    4.65 + 	wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC);
    4.66 +-	wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
    4.67 +-	wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
    4.68 ++	wdev->wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
    4.69 ++	wdev->wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
    4.70 + 	wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
    4.71 + 	wdev->wiphy->cipher_suites = __wl_cipher_suites;
    4.72 + 	wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
    4.73 +@@ -2000,7 +2000,7 @@
    4.74 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
    4.75 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
    4.76 + 		(notif_bss_info->channel <= CH_MAX_2G_CHANNEL) ?
    4.77 +-		IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ);
    4.78 ++		NL80211_BAND_2GHZ : NL80211_BAND_5GHZ);
    4.79 + #else
    4.80 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
    4.81 + #endif
    4.82 +@@ -2116,7 +2116,7 @@
    4.83 + 				return err;
    4.84 + 			}
    4.85 + 			chan = wf_chspec_ctlchan(chanspec);
    4.86 +-			band = (chan <= CH_MAX_2G_CHANNEL) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
    4.87 ++			band = (chan <= CH_MAX_2G_CHANNEL) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
    4.88 + 			freq = ieee80211_channel_to_frequency(chan, band);
    4.89 + 			channel = ieee80211_get_channel(wiphy, freq);
    4.90 + 			cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL);
    4.91 +@@ -2250,10 +2250,10 @@
    4.92 + 		join_params->params.chanspec_list[0] =
    4.93 + 		    ieee80211_frequency_to_channel(chan->center_freq);
    4.94 + 
    4.95 +-		if (chan->band == IEEE80211_BAND_2GHZ) {
    4.96 ++		if (chan->band == NL80211_BAND_2GHZ) {
    4.97 + 			chanspec |= WL_CHANSPEC_BAND_2G;
    4.98 + 		}
    4.99 +-		else if (chan->band == IEEE80211_BAND_5GHZ) {
   4.100 ++		else if (chan->band == NL80211_BAND_5GHZ) {
   4.101 + 			chanspec |= WL_CHANSPEC_BAND_5G;
   4.102 + 		}
   4.103 + 		else {
   4.104 +@@ -2885,7 +2885,7 @@
   4.105 + 
   4.106 + 	if (phy == 'n' || phy == 'a' || phy == 'v') {
   4.107 + 		wiphy = wl_to_wiphy(wl);
   4.108 +-		wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
   4.109 ++		wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_n;
   4.110 + 	}
   4.111 + 
   4.112 + 	return err;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/broadcom-wl-pae/stuff/004-linux48.patch	Fri Jan 19 12:44:23 2024 +0000
     5.3 @@ -0,0 +1,64 @@
     5.4 +From d3f93542326a06d920c6eb89b703384290d37b8b Mon Sep 17 00:00:00 2001
     5.5 +From: Alberto Milone <alberto.milone@canonical.com>
     5.6 +Date: Fri, 2 Sep 2016 17:35:34 +0200
     5.7 +Subject: [PATCH 1/1] Add support for Linux 4.8
     5.8 +
     5.9 +Orginal author: Krzysztof Kolasa
    5.10 +---
    5.11 + src/wl/sys/wl_cfg80211_hybrid.c | 22 ++++++++++++++++++++++
    5.12 + 1 file changed, 22 insertions(+)
    5.13 +
    5.14 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
    5.15 +index 2fc71fe..ec5e472 100644
    5.16 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    5.17 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    5.18 +@@ -2388,8 +2388,16 @@ wl_bss_connect_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
    5.19 + 	s32 err = 0;
    5.20 + 
    5.21 + 	if (wl->scan_request) {
    5.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
    5.23 ++		struct cfg80211_scan_info info = {
    5.24 ++			.aborted = true,
    5.25 ++		};
    5.26 ++		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
    5.27 ++		cfg80211_scan_done(wl->scan_request, &info);
    5.28 ++#else
    5.29 + 		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
    5.30 + 		cfg80211_scan_done(wl->scan_request, true);     
    5.31 ++#endif
    5.32 + 		wl->scan_request = NULL;
    5.33 + 	}
    5.34 + 
    5.35 +@@ -2490,7 +2498,14 @@ wl_notify_scan_status(struct wl_cfg80211_priv *wl, struct net_device *ndev,
    5.36 + 
    5.37 + scan_done_out:
    5.38 + 	if (wl->scan_request) {
    5.39 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
    5.40 ++		struct cfg80211_scan_info info = {
    5.41 ++			.aborted = false,
    5.42 ++		};
    5.43 ++		cfg80211_scan_done(wl->scan_request, &info);
    5.44 ++#else
    5.45 + 		cfg80211_scan_done(wl->scan_request, false);
    5.46 ++#endif
    5.47 + 		wl->scan_request = NULL;
    5.48 + 	}
    5.49 + 	rtnl_unlock();
    5.50 +@@ -2909,7 +2924,14 @@ s32 wl_cfg80211_down(struct net_device *ndev)
    5.51 + 	s32 err = 0;
    5.52 + 
    5.53 + 	if (wl->scan_request) {
    5.54 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
    5.55 ++		struct cfg80211_scan_info info = {
    5.56 ++			.aborted = true,
    5.57 ++		};
    5.58 ++		cfg80211_scan_done(wl->scan_request, &info);
    5.59 ++#else
    5.60 + 		cfg80211_scan_done(wl->scan_request, true);	
    5.61 ++#endif
    5.62 + 		wl->scan_request = NULL;
    5.63 + 	}
    5.64 + 
    5.65 +-- 
    5.66 +2.7.4
    5.67 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/broadcom-wl-pae/stuff/005-debian-fix-kernel-warnings.patch	Fri Jan 19 12:44:23 2024 +0000
     6.3 @@ -0,0 +1,161 @@
     6.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
     6.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
     6.6 +@@ -1968,7 +1968,7 @@
     6.7 + 
     6.8 + 	if (dtoh32(bi->length) > WL_BSS_INFO_MAX) {
     6.9 + 		WL_DBG(("Beacon is larger than buffer. Discarding\n"));
    6.10 +-		return err;
    6.11 ++		return -E2BIG;
    6.12 + 	}
    6.13 + 	notif_bss_info = kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
    6.14 + 	                         WL_BSS_INFO_MAX, GFP_KERNEL);
    6.15 +@@ -1992,9 +1992,15 @@
    6.16 + 	beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
    6.17 + 	wl_rst_ie(wl);
    6.18 + 
    6.19 +-	wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
    6.20 +-	wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
    6.21 ++	err = wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
    6.22 ++	if (err)
    6.23 ++		goto inform_single_bss_out;
    6.24 ++
    6.25 ++	err = wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
    6.26 + 	         offsetof(struct wl_cfg80211_bss_info, frame_buf));
    6.27 ++	if (err)
    6.28 ++		goto inform_single_bss_out;
    6.29 ++
    6.30 + 	notif_bss_info->frame_len = offsetof(struct ieee80211_mgmt, u.beacon.variable) +
    6.31 + 	                            wl_get_ielen(wl);
    6.32 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
    6.33 +@@ -2006,14 +2012,14 @@
    6.34 + #endif
    6.35 + 	if (freq == 0) {
    6.36 + 		WL_ERR(("Invalid channel, fail to chcnage channel to freq\n"));
    6.37 +-		kfree(notif_bss_info);
    6.38 +-		return -EINVAL;
    6.39 ++		err = -EINVAL;
    6.40 ++		goto inform_single_bss_out;
    6.41 + 	}
    6.42 + 	channel = ieee80211_get_channel(wiphy, freq);
    6.43 + 	if (unlikely(!channel)) {
    6.44 + 		WL_ERR(("ieee80211_get_channel error\n"));
    6.45 +-		kfree(notif_bss_info);
    6.46 +-		return -EINVAL;
    6.47 ++		err = -EINVAL;
    6.48 ++		goto inform_single_bss_out;
    6.49 + 	}
    6.50 + 
    6.51 + 	WL_DBG(("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
    6.52 +@@ -2021,28 +2027,37 @@
    6.53 + 		mgmt->u.beacon.capab_info, &bi->BSSID));
    6.54 + 
    6.55 + 	signal = notif_bss_info->rssi * 100;
    6.56 +-	cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
    6.57 +-	    le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
    6.58 +-	if (unlikely(!cbss)) {
    6.59 +-		WL_ERR(("cfg80211_inform_bss_frame error\n"));
    6.60 +-		kfree(notif_bss_info);
    6.61 +-		return -EINVAL;
    6.62 +-	}
    6.63 + 
    6.64 +-	notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
    6.65 +-	notify_ielen = le32_to_cpu(bi->ie_length);
    6.66 ++	if (!wl->scan_request) {
    6.67 ++		cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
    6.68 ++			le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
    6.69 ++		if (unlikely(!cbss)) {
    6.70 ++			WL_ERR(("cfg80211_inform_bss_frame error\n"));
    6.71 ++			err = -ENOMEM;
    6.72 ++			goto inform_single_bss_out;
    6.73 ++		}
    6.74 ++	} else {
    6.75 ++		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
    6.76 ++		notify_ielen = le32_to_cpu(bi->ie_length);
    6.77 + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
    6.78 +-	cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
    6.79 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
    6.80 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
    6.81 ++		cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
    6.82 ++			0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
    6.83 ++			(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
    6.84 + #else
    6.85 +-	cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, (const u8 *)(bi->BSSID.octet),
    6.86 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
    6.87 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
    6.88 ++		cbss = cfg80211_inform_bss(wiphy, channel,
    6.89 ++				wl->active_scan ?
    6.90 ++				CFG80211_BSS_FTYPE_PRESP : CFG80211_BSS_FTYPE_BEACON,
    6.91 ++				(const u8 *)(bi->BSSID.octet), 0,
    6.92 ++				beacon_proberesp->capab_info,
    6.93 ++				beacon_proberesp->beacon_int,
    6.94 ++				(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
    6.95 + #endif
    6.96 +-
    6.97 +-	if (unlikely(!cbss))
    6.98 +-		return -ENOMEM;
    6.99 ++		if (unlikely(!cbss)) {
   6.100 ++			WL_ERR(("cfg80211_inform_bss error\n"));
   6.101 ++			err = -ENOMEM;
   6.102 ++			goto inform_single_bss_out;
   6.103 ++		}
   6.104 ++	}
   6.105 + 
   6.106 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
   6.107 + 	cfg80211_put_bss(wiphy, cbss);
   6.108 +@@ -2050,6 +2065,7 @@
   6.109 + 	cfg80211_put_bss(cbss);
   6.110 + #endif
   6.111 + 
   6.112 ++inform_single_bss_out:
   6.113 + 	kfree(notif_bss_info);
   6.114 + 
   6.115 + 	return err;
   6.116 +@@ -2316,6 +2332,9 @@
   6.117 + 		if (err)
   6.118 + 			goto update_bss_info_out;
   6.119 + 
   6.120 ++		bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
   6.121 ++		      ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
   6.122 ++
   6.123 + 		ie = ((u8 *)bi) + bi->ie_offset;
   6.124 + 		ie_len = bi->ie_length;
   6.125 + 	} else {
   6.126 +@@ -2328,11 +2347,18 @@
   6.127 + 		ie_len = bss->len_information_elements;
   6.128 + #endif
   6.129 + 		wl->conf->channel = *bss->channel;
   6.130 ++	}
   6.131 ++
   6.132 ++	if (bss) {
   6.133 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
   6.134 + 		cfg80211_put_bss(wiphy, bss);
   6.135 + #else
   6.136 + 		cfg80211_put_bss(bss);
   6.137 + #endif
   6.138 ++	} else {
   6.139 ++		WL_DBG(("Could not update BSS\n"));
   6.140 ++		err = -EINVAL;
   6.141 ++		goto update_bss_info_out;
   6.142 + 	}
   6.143 + 
   6.144 + 	tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
   6.145 +@@ -2360,10 +2386,17 @@
   6.146 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
   6.147 + 	s32 err = 0;
   6.148 + 
   6.149 +-	wl_get_assoc_ies(wl);
   6.150 ++	err = wl_get_assoc_ies(wl);
   6.151 ++	if (err)
   6.152 ++		return err;
   6.153 ++
   6.154 + 	memcpy(wl->profile->bssid, &e->addr, ETHER_ADDR_LEN);
   6.155 + 	memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
   6.156 +-	wl_update_bss_info(wl);
   6.157 ++
   6.158 ++	err = wl_update_bss_info(wl);
   6.159 ++	if (err)
   6.160 ++		return err;
   6.161 ++
   6.162 + 	cfg80211_roamed(ndev,
   6.163 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
   6.164 + 			&wl->conf->channel,	 
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/broadcom-wl-pae/stuff/006-linux411.patch	Fri Jan 19 12:44:23 2024 +0000
     7.3 @@ -0,0 +1,27 @@
     7.4 +diff -u sys0/wl_cfg80211_hybrid.c sys/wl_cfg80211_hybrid.c
     7.5 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
     7.6 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
     7.7 +@@ -39,6 +39,10 @@
     7.8 + #include <proto/802.11.h>
     7.9 + #include <wl_cfg80211_hybrid.h>
    7.10 + 
    7.11 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
    7.12 ++#include <linux/sched/signal.h>
    7.13 ++#endif
    7.14 ++
    7.15 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
    7.16 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
    7.17 + #define EVENT_STATUS(e) dtoh32((e)->status)
    7.18 +diff -u sys0/wl_linux.c sys/wl_linux.c
    7.19 +--- a/src/wl/sys/wl_linux.c
    7.20 ++++ b/src/wl/sys/wl_linux.c
    7.21 +@@ -2915,7 +2915,9 @@
    7.22 + 	if (skb == NULL) return;
    7.23 + 
    7.24 + 	skb->dev = wl->monitor_dev;
    7.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
    7.26 + 	skb->dev->last_rx = jiffies;
    7.27 ++#endif
    7.28 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
    7.29 + 	skb_reset_mac_header(skb);
    7.30 + #else
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/broadcom-wl-pae/stuff/007-linux412.patch	Fri Jan 19 12:44:23 2024 +0000
     8.3 @@ -0,0 +1,78 @@
     8.4 +From 0b888bf115612074df99654140a1980111c29748 Mon Sep 17 00:00:00 2001
     8.5 +From: Antoine Cotten <tonio.cotten@gmail.com>
     8.6 +Date: Fri, 7 Jul 2017 15:17:47 +0200
     8.7 +Subject: [PATCH] Apply patch from Debian bug #867258
     8.8 +
     8.9 +Compile fix with kernel 4.12
    8.10 +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=867258
    8.11 +---
    8.12 + src/wl/sys/wl_cfg80211_hybrid.c | 29 +++++++++++++++++++++++++----
    8.13 + 1 file changed, 25 insertions(+), 4 deletions(-)
    8.14 +
    8.15 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
    8.16 +index c46944a..1a9840a 100644
    8.17 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    8.18 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    8.19 +@@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
    8.20 + #endif
    8.21 + 
    8.22 + static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
    8.23 +-           enum nl80211_iftype type, u32 *flags, struct vif_params *params);
    8.24 ++           enum nl80211_iftype type,
    8.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
    8.26 ++           u32 *flags,
    8.27 ++#endif
    8.28 ++	   struct vif_params *params);
    8.29 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
    8.30 + static s32
    8.31 + wl_cfg80211_scan(struct wiphy *wiphy,
    8.32 +@@ -466,8 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
    8.33 + 
    8.34 + static s32
    8.35 + wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
    8.36 +-                         enum nl80211_iftype type, u32 *flags,
    8.37 +-   struct vif_params *params)
    8.38 ++                         enum nl80211_iftype type,
    8.39 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
    8.40 ++                         u32 *flags,
    8.41 ++#endif
    8.42 ++                         struct vif_params *params)
    8.43 + {
    8.44 + 	struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
    8.45 + 	struct wireless_dev *wdev;
    8.46 +@@ -2387,6 +2394,15 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
    8.47 +                     const wl_event_msg_t *e, void *data)
    8.48 + {
    8.49 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
    8.50 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
    8.51 ++	struct cfg80211_roam_info roam_info = {
    8.52 ++		.bssid = wl->profile->bssid,
    8.53 ++		.req_ie = conn_info->req_ie,
    8.54 ++		.req_ie_len = conn_info->req_ie_len,
    8.55 ++		.resp_ie = conn_info->resp_ie,
    8.56 ++		.resp_ie_len = conn_info->resp_ie_len,
    8.57 ++	};
    8.58 ++#endif
    8.59 + 	s32 err = 0;
    8.60 + 
    8.61 + 	err = wl_get_assoc_ies(wl);
    8.62 +@@ -2401,12 +2417,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
    8.63 + 		return err;
    8.64 + 
    8.65 + 	cfg80211_roamed(ndev,
    8.66 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
    8.67 ++			&roam_info,
    8.68 ++#else
    8.69 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
    8.70 + 			&wl->conf->channel,	 
    8.71 + #endif
    8.72 + 			(u8 *)&wl->bssid,
    8.73 + 			conn_info->req_ie, conn_info->req_ie_len,
    8.74 +-			conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
    8.75 ++			conn_info->resp_ie, conn_info->resp_ie_len,
    8.76 ++#endif
    8.77 ++			GFP_KERNEL);
    8.78 + 	WL_DBG(("Report roaming result\n"));
    8.79 + 
    8.80 + 	set_bit(WL_STATUS_CONNECTED, &wl->status);
    8.81 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/broadcom-wl-pae/stuff/008-linux415.patch	Fri Jan 19 12:44:23 2024 +0000
     9.3 @@ -0,0 +1,46 @@
     9.4 +--- a/src/wl/sys/wl_linux.c	2017-07-17 00:11:24.000000000 +0100
     9.5 ++++ b/src/wl/sys/wl_linux.c	2018-01-27 09:49:47.057799596 +0000
     9.6 +@@ -93,7 +93,11 @@
     9.7 + 
     9.8 + #include <wlc_wowl.h>
     9.9 + 
    9.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
    9.11 ++static void wl_timer(struct timer_list *tl);
    9.12 ++#else
    9.13 + static void wl_timer(ulong data);
    9.14 ++#endif
    9.15 + static void _wl_timer(wl_timer_t *t);
    9.16 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
    9.17 + 
    9.18 +@@ -2297,10 +2301,17 @@
    9.19 + 	atomic_dec(&t->wl->callbacks);
    9.20 + }
    9.21 + 
    9.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
    9.23 ++static void
    9.24 ++wl_timer(struct timer_list *tl)
    9.25 ++{
    9.26 ++	wl_timer_t *t = (wl_timer_t *)tl;
    9.27 ++#else
    9.28 + static void
    9.29 + wl_timer(ulong data)
    9.30 + {
    9.31 + 	wl_timer_t *t = (wl_timer_t *)data;
    9.32 ++#endif
    9.33 + 
    9.34 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
    9.35 + 		_wl_timer(t);
    9.36 +@@ -2352,9 +2363,13 @@
    9.37 + 
    9.38 + 	bzero(t, sizeof(wl_timer_t));
    9.39 + 
    9.40 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
    9.41 ++	timer_setup(&t->timer, wl_timer, 0);
    9.42 ++#else
    9.43 + 	init_timer(&t->timer);
    9.44 + 	t->timer.data = (ulong) t;
    9.45 + 	t->timer.function = wl_timer;
    9.46 ++#endif
    9.47 + 	t->wl = wl;
    9.48 + 	t->fn = fn;
    9.49 + 	t->arg = arg;
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/broadcom-wl-pae/stuff/009-fix_mac_profile_discrepancy.patch	Fri Jan 19 12:44:23 2024 +0000
    10.3 @@ -0,0 +1,14 @@
    10.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2015-09-19 00:47:30.000000000 +0200
    10.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2018-11-14 14:06:03.313487995 +0100
    10.6 +@@ -1444,11 +1444,10 @@
    10.7 + 	s32 rate;
    10.8 + 	s32 err = 0;
    10.9 + 
   10.10 + 	if (memcmp(mac, wl->profile->bssid, ETHER_ADDR_LEN)) {
   10.11 + 		WL_ERR(("Wrong Mac address, mac = %pM   profile =%pM\n", mac, wl->profile->bssid));
   10.12 +-		return -ENOENT;
   10.13 + 	}
   10.14 + 
   10.15 + 	err = wl_dev_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate));
   10.16 + 	if (err) {
   10.17 + 		WL_DBG(("Could not get rate (%d)\n", err));
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/broadcom-wl-pae/stuff/014-linux414.patch	Fri Jan 19 12:44:23 2024 +0000
    11.3 @@ -0,0 +1,37 @@
    11.4 +From: Gerardo Esteban Malazdrewicz <gerardo@malazdrewicz.com.ar>
    11.5 +Date: Fri, 29 Dec 2017 23:44:24 -0400
    11.6 +Subject: linux414
    11.7 +Origin: https://bugs.debian.org/885885
    11.8 +
    11.9 +linux 4.14 changed the kernel_read function prototype.
   11.10 +---
   11.11 + src/shared/linux_osl.c | 12 +++++++++++-
   11.12 + 1 files changed, 12 insertions(+), 1 deletion(-)
   11.13 +
   11.14 +diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
   11.15 +index 9adc392..b24a973 100644
   11.16 +--- a/src/shared/linux_osl.c
   11.17 ++++ b/src/shared/linux_osl.c
   11.18 +@@ -1076,11 +1076,21 @@ osl_os_get_image_block(char *buf, int len, void *image)
   11.19 + {
   11.20 + 	struct file *fp = (struct file *)image;
   11.21 + 	int rdlen;
   11.22 ++	loff_t pos;
   11.23 + 
   11.24 + 	if (!image)
   11.25 + 		return 0;
   11.26 + 
   11.27 +-	rdlen = kernel_read(fp, fp->f_pos, buf, len);
   11.28 ++	pos = fp->f_pos;
   11.29 ++	rdlen = kernel_read(fp,
   11.30 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
   11.31 ++			pos,
   11.32 ++#endif
   11.33 ++			buf, len
   11.34 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
   11.35 ++			,&pos
   11.36 ++#endif
   11.37 ++	);
   11.38 + 	if (rdlen > 0)
   11.39 + 		fp->f_pos += rdlen;
   11.40 + 
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/broadcom-wl-pae/stuff/015-linux419.patch	Fri Jan 19 12:44:23 2024 +0000
    12.3 @@ -0,0 +1,63 @@
    12.4 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
    12.5 +index 489c9f5..f8278ad 100644
    12.6 +--- a/src/wl/sys/wl_linux.c
    12.7 ++++ b/src/wl/sys/wl_linux.c
    12.8 +@@ -93,7 +93,11 @@
    12.9 + 
   12.10 + #include <wlc_wowl.h>
   12.11 + 
   12.12 ++#ifdef HAVE_TIMER_SETUP
   12.13 ++static void wl_timer(struct timer_list *list);
   12.14 ++#else
   12.15 + static void wl_timer(ulong data);
   12.16 ++#endif
   12.17 + static void _wl_timer(wl_timer_t *t);
   12.18 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
   12.19 + 
   12.20 +@@ -2296,12 +2300,17 @@
   12.21 + 
   12.22 + 	atomic_dec(&t->wl->callbacks);
   12.23 + }
   12.24 +-
   12.25 ++#ifdef HAVE_TIMER_SETUP
   12.26 ++static void
   12.27 ++wl_timer(struct timer_list *list)
   12.28 ++{
   12.29 ++	wl_timer_t *t = from_timer(t,list,timer);
   12.30 ++#else
   12.31 + static void
   12.32 + wl_timer(ulong data)
   12.33 + {
   12.34 + 	wl_timer_t *t = (wl_timer_t *)data;
   12.35 +-
   12.36 ++#endif
   12.37 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
   12.38 + 		_wl_timer(t);
   12.39 + 	else
   12.40 +@@ -2351,10 +2360,13 @@
   12.41 + 	}
   12.42 + 
   12.43 + 	bzero(t, sizeof(wl_timer_t));
   12.44 +-
   12.45 ++#ifdef HAVE_TIMER_SETUP
   12.46 ++	timer_setup(&t->timer, wl_timer,0);
   12.47 ++#else
   12.48 + 	init_timer(&t->timer);
   12.49 + 	t->timer.data = (ulong) t;
   12.50 + 	t->timer.function = wl_timer;
   12.51 ++#endif
   12.52 + 	t->wl = wl;
   12.53 + 	t->fn = fn;
   12.54 + 	t->arg = arg;
   12.55 +diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
   12.56 +index 489c9f5..f8278ad 100644
   12.57 +--- a/src/wl/sys/wl_linux.h
   12.58 ++++ b/src/wl/sys/wl_linux.h
   12.59 +@@ -190,3 +190,7 @@
   12.60 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
   12.61 + 
   12.62 + #endif 
   12.63 ++
   12.64 ++#if defined(timer_setup) && defined(from_timer)
   12.65 ++#define HAVE_TIMER_SETUP
   12.66 ++#endif
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/broadcom-wl-pae/stuff/016-linux51.patch	Fri Jan 19 12:44:23 2024 +0000
    13.3 @@ -0,0 +1,24 @@
    13.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    13.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    13.6 +@@ -43,6 +43,9 @@
    13.7 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
    13.8 + #define EVENT_STATUS(e) dtoh32((e)->status)
    13.9 + 
   13.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   13.11 ++#define get_ds() (KERNEL_DS)
   13.12 ++#endif
   13.13 + #ifdef BCMDBG
   13.14 + u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
   13.15 + #else
   13.16 +--- a/src/wl/sys/wl_iw.c
   13.17 ++++ b/src/wl/sys/wl_iw.c
   13.18 +@@ -61,6 +61,9 @@ typedef struct priv_link {
   13.19 + 	wl_iw_t *wliw;
   13.20 + } priv_link_t;
   13.21 + 
   13.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   13.23 ++#define get_ds() (KERNEL_DS)
   13.24 ++#endif
   13.25 + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
   13.26 + #define WL_DEV_LINK(dev)       (priv_link_t*)(dev->priv)
   13.27 + #else
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/broadcom-wl-pae/stuff/017-get-rid-of-get_fs-set_fs-calls.patch	Fri Jan 19 12:44:23 2024 +0000
    14.3 @@ -0,0 +1,207 @@
    14.4 +From: Joan Bruguera <joanbrugueram@gmail.com>
    14.5 +Date: Sun, 13 Sep 2020 07:33:32 +0200
    14.6 +Subject: Get rid of get_fs/set_fs calls in Broadcom WL driver.
    14.7 +Origin: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
    14.8 +
    14.9 +Fixes linux-next where get_fs/set_fs is already removed for some architectures.
   14.10 +
   14.11 +NB: Some checks in wlc_ioctl_internal are likely superfluous,
   14.12 +    but I'm not familiar enough with the driver to remove them with confidence.
   14.13 +
   14.14 +See also: https://lwn.net/Articles/722267/
   14.15 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/x86/include/asm/uaccess.h?h=next-20200911&id=47058bb54b57962b3958a936ddbc59355e4c5504
   14.16 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/linux/uaccess.h?h=next-20200911&id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
   14.17 +
   14.18 +Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
   14.19 +---
   14.20 + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 29 ++-----------------------
   14.21 + amd64/src/wl/sys/wl_iw.c              | 25 ++--------------------
   14.22 + amd64/src/wl/sys/wl_linux.c           | 40 ++++++++++++++++++++++++++++++-----
   14.23 + amd64/src/wl/sys/wl_linux.h           |  2 ++
   14.24 + amd64/src/wl/sys/wlc_pub.h            |  1 +
   14.25 + 5 files changed, 42 insertions(+), 55 deletions(-)
   14.26 +
   14.27 +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   14.28 +index 8e01841..111ec5a 100644
   14.29 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   14.30 ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   14.31 +@@ -41,6 +41,7 @@
   14.32 + #include <wlioctl.h>
   14.33 + #include <proto/802.11.h>
   14.34 + #include <wl_cfg80211_hybrid.h>
   14.35 ++#include <wl_linux.h>
   14.36 + 
   14.37 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
   14.38 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
   14.39 +@@ -442,30 +443,8 @@
   14.40 + static s32
   14.41 + wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
   14.42 + {
   14.43 +-	struct ifreq ifr;
   14.44 +-	struct wl_ioctl ioc;
   14.45 +-	mm_segment_t fs;
   14.46 +-	s32 err = 0;
   14.47 +-
   14.48 + 	BUG_ON(len < sizeof(int));
   14.49 +-
   14.50 +-	memset(&ioc, 0, sizeof(ioc));
   14.51 +-	ioc.cmd = cmd;
   14.52 +-	ioc.buf = arg;
   14.53 +-	ioc.len = len;
   14.54 +-	strcpy(ifr.ifr_name, dev->name);
   14.55 +-	ifr.ifr_data = (caddr_t)&ioc;
   14.56 +-
   14.57 +-	fs = get_fs();
   14.58 +-	set_fs(get_ds());
   14.59 +-#if defined(WL_USE_NETDEV_OPS)
   14.60 +-	err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   14.61 +-#else
   14.62 +-	err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   14.63 +-#endif
   14.64 +-	set_fs(fs);
   14.65 +-
   14.66 +-	return err;
   14.67 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
   14.68 + }
   14.69 + 
   14.70 + static s32
   14.71 +diff --git a/amd64/src/wl/sys/wl_iw.c b/amd64/src/wl/sys/wl_iw.c
   14.72 +index c4c610b..e346b15 100644
   14.73 +--- a/amd64/src/wl/sys/wl_iw.c
   14.74 ++++ b/amd64/src/wl/sys/wl_iw.c
   14.75 +@@ -37,6 +37,7 @@ typedef const struct si_pub	si_t;
   14.76 + 
   14.77 + #include <wl_dbg.h>
   14.78 + #include <wl_iw.h>
   14.79 ++#include <wl_linux.h>
   14.80 + 
   14.81 + extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
   14.82 + 	uint32 reason, char* stringBuf, uint buflen);
   14.83 +@@ -103,29 +104,7 @@ dev_wlc_ioctl(
   14.84 + 	int len
   14.85 + )
   14.86 + {
   14.87 +-	struct ifreq ifr;
   14.88 +-	wl_ioctl_t ioc;
   14.89 +-	mm_segment_t fs;
   14.90 +-	int ret;
   14.91 +-
   14.92 +-	memset(&ioc, 0, sizeof(ioc));
   14.93 +-	ioc.cmd = cmd;
   14.94 +-	ioc.buf = arg;
   14.95 +-	ioc.len = len;
   14.96 +-
   14.97 +-	strcpy(ifr.ifr_name, dev->name);
   14.98 +-	ifr.ifr_data = (caddr_t) &ioc;
   14.99 +-
  14.100 +-	fs = get_fs();
  14.101 +-	set_fs(get_ds());
  14.102 +-#if defined(WL_USE_NETDEV_OPS)
  14.103 +-	ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  14.104 +-#else
  14.105 +-	ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  14.106 +-#endif
  14.107 +-	set_fs(fs);
  14.108 +-
  14.109 +-	return ret;
  14.110 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
  14.111 + }
  14.112 + 
  14.113 + static int
  14.114 +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c
  14.115 +index 66069d4..cc01d2b 100644
  14.116 +--- a/amd64/src/wl/sys/wl_linux.c
  14.117 ++++ b/amd64/src/wl/sys/wl_linux.c
  14.118 +@@ -1661,10 +1661,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  14.119 + 		goto done2;
  14.120 + 	}
  14.121 + 
  14.122 +-	if (segment_eq(get_fs(), KERNEL_DS))
  14.123 +-		buf = ioc.buf;
  14.124 +-
  14.125 +-	else if (ioc.buf) {
  14.126 ++	if (ioc.buf) {
  14.127 + 		if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
  14.128 + 			bcmerror = BCME_NORESOURCE;
  14.129 + 			goto done2;
  14.130 +@@ -1681,7 +1678,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  14.131 + 	WL_UNLOCK(wl);
  14.132 + 
  14.133 + done1:
  14.134 +-	if (ioc.buf && (ioc.buf != buf)) {
  14.135 ++	if (ioc.buf) {
  14.136 + 		if (copy_to_user(ioc.buf, buf, ioc.len))
  14.137 + 			bcmerror = BCME_BADADDR;
  14.138 + 		MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
  14.139 +@@ -1694,6 +1691,39 @@ done2:
  14.140 + 	return (OSL_ERROR(bcmerror));
  14.141 + }
  14.142 + 
  14.143 ++int
  14.144 ++wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
  14.145 ++{
  14.146 ++	wl_info_t *wl;
  14.147 ++	wl_if_t *wlif;
  14.148 ++	int bcmerror;
  14.149 ++
  14.150 ++	if (!dev)
  14.151 ++		return -ENETDOWN;
  14.152 ++
  14.153 ++	wl = WL_INFO(dev);
  14.154 ++	wlif = WL_DEV_IF(dev);
  14.155 ++	if (wlif == NULL || wl == NULL || wl->dev == NULL)
  14.156 ++		return -ENETDOWN;
  14.157 ++
  14.158 ++	bcmerror = 0;
  14.159 ++
  14.160 ++	WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
  14.161 ++
  14.162 ++	WL_LOCK(wl);
  14.163 ++	if (!capable(CAP_NET_ADMIN)) {
  14.164 ++		bcmerror = BCME_EPERM;
  14.165 ++	} else {
  14.166 ++		bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
  14.167 ++	}
  14.168 ++	WL_UNLOCK(wl);
  14.169 ++
  14.170 ++	ASSERT(VALID_BCMERROR(bcmerror));
  14.171 ++	if (bcmerror != 0)
  14.172 ++		wl->pub->bcmerror = bcmerror;
  14.173 ++	return (OSL_ERROR(bcmerror));
  14.174 ++}
  14.175 ++
  14.176 + static struct net_device_stats*
  14.177 + wl_get_stats(struct net_device *dev)
  14.178 + {
  14.179 +diff --git a/amd64/src/wl/sys/wl_linux.h b/amd64/src/wl/sys/wl_linux.h
  14.180 +index 5b1048e..c8c1f41 100644
  14.181 +--- a/amd64/src/wl/sys/wl_linux.h
  14.182 ++++ b/amd64/src/wl/sys/wl_linux.h
  14.183 +@@ -22,6 +22,7 @@
  14.184 + #define _wl_linux_h_
  14.185 + 
  14.186 + #include <wlc_types.h>
  14.187 ++#include <wlc_pub.h>
  14.188 + 
  14.189 + typedef struct wl_timer {
  14.190 + 	struct timer_list 	timer;
  14.191 +@@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
  14.192 + extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  14.193 + extern void wl_free(wl_info_t *wl);
  14.194 + extern int  wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  14.195 ++extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
  14.196 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
  14.197 + 
  14.198 + #endif 
  14.199 +diff --git a/amd64/src/wl/sys/wlc_pub.h b/amd64/src/wl/sys/wlc_pub.h
  14.200 +index 53a98b8..2b5a029 100644
  14.201 +--- a/amd64/src/wl/sys/wlc_pub.h
  14.202 ++++ b/amd64/src/wl/sys/wlc_pub.h
  14.203 +@@ -24,6 +24,7 @@
  14.204 + 
  14.205 + #include <wlc_types.h>
  14.206 + #include <wlc_utils.h>
  14.207 ++#include <siutils.h>
  14.208 + #include "proto/802.11.h"
  14.209 + #include "proto/bcmevent.h"
  14.210 + 
    15.1 --- a/broadcom-wl/receipt	Wed Jan 17 12:05:22 2024 +0000
    15.2 +++ b/broadcom-wl/receipt	Fri Jan 19 12:44:23 2024 +0000
    15.3 @@ -1,14 +1,14 @@
    15.4  # SliTaz package receipt.
    15.5  
    15.6  PACKAGE="broadcom-wl"
    15.7 -VERSION="5_100_82_112"
    15.8 +VERSION="6_30_223_271"
    15.9  CATEGORY="network"
   15.10 -MAINTAINER="jozee@slitaz.org"
   15.11 +MAINTAINER="maintainer@slitaz.org"
   15.12  LICENSE="other"
   15.13  SHORT_DESC="Broadcom 802.11abg Linux STA Networking Drivers"
   15.14 -WEB_SITE="https://web.archive.org/web/20150506062632/http://www.broadcom.com/support/802.11/linux_sta.php"
   15.15 -TARBALL="hybrid-portsrc_x86_32-v${VERSION}.tar.gz"
   15.16 -WGET_URL="ftp://ftp.fr.freebsd.org/mirrors/rsync.frugalware.org/frugalware-testing/source/network-extra/bcmwl/$TARBALL"
   15.17 +WEB_SITE="https://www.broadcom.com/support/download-search/?pf=Wireless+LAN+Infrastructure"
   15.18 +TARBALL="hybrid-v35-nodebug-pcoem-$VERSION.tar.gz"
   15.19 +WGET_URL="https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/$TARBALL"
   15.20  TAGS="wireless wifi driver"
   15.21  
   15.22  DEPENDS="linux"
   15.23 @@ -17,33 +17,48 @@
   15.24  # Rules to configure and make the package.
   15.25  compile_rules()
   15.26  {
   15.27 -	sed -i 's|ndo_set_multicast_list|ndo_set_rx_mode|' src/wl/sys/wl_linux.c
   15.28 -	sed -i 's|linux/autoconf.h|generated/autoconf.h|' src/include/linuxver.h
   15.29 -	for i in semaphore 3.4.0 3.6.0 3.8.0 3.9.0 3.14.0 ; do
   15.30 -		echo "patch $i ..."
   15.31 -		patch -Np2 -i $stuff/$i.patch
   15.32 -	done
   15.33 -	KBUILD_NOPEDANTIC=1 make -C /usr/src/linux M=`pwd`
   15.34 -	xz wl.ko
   15.35 +    # Use wlan instead eth
   15.36 +    sed -i -e '/BRCM_WLAN_IFNAME/s/eth/wlan/' src/wl/sys/wl_linux.c
   15.37 +
   15.38 +    while read file; do
   15.39 +        [ -f done.$file ] && continue
   15.40 +        echo "Apply $file..."
   15.41 +        patch -p1 < $stuff/$file || return 1
   15.42 +        cp $stuff/$file done.$file
   15.43 +    done <<EOT
   15.44 +001-null-pointer-fix.patch
   15.45 +002-rdtscl.patch
   15.46 +003-linux47.patch
   15.47 +004-linux48.patch
   15.48 +005-debian-fix-kernel-warnings.patch
   15.49 +006-linux411.patch
   15.50 +007-linux412.patch
   15.51 +008-linux415.patch
   15.52 +009-fix_mac_profile_discrepancy.patch
   15.53 +014-linux414.patch
   15.54 +EOT
   15.55 +
   15.56 +    KBUILD_NOPEDANTIC=1 make -C /usr/src/linux M=`pwd`
   15.57 +    xz wl.ko
   15.58  }
   15.59  
   15.60  # Rules to gen a SliTaz package suitable for Tazpkg.
   15.61  genpkg_rules()
   15.62  {
   15.63 -	EXTRAVERSION=_${kvers}
   15.64 -	mkdir -p $fs/lib/modules/${kvers}-slitaz/kernel/drivers/net/wireless
   15.65 -	# Compress and install module
   15.66 -	install -o root -m 0644 $src/wl.ko.xz \
   15.67 -		$fs/lib/modules/${kvers}-slitaz/kernel/drivers/net/wireless/wl.ko.xz
   15.68 +    EXTRAVERSION=_${kvers}
   15.69 +    mkdir -p $fs/lib/modules/${kvers}-slitaz/kernel/drivers/net/wireless
   15.70 +    # Compress and install module
   15.71 +    install -o root -m 0644 $src/wl.ko.xz \
   15.72 +        $fs/lib/modules/${kvers}-slitaz/kernel/drivers/net/wireless/wl.ko.xz
   15.73  }
   15.74  
   15.75  # Post install/remove commands for Tazpkg.
   15.76  post_install()
   15.77  {
   15.78 -	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz
   15.79 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz
   15.80  }
   15.81  
   15.82  post_remove()
   15.83  {
   15.84 -	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz
   15.85 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz
   15.86  }
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/broadcom-wl/stuff/001-null-pointer-fix.patch	Fri Jan 19 12:44:23 2024 +0000
    16.3 @@ -0,0 +1,27 @@
    16.4 +Description: Fixing null pointer crash
    16.5 +
    16.6 +Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773713
    16.7 +Bug-Ubuntu: https://launchpad.net/bugs/1415880
    16.8 +Last-Update: 2015-08-18
    16.9 +
   16.10 +---
   16.11 + src/wl/sys/wl_linux.c | 2 +-
   16.12 + 1 file changed, 1 insertion(+), 1 deletion(-)
   16.13 +
   16.14 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
   16.15 +index 860b935..295156f 100644
   16.16 +--- a/src/wl/sys/wl_linux.c
   16.17 ++++ b/src/wl/sys/wl_linux.c
   16.18 +@@ -2157,8 +2157,8 @@ wl_start(struct sk_buff *skb, struct net_device *dev)
   16.19 + 	wlif = WL_DEV_IF(dev);
   16.20 + 	wl = WL_INFO(dev);
   16.21 + 
   16.22 ++	skb->prev = NULL;
   16.23 + 	if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) {
   16.24 +-		skb->prev = NULL;
   16.25 + 
   16.26 + 		TXQ_LOCK(wl);
   16.27 + 
   16.28 +-- 
   16.29 +1.9.1
   16.30 +
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/broadcom-wl/stuff/002-rdtscl.patch	Fri Jan 19 12:44:23 2024 +0000
    17.3 @@ -0,0 +1,22 @@
    17.4 +Since Linux 4.3, rdtscl() is no longer available and native_read_tsc()
    17.5 +is renamed to rdtsc(). Move the macro contents in-line and call the
    17.6 +new function. References:
    17.7 +
    17.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=fe47ae6e1a5005b2e82f7eab57b5c3820453293a
    17.9 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=4ea1636b04dbd66536fa387bae2eea463efc705b
   17.10 +
   17.11 +diff -ru a/src/shared/linux_osl.c b/src/shared/linux_osl.c
   17.12 +--- a/src/shared/linux_osl.c	2015-09-19 01:47:15.000000000 +0300
   17.13 ++++ b/src/shared/linux_osl.c	2015-11-21 15:20:30.585902518 +0200
   17.14 +@@ -932,7 +932,11 @@
   17.15 + 	uint cycles;
   17.16 + 
   17.17 + #if defined(__i386__)
   17.18 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
   17.19 ++	cycles = (u32)rdtsc();
   17.20 ++#else
   17.21 + 	rdtscl(cycles);
   17.22 ++#endif
   17.23 + #else
   17.24 + 	cycles = 0;
   17.25 + #endif 
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/broadcom-wl/stuff/003-linux47.patch	Fri Jan 19 12:44:23 2024 +0000
    18.3 @@ -0,0 +1,109 @@
    18.4 +Since Linux 4.7, the enum ieee80211_band is no longer used
    18.5 +
    18.6 +This shall cause no problem's since both enums ieee80211_band
    18.7 +and nl80211_band were added in the same commit:
    18.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=13ae75b103e07304a34ab40c9136e9f53e06475c
    18.9 +
   18.10 +This patch refactors the references of IEEE80211_BAND_* to NL80211_BAND_*
   18.11 +
   18.12 +Reference:
   18.13 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=57fbcce37be7c1d2622b56587c10ade00e96afa3
   18.14 +
   18.15 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:57:36.159340297 -0500
   18.16 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:58:18.442323435 -0500
   18.17 +@@ -236,7 +236,7 @@
   18.18 + #endif				
   18.19 + 
   18.20 + #define CHAN2G(_channel, _freq, _flags) {			\
   18.21 +-	.band			= IEEE80211_BAND_2GHZ,		\
   18.22 ++	.band			= NL80211_BAND_2GHZ,		\
   18.23 + 	.center_freq		= (_freq),			\
   18.24 + 	.hw_value		= (_channel),			\
   18.25 + 	.flags			= (_flags),			\
   18.26 +@@ -245,7 +245,7 @@
   18.27 + }
   18.28 + 
   18.29 + #define CHAN5G(_channel, _flags) {				\
   18.30 +-	.band			= IEEE80211_BAND_5GHZ,		\
   18.31 ++	.band			= NL80211_BAND_5GHZ,		\
   18.32 + 	.center_freq		= 5000 + (5 * (_channel)),	\
   18.33 + 	.hw_value		= (_channel),			\
   18.34 + 	.flags			= (_flags),			\
   18.35 +@@ -379,7 +379,7 @@
   18.36 + };
   18.37 + 
   18.38 + static struct ieee80211_supported_band __wl_band_2ghz = {
   18.39 +-	.band = IEEE80211_BAND_2GHZ,
   18.40 ++	.band = NL80211_BAND_2GHZ,
   18.41 + 	.channels = __wl_2ghz_channels,
   18.42 + 	.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
   18.43 + 	.bitrates = wl_g_rates,
   18.44 +@@ -387,7 +387,7 @@
   18.45 + };
   18.46 + 
   18.47 + static struct ieee80211_supported_band __wl_band_5ghz_a = {
   18.48 +-	.band = IEEE80211_BAND_5GHZ,
   18.49 ++	.band = NL80211_BAND_5GHZ,
   18.50 + 	.channels = __wl_5ghz_a_channels,
   18.51 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
   18.52 + 	.bitrates = wl_a_rates,
   18.53 +@@ -395,7 +395,7 @@
   18.54 + };
   18.55 + 
   18.56 + static struct ieee80211_supported_band __wl_band_5ghz_n = {
   18.57 +-	.band = IEEE80211_BAND_5GHZ,
   18.58 ++	.band = NL80211_BAND_5GHZ,
   18.59 + 	.channels = __wl_5ghz_n_channels,
   18.60 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_n_channels),
   18.61 + 	.bitrates = wl_a_rates,
   18.62 +@@ -1876,8 +1876,8 @@
   18.63 + 	wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
   18.64 + #endif
   18.65 + 	wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC);
   18.66 +-	wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
   18.67 +-	wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
   18.68 ++	wdev->wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
   18.69 ++	wdev->wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
   18.70 + 	wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
   18.71 + 	wdev->wiphy->cipher_suites = __wl_cipher_suites;
   18.72 + 	wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
   18.73 +@@ -2000,7 +2000,7 @@
   18.74 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
   18.75 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
   18.76 + 		(notif_bss_info->channel <= CH_MAX_2G_CHANNEL) ?
   18.77 +-		IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ);
   18.78 ++		NL80211_BAND_2GHZ : NL80211_BAND_5GHZ);
   18.79 + #else
   18.80 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
   18.81 + #endif
   18.82 +@@ -2116,7 +2116,7 @@
   18.83 + 				return err;
   18.84 + 			}
   18.85 + 			chan = wf_chspec_ctlchan(chanspec);
   18.86 +-			band = (chan <= CH_MAX_2G_CHANNEL) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
   18.87 ++			band = (chan <= CH_MAX_2G_CHANNEL) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
   18.88 + 			freq = ieee80211_channel_to_frequency(chan, band);
   18.89 + 			channel = ieee80211_get_channel(wiphy, freq);
   18.90 + 			cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL);
   18.91 +@@ -2250,10 +2250,10 @@
   18.92 + 		join_params->params.chanspec_list[0] =
   18.93 + 		    ieee80211_frequency_to_channel(chan->center_freq);
   18.94 + 
   18.95 +-		if (chan->band == IEEE80211_BAND_2GHZ) {
   18.96 ++		if (chan->band == NL80211_BAND_2GHZ) {
   18.97 + 			chanspec |= WL_CHANSPEC_BAND_2G;
   18.98 + 		}
   18.99 +-		else if (chan->band == IEEE80211_BAND_5GHZ) {
  18.100 ++		else if (chan->band == NL80211_BAND_5GHZ) {
  18.101 + 			chanspec |= WL_CHANSPEC_BAND_5G;
  18.102 + 		}
  18.103 + 		else {
  18.104 +@@ -2885,7 +2885,7 @@
  18.105 + 
  18.106 + 	if (phy == 'n' || phy == 'a' || phy == 'v') {
  18.107 + 		wiphy = wl_to_wiphy(wl);
  18.108 +-		wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  18.109 ++		wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  18.110 + 	}
  18.111 + 
  18.112 + 	return err;
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/broadcom-wl/stuff/004-linux48.patch	Fri Jan 19 12:44:23 2024 +0000
    19.3 @@ -0,0 +1,64 @@
    19.4 +From d3f93542326a06d920c6eb89b703384290d37b8b Mon Sep 17 00:00:00 2001
    19.5 +From: Alberto Milone <alberto.milone@canonical.com>
    19.6 +Date: Fri, 2 Sep 2016 17:35:34 +0200
    19.7 +Subject: [PATCH 1/1] Add support for Linux 4.8
    19.8 +
    19.9 +Orginal author: Krzysztof Kolasa
   19.10 +---
   19.11 + src/wl/sys/wl_cfg80211_hybrid.c | 22 ++++++++++++++++++++++
   19.12 + 1 file changed, 22 insertions(+)
   19.13 +
   19.14 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
   19.15 +index 2fc71fe..ec5e472 100644
   19.16 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
   19.17 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
   19.18 +@@ -2388,8 +2388,16 @@ wl_bss_connect_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   19.19 + 	s32 err = 0;
   19.20 + 
   19.21 + 	if (wl->scan_request) {
   19.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   19.23 ++		struct cfg80211_scan_info info = {
   19.24 ++			.aborted = true,
   19.25 ++		};
   19.26 ++		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
   19.27 ++		cfg80211_scan_done(wl->scan_request, &info);
   19.28 ++#else
   19.29 + 		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
   19.30 + 		cfg80211_scan_done(wl->scan_request, true);     
   19.31 ++#endif
   19.32 + 		wl->scan_request = NULL;
   19.33 + 	}
   19.34 + 
   19.35 +@@ -2490,7 +2498,14 @@ wl_notify_scan_status(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   19.36 + 
   19.37 + scan_done_out:
   19.38 + 	if (wl->scan_request) {
   19.39 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   19.40 ++		struct cfg80211_scan_info info = {
   19.41 ++			.aborted = false,
   19.42 ++		};
   19.43 ++		cfg80211_scan_done(wl->scan_request, &info);
   19.44 ++#else
   19.45 + 		cfg80211_scan_done(wl->scan_request, false);
   19.46 ++#endif
   19.47 + 		wl->scan_request = NULL;
   19.48 + 	}
   19.49 + 	rtnl_unlock();
   19.50 +@@ -2909,7 +2924,14 @@ s32 wl_cfg80211_down(struct net_device *ndev)
   19.51 + 	s32 err = 0;
   19.52 + 
   19.53 + 	if (wl->scan_request) {
   19.54 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   19.55 ++		struct cfg80211_scan_info info = {
   19.56 ++			.aborted = true,
   19.57 ++		};
   19.58 ++		cfg80211_scan_done(wl->scan_request, &info);
   19.59 ++#else
   19.60 + 		cfg80211_scan_done(wl->scan_request, true);	
   19.61 ++#endif
   19.62 + 		wl->scan_request = NULL;
   19.63 + 	}
   19.64 + 
   19.65 +-- 
   19.66 +2.7.4
   19.67 +
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/broadcom-wl/stuff/005-debian-fix-kernel-warnings.patch	Fri Jan 19 12:44:23 2024 +0000
    20.3 @@ -0,0 +1,161 @@
    20.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    20.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    20.6 +@@ -1968,7 +1968,7 @@
    20.7 + 
    20.8 + 	if (dtoh32(bi->length) > WL_BSS_INFO_MAX) {
    20.9 + 		WL_DBG(("Beacon is larger than buffer. Discarding\n"));
   20.10 +-		return err;
   20.11 ++		return -E2BIG;
   20.12 + 	}
   20.13 + 	notif_bss_info = kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
   20.14 + 	                         WL_BSS_INFO_MAX, GFP_KERNEL);
   20.15 +@@ -1992,9 +1992,15 @@
   20.16 + 	beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
   20.17 + 	wl_rst_ie(wl);
   20.18 + 
   20.19 +-	wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
   20.20 +-	wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
   20.21 ++	err = wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
   20.22 ++	if (err)
   20.23 ++		goto inform_single_bss_out;
   20.24 ++
   20.25 ++	err = wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
   20.26 + 	         offsetof(struct wl_cfg80211_bss_info, frame_buf));
   20.27 ++	if (err)
   20.28 ++		goto inform_single_bss_out;
   20.29 ++
   20.30 + 	notif_bss_info->frame_len = offsetof(struct ieee80211_mgmt, u.beacon.variable) +
   20.31 + 	                            wl_get_ielen(wl);
   20.32 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
   20.33 +@@ -2006,14 +2012,14 @@
   20.34 + #endif
   20.35 + 	if (freq == 0) {
   20.36 + 		WL_ERR(("Invalid channel, fail to chcnage channel to freq\n"));
   20.37 +-		kfree(notif_bss_info);
   20.38 +-		return -EINVAL;
   20.39 ++		err = -EINVAL;
   20.40 ++		goto inform_single_bss_out;
   20.41 + 	}
   20.42 + 	channel = ieee80211_get_channel(wiphy, freq);
   20.43 + 	if (unlikely(!channel)) {
   20.44 + 		WL_ERR(("ieee80211_get_channel error\n"));
   20.45 +-		kfree(notif_bss_info);
   20.46 +-		return -EINVAL;
   20.47 ++		err = -EINVAL;
   20.48 ++		goto inform_single_bss_out;
   20.49 + 	}
   20.50 + 
   20.51 + 	WL_DBG(("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
   20.52 +@@ -2021,28 +2027,37 @@
   20.53 + 		mgmt->u.beacon.capab_info, &bi->BSSID));
   20.54 + 
   20.55 + 	signal = notif_bss_info->rssi * 100;
   20.56 +-	cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
   20.57 +-	    le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
   20.58 +-	if (unlikely(!cbss)) {
   20.59 +-		WL_ERR(("cfg80211_inform_bss_frame error\n"));
   20.60 +-		kfree(notif_bss_info);
   20.61 +-		return -EINVAL;
   20.62 +-	}
   20.63 + 
   20.64 +-	notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
   20.65 +-	notify_ielen = le32_to_cpu(bi->ie_length);
   20.66 ++	if (!wl->scan_request) {
   20.67 ++		cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
   20.68 ++			le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
   20.69 ++		if (unlikely(!cbss)) {
   20.70 ++			WL_ERR(("cfg80211_inform_bss_frame error\n"));
   20.71 ++			err = -ENOMEM;
   20.72 ++			goto inform_single_bss_out;
   20.73 ++		}
   20.74 ++	} else {
   20.75 ++		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
   20.76 ++		notify_ielen = le32_to_cpu(bi->ie_length);
   20.77 + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
   20.78 +-	cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
   20.79 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   20.80 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   20.81 ++		cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
   20.82 ++			0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   20.83 ++			(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   20.84 + #else
   20.85 +-	cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, (const u8 *)(bi->BSSID.octet),
   20.86 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   20.87 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   20.88 ++		cbss = cfg80211_inform_bss(wiphy, channel,
   20.89 ++				wl->active_scan ?
   20.90 ++				CFG80211_BSS_FTYPE_PRESP : CFG80211_BSS_FTYPE_BEACON,
   20.91 ++				(const u8 *)(bi->BSSID.octet), 0,
   20.92 ++				beacon_proberesp->capab_info,
   20.93 ++				beacon_proberesp->beacon_int,
   20.94 ++				(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   20.95 + #endif
   20.96 +-
   20.97 +-	if (unlikely(!cbss))
   20.98 +-		return -ENOMEM;
   20.99 ++		if (unlikely(!cbss)) {
  20.100 ++			WL_ERR(("cfg80211_inform_bss error\n"));
  20.101 ++			err = -ENOMEM;
  20.102 ++			goto inform_single_bss_out;
  20.103 ++		}
  20.104 ++	}
  20.105 + 
  20.106 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
  20.107 + 	cfg80211_put_bss(wiphy, cbss);
  20.108 +@@ -2050,6 +2065,7 @@
  20.109 + 	cfg80211_put_bss(cbss);
  20.110 + #endif
  20.111 + 
  20.112 ++inform_single_bss_out:
  20.113 + 	kfree(notif_bss_info);
  20.114 + 
  20.115 + 	return err;
  20.116 +@@ -2316,6 +2332,9 @@
  20.117 + 		if (err)
  20.118 + 			goto update_bss_info_out;
  20.119 + 
  20.120 ++		bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
  20.121 ++		      ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  20.122 ++
  20.123 + 		ie = ((u8 *)bi) + bi->ie_offset;
  20.124 + 		ie_len = bi->ie_length;
  20.125 + 	} else {
  20.126 +@@ -2328,11 +2347,18 @@
  20.127 + 		ie_len = bss->len_information_elements;
  20.128 + #endif
  20.129 + 		wl->conf->channel = *bss->channel;
  20.130 ++	}
  20.131 ++
  20.132 ++	if (bss) {
  20.133 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
  20.134 + 		cfg80211_put_bss(wiphy, bss);
  20.135 + #else
  20.136 + 		cfg80211_put_bss(bss);
  20.137 + #endif
  20.138 ++	} else {
  20.139 ++		WL_DBG(("Could not update BSS\n"));
  20.140 ++		err = -EINVAL;
  20.141 ++		goto update_bss_info_out;
  20.142 + 	}
  20.143 + 
  20.144 + 	tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
  20.145 +@@ -2360,10 +2386,17 @@
  20.146 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
  20.147 + 	s32 err = 0;
  20.148 + 
  20.149 +-	wl_get_assoc_ies(wl);
  20.150 ++	err = wl_get_assoc_ies(wl);
  20.151 ++	if (err)
  20.152 ++		return err;
  20.153 ++
  20.154 + 	memcpy(wl->profile->bssid, &e->addr, ETHER_ADDR_LEN);
  20.155 + 	memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
  20.156 +-	wl_update_bss_info(wl);
  20.157 ++
  20.158 ++	err = wl_update_bss_info(wl);
  20.159 ++	if (err)
  20.160 ++		return err;
  20.161 ++
  20.162 + 	cfg80211_roamed(ndev,
  20.163 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
  20.164 + 			&wl->conf->channel,	 
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/broadcom-wl/stuff/006-linux411.patch	Fri Jan 19 12:44:23 2024 +0000
    21.3 @@ -0,0 +1,27 @@
    21.4 +diff -u sys0/wl_cfg80211_hybrid.c sys/wl_cfg80211_hybrid.c
    21.5 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    21.6 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    21.7 +@@ -39,6 +39,10 @@
    21.8 + #include <proto/802.11.h>
    21.9 + #include <wl_cfg80211_hybrid.h>
   21.10 + 
   21.11 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
   21.12 ++#include <linux/sched/signal.h>
   21.13 ++#endif
   21.14 ++
   21.15 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
   21.16 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
   21.17 + #define EVENT_STATUS(e) dtoh32((e)->status)
   21.18 +diff -u sys0/wl_linux.c sys/wl_linux.c
   21.19 +--- a/src/wl/sys/wl_linux.c
   21.20 ++++ b/src/wl/sys/wl_linux.c
   21.21 +@@ -2915,7 +2915,9 @@
   21.22 + 	if (skb == NULL) return;
   21.23 + 
   21.24 + 	skb->dev = wl->monitor_dev;
   21.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
   21.26 + 	skb->dev->last_rx = jiffies;
   21.27 ++#endif
   21.28 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
   21.29 + 	skb_reset_mac_header(skb);
   21.30 + #else
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/broadcom-wl/stuff/007-linux412.patch	Fri Jan 19 12:44:23 2024 +0000
    22.3 @@ -0,0 +1,78 @@
    22.4 +From 0b888bf115612074df99654140a1980111c29748 Mon Sep 17 00:00:00 2001
    22.5 +From: Antoine Cotten <tonio.cotten@gmail.com>
    22.6 +Date: Fri, 7 Jul 2017 15:17:47 +0200
    22.7 +Subject: [PATCH] Apply patch from Debian bug #867258
    22.8 +
    22.9 +Compile fix with kernel 4.12
   22.10 +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=867258
   22.11 +---
   22.12 + src/wl/sys/wl_cfg80211_hybrid.c | 29 +++++++++++++++++++++++++----
   22.13 + 1 file changed, 25 insertions(+), 4 deletions(-)
   22.14 +
   22.15 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
   22.16 +index c46944a..1a9840a 100644
   22.17 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
   22.18 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
   22.19 +@@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
   22.20 + #endif
   22.21 + 
   22.22 + static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
   22.23 +-           enum nl80211_iftype type, u32 *flags, struct vif_params *params);
   22.24 ++           enum nl80211_iftype type,
   22.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
   22.26 ++           u32 *flags,
   22.27 ++#endif
   22.28 ++	   struct vif_params *params);
   22.29 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
   22.30 + static s32
   22.31 + wl_cfg80211_scan(struct wiphy *wiphy,
   22.32 +@@ -466,8 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
   22.33 + 
   22.34 + static s32
   22.35 + wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
   22.36 +-                         enum nl80211_iftype type, u32 *flags,
   22.37 +-   struct vif_params *params)
   22.38 ++                         enum nl80211_iftype type,
   22.39 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
   22.40 ++                         u32 *flags,
   22.41 ++#endif
   22.42 ++                         struct vif_params *params)
   22.43 + {
   22.44 + 	struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
   22.45 + 	struct wireless_dev *wdev;
   22.46 +@@ -2387,6 +2394,15 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   22.47 +                     const wl_event_msg_t *e, void *data)
   22.48 + {
   22.49 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
   22.50 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
   22.51 ++	struct cfg80211_roam_info roam_info = {
   22.52 ++		.bssid = wl->profile->bssid,
   22.53 ++		.req_ie = conn_info->req_ie,
   22.54 ++		.req_ie_len = conn_info->req_ie_len,
   22.55 ++		.resp_ie = conn_info->resp_ie,
   22.56 ++		.resp_ie_len = conn_info->resp_ie_len,
   22.57 ++	};
   22.58 ++#endif
   22.59 + 	s32 err = 0;
   22.60 + 
   22.61 + 	err = wl_get_assoc_ies(wl);
   22.62 +@@ -2401,12 +2417,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   22.63 + 		return err;
   22.64 + 
   22.65 + 	cfg80211_roamed(ndev,
   22.66 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
   22.67 ++			&roam_info,
   22.68 ++#else
   22.69 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
   22.70 + 			&wl->conf->channel,	 
   22.71 + #endif
   22.72 + 			(u8 *)&wl->bssid,
   22.73 + 			conn_info->req_ie, conn_info->req_ie_len,
   22.74 +-			conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
   22.75 ++			conn_info->resp_ie, conn_info->resp_ie_len,
   22.76 ++#endif
   22.77 ++			GFP_KERNEL);
   22.78 + 	WL_DBG(("Report roaming result\n"));
   22.79 + 
   22.80 + 	set_bit(WL_STATUS_CONNECTED, &wl->status);
   22.81 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/broadcom-wl/stuff/008-linux415.patch	Fri Jan 19 12:44:23 2024 +0000
    23.3 @@ -0,0 +1,46 @@
    23.4 +--- a/src/wl/sys/wl_linux.c	2017-07-17 00:11:24.000000000 +0100
    23.5 ++++ b/src/wl/sys/wl_linux.c	2018-01-27 09:49:47.057799596 +0000
    23.6 +@@ -93,7 +93,11 @@
    23.7 + 
    23.8 + #include <wlc_wowl.h>
    23.9 + 
   23.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   23.11 ++static void wl_timer(struct timer_list *tl);
   23.12 ++#else
   23.13 + static void wl_timer(ulong data);
   23.14 ++#endif
   23.15 + static void _wl_timer(wl_timer_t *t);
   23.16 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
   23.17 + 
   23.18 +@@ -2297,10 +2301,17 @@
   23.19 + 	atomic_dec(&t->wl->callbacks);
   23.20 + }
   23.21 + 
   23.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   23.23 ++static void
   23.24 ++wl_timer(struct timer_list *tl)
   23.25 ++{
   23.26 ++	wl_timer_t *t = (wl_timer_t *)tl;
   23.27 ++#else
   23.28 + static void
   23.29 + wl_timer(ulong data)
   23.30 + {
   23.31 + 	wl_timer_t *t = (wl_timer_t *)data;
   23.32 ++#endif
   23.33 + 
   23.34 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
   23.35 + 		_wl_timer(t);
   23.36 +@@ -2352,9 +2363,13 @@
   23.37 + 
   23.38 + 	bzero(t, sizeof(wl_timer_t));
   23.39 + 
   23.40 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   23.41 ++	timer_setup(&t->timer, wl_timer, 0);
   23.42 ++#else
   23.43 + 	init_timer(&t->timer);
   23.44 + 	t->timer.data = (ulong) t;
   23.45 + 	t->timer.function = wl_timer;
   23.46 ++#endif
   23.47 + 	t->wl = wl;
   23.48 + 	t->fn = fn;
   23.49 + 	t->arg = arg;
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/broadcom-wl/stuff/009-fix_mac_profile_discrepancy.patch	Fri Jan 19 12:44:23 2024 +0000
    24.3 @@ -0,0 +1,14 @@
    24.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2015-09-19 00:47:30.000000000 +0200
    24.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2018-11-14 14:06:03.313487995 +0100
    24.6 +@@ -1444,11 +1444,10 @@
    24.7 + 	s32 rate;
    24.8 + 	s32 err = 0;
    24.9 + 
   24.10 + 	if (memcmp(mac, wl->profile->bssid, ETHER_ADDR_LEN)) {
   24.11 + 		WL_ERR(("Wrong Mac address, mac = %pM   profile =%pM\n", mac, wl->profile->bssid));
   24.12 +-		return -ENOENT;
   24.13 + 	}
   24.14 + 
   24.15 + 	err = wl_dev_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate));
   24.16 + 	if (err) {
   24.17 + 		WL_DBG(("Could not get rate (%d)\n", err));
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/broadcom-wl/stuff/014-linux414.patch	Fri Jan 19 12:44:23 2024 +0000
    25.3 @@ -0,0 +1,37 @@
    25.4 +From: Gerardo Esteban Malazdrewicz <gerardo@malazdrewicz.com.ar>
    25.5 +Date: Fri, 29 Dec 2017 23:44:24 -0400
    25.6 +Subject: linux414
    25.7 +Origin: https://bugs.debian.org/885885
    25.8 +
    25.9 +linux 4.14 changed the kernel_read function prototype.
   25.10 +---
   25.11 + src/shared/linux_osl.c | 12 +++++++++++-
   25.12 + 1 files changed, 12 insertions(+), 1 deletion(-)
   25.13 +
   25.14 +diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
   25.15 +index 9adc392..b24a973 100644
   25.16 +--- a/src/shared/linux_osl.c
   25.17 ++++ b/src/shared/linux_osl.c
   25.18 +@@ -1076,11 +1076,21 @@ osl_os_get_image_block(char *buf, int len, void *image)
   25.19 + {
   25.20 + 	struct file *fp = (struct file *)image;
   25.21 + 	int rdlen;
   25.22 ++	loff_t pos;
   25.23 + 
   25.24 + 	if (!image)
   25.25 + 		return 0;
   25.26 + 
   25.27 +-	rdlen = kernel_read(fp, fp->f_pos, buf, len);
   25.28 ++	pos = fp->f_pos;
   25.29 ++	rdlen = kernel_read(fp,
   25.30 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
   25.31 ++			pos,
   25.32 ++#endif
   25.33 ++			buf, len
   25.34 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
   25.35 ++			,&pos
   25.36 ++#endif
   25.37 ++	);
   25.38 + 	if (rdlen > 0)
   25.39 + 		fp->f_pos += rdlen;
   25.40 + 
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/broadcom-wl/stuff/015-linux419.patch	Fri Jan 19 12:44:23 2024 +0000
    26.3 @@ -0,0 +1,63 @@
    26.4 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
    26.5 +index 489c9f5..f8278ad 100644
    26.6 +--- a/src/wl/sys/wl_linux.c
    26.7 ++++ b/src/wl/sys/wl_linux.c
    26.8 +@@ -93,7 +93,11 @@
    26.9 + 
   26.10 + #include <wlc_wowl.h>
   26.11 + 
   26.12 ++#ifdef HAVE_TIMER_SETUP
   26.13 ++static void wl_timer(struct timer_list *list);
   26.14 ++#else
   26.15 + static void wl_timer(ulong data);
   26.16 ++#endif
   26.17 + static void _wl_timer(wl_timer_t *t);
   26.18 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
   26.19 + 
   26.20 +@@ -2296,12 +2300,17 @@
   26.21 + 
   26.22 + 	atomic_dec(&t->wl->callbacks);
   26.23 + }
   26.24 +-
   26.25 ++#ifdef HAVE_TIMER_SETUP
   26.26 ++static void
   26.27 ++wl_timer(struct timer_list *list)
   26.28 ++{
   26.29 ++	wl_timer_t *t = from_timer(t,list,timer);
   26.30 ++#else
   26.31 + static void
   26.32 + wl_timer(ulong data)
   26.33 + {
   26.34 + 	wl_timer_t *t = (wl_timer_t *)data;
   26.35 +-
   26.36 ++#endif
   26.37 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
   26.38 + 		_wl_timer(t);
   26.39 + 	else
   26.40 +@@ -2351,10 +2360,13 @@
   26.41 + 	}
   26.42 + 
   26.43 + 	bzero(t, sizeof(wl_timer_t));
   26.44 +-
   26.45 ++#ifdef HAVE_TIMER_SETUP
   26.46 ++	timer_setup(&t->timer, wl_timer,0);
   26.47 ++#else
   26.48 + 	init_timer(&t->timer);
   26.49 + 	t->timer.data = (ulong) t;
   26.50 + 	t->timer.function = wl_timer;
   26.51 ++#endif
   26.52 + 	t->wl = wl;
   26.53 + 	t->fn = fn;
   26.54 + 	t->arg = arg;
   26.55 +diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
   26.56 +index 489c9f5..f8278ad 100644
   26.57 +--- a/src/wl/sys/wl_linux.h
   26.58 ++++ b/src/wl/sys/wl_linux.h
   26.59 +@@ -190,3 +190,7 @@
   26.60 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
   26.61 + 
   26.62 + #endif 
   26.63 ++
   26.64 ++#if defined(timer_setup) && defined(from_timer)
   26.65 ++#define HAVE_TIMER_SETUP
   26.66 ++#endif
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/broadcom-wl/stuff/016-linux51.patch	Fri Jan 19 12:44:23 2024 +0000
    27.3 @@ -0,0 +1,24 @@
    27.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    27.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    27.6 +@@ -43,6 +43,9 @@
    27.7 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
    27.8 + #define EVENT_STATUS(e) dtoh32((e)->status)
    27.9 + 
   27.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   27.11 ++#define get_ds() (KERNEL_DS)
   27.12 ++#endif
   27.13 + #ifdef BCMDBG
   27.14 + u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
   27.15 + #else
   27.16 +--- a/src/wl/sys/wl_iw.c
   27.17 ++++ b/src/wl/sys/wl_iw.c
   27.18 +@@ -61,6 +61,9 @@ typedef struct priv_link {
   27.19 + 	wl_iw_t *wliw;
   27.20 + } priv_link_t;
   27.21 + 
   27.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   27.23 ++#define get_ds() (KERNEL_DS)
   27.24 ++#endif
   27.25 + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
   27.26 + #define WL_DEV_LINK(dev)       (priv_link_t*)(dev->priv)
   27.27 + #else
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/broadcom-wl/stuff/017-get-rid-of-get_fs-set_fs-calls.patch	Fri Jan 19 12:44:23 2024 +0000
    28.3 @@ -0,0 +1,207 @@
    28.4 +From: Joan Bruguera <joanbrugueram@gmail.com>
    28.5 +Date: Sun, 13 Sep 2020 07:33:32 +0200
    28.6 +Subject: Get rid of get_fs/set_fs calls in Broadcom WL driver.
    28.7 +Origin: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
    28.8 +
    28.9 +Fixes linux-next where get_fs/set_fs is already removed for some architectures.
   28.10 +
   28.11 +NB: Some checks in wlc_ioctl_internal are likely superfluous,
   28.12 +    but I'm not familiar enough with the driver to remove them with confidence.
   28.13 +
   28.14 +See also: https://lwn.net/Articles/722267/
   28.15 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/x86/include/asm/uaccess.h?h=next-20200911&id=47058bb54b57962b3958a936ddbc59355e4c5504
   28.16 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/linux/uaccess.h?h=next-20200911&id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
   28.17 +
   28.18 +Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
   28.19 +---
   28.20 + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 29 ++-----------------------
   28.21 + amd64/src/wl/sys/wl_iw.c              | 25 ++--------------------
   28.22 + amd64/src/wl/sys/wl_linux.c           | 40 ++++++++++++++++++++++++++++++-----
   28.23 + amd64/src/wl/sys/wl_linux.h           |  2 ++
   28.24 + amd64/src/wl/sys/wlc_pub.h            |  1 +
   28.25 + 5 files changed, 42 insertions(+), 55 deletions(-)
   28.26 +
   28.27 +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   28.28 +index 8e01841..111ec5a 100644
   28.29 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   28.30 ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   28.31 +@@ -41,6 +41,7 @@
   28.32 + #include <wlioctl.h>
   28.33 + #include <proto/802.11.h>
   28.34 + #include <wl_cfg80211_hybrid.h>
   28.35 ++#include <wl_linux.h>
   28.36 + 
   28.37 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
   28.38 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
   28.39 +@@ -442,30 +443,8 @@
   28.40 + static s32
   28.41 + wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
   28.42 + {
   28.43 +-	struct ifreq ifr;
   28.44 +-	struct wl_ioctl ioc;
   28.45 +-	mm_segment_t fs;
   28.46 +-	s32 err = 0;
   28.47 +-
   28.48 + 	BUG_ON(len < sizeof(int));
   28.49 +-
   28.50 +-	memset(&ioc, 0, sizeof(ioc));
   28.51 +-	ioc.cmd = cmd;
   28.52 +-	ioc.buf = arg;
   28.53 +-	ioc.len = len;
   28.54 +-	strcpy(ifr.ifr_name, dev->name);
   28.55 +-	ifr.ifr_data = (caddr_t)&ioc;
   28.56 +-
   28.57 +-	fs = get_fs();
   28.58 +-	set_fs(get_ds());
   28.59 +-#if defined(WL_USE_NETDEV_OPS)
   28.60 +-	err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   28.61 +-#else
   28.62 +-	err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   28.63 +-#endif
   28.64 +-	set_fs(fs);
   28.65 +-
   28.66 +-	return err;
   28.67 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
   28.68 + }
   28.69 + 
   28.70 + static s32
   28.71 +diff --git a/amd64/src/wl/sys/wl_iw.c b/amd64/src/wl/sys/wl_iw.c
   28.72 +index c4c610b..e346b15 100644
   28.73 +--- a/amd64/src/wl/sys/wl_iw.c
   28.74 ++++ b/amd64/src/wl/sys/wl_iw.c
   28.75 +@@ -37,6 +37,7 @@ typedef const struct si_pub	si_t;
   28.76 + 
   28.77 + #include <wl_dbg.h>
   28.78 + #include <wl_iw.h>
   28.79 ++#include <wl_linux.h>
   28.80 + 
   28.81 + extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
   28.82 + 	uint32 reason, char* stringBuf, uint buflen);
   28.83 +@@ -103,29 +104,7 @@ dev_wlc_ioctl(
   28.84 + 	int len
   28.85 + )
   28.86 + {
   28.87 +-	struct ifreq ifr;
   28.88 +-	wl_ioctl_t ioc;
   28.89 +-	mm_segment_t fs;
   28.90 +-	int ret;
   28.91 +-
   28.92 +-	memset(&ioc, 0, sizeof(ioc));
   28.93 +-	ioc.cmd = cmd;
   28.94 +-	ioc.buf = arg;
   28.95 +-	ioc.len = len;
   28.96 +-
   28.97 +-	strcpy(ifr.ifr_name, dev->name);
   28.98 +-	ifr.ifr_data = (caddr_t) &ioc;
   28.99 +-
  28.100 +-	fs = get_fs();
  28.101 +-	set_fs(get_ds());
  28.102 +-#if defined(WL_USE_NETDEV_OPS)
  28.103 +-	ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  28.104 +-#else
  28.105 +-	ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  28.106 +-#endif
  28.107 +-	set_fs(fs);
  28.108 +-
  28.109 +-	return ret;
  28.110 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
  28.111 + }
  28.112 + 
  28.113 + static int
  28.114 +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c
  28.115 +index 66069d4..cc01d2b 100644
  28.116 +--- a/amd64/src/wl/sys/wl_linux.c
  28.117 ++++ b/amd64/src/wl/sys/wl_linux.c
  28.118 +@@ -1661,10 +1661,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  28.119 + 		goto done2;
  28.120 + 	}
  28.121 + 
  28.122 +-	if (segment_eq(get_fs(), KERNEL_DS))
  28.123 +-		buf = ioc.buf;
  28.124 +-
  28.125 +-	else if (ioc.buf) {
  28.126 ++	if (ioc.buf) {
  28.127 + 		if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
  28.128 + 			bcmerror = BCME_NORESOURCE;
  28.129 + 			goto done2;
  28.130 +@@ -1681,7 +1678,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  28.131 + 	WL_UNLOCK(wl);
  28.132 + 
  28.133 + done1:
  28.134 +-	if (ioc.buf && (ioc.buf != buf)) {
  28.135 ++	if (ioc.buf) {
  28.136 + 		if (copy_to_user(ioc.buf, buf, ioc.len))
  28.137 + 			bcmerror = BCME_BADADDR;
  28.138 + 		MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
  28.139 +@@ -1694,6 +1691,39 @@ done2:
  28.140 + 	return (OSL_ERROR(bcmerror));
  28.141 + }
  28.142 + 
  28.143 ++int
  28.144 ++wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
  28.145 ++{
  28.146 ++	wl_info_t *wl;
  28.147 ++	wl_if_t *wlif;
  28.148 ++	int bcmerror;
  28.149 ++
  28.150 ++	if (!dev)
  28.151 ++		return -ENETDOWN;
  28.152 ++
  28.153 ++	wl = WL_INFO(dev);
  28.154 ++	wlif = WL_DEV_IF(dev);
  28.155 ++	if (wlif == NULL || wl == NULL || wl->dev == NULL)
  28.156 ++		return -ENETDOWN;
  28.157 ++
  28.158 ++	bcmerror = 0;
  28.159 ++
  28.160 ++	WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
  28.161 ++
  28.162 ++	WL_LOCK(wl);
  28.163 ++	if (!capable(CAP_NET_ADMIN)) {
  28.164 ++		bcmerror = BCME_EPERM;
  28.165 ++	} else {
  28.166 ++		bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
  28.167 ++	}
  28.168 ++	WL_UNLOCK(wl);
  28.169 ++
  28.170 ++	ASSERT(VALID_BCMERROR(bcmerror));
  28.171 ++	if (bcmerror != 0)
  28.172 ++		wl->pub->bcmerror = bcmerror;
  28.173 ++	return (OSL_ERROR(bcmerror));
  28.174 ++}
  28.175 ++
  28.176 + static struct net_device_stats*
  28.177 + wl_get_stats(struct net_device *dev)
  28.178 + {
  28.179 +diff --git a/amd64/src/wl/sys/wl_linux.h b/amd64/src/wl/sys/wl_linux.h
  28.180 +index 5b1048e..c8c1f41 100644
  28.181 +--- a/amd64/src/wl/sys/wl_linux.h
  28.182 ++++ b/amd64/src/wl/sys/wl_linux.h
  28.183 +@@ -22,6 +22,7 @@
  28.184 + #define _wl_linux_h_
  28.185 + 
  28.186 + #include <wlc_types.h>
  28.187 ++#include <wlc_pub.h>
  28.188 + 
  28.189 + typedef struct wl_timer {
  28.190 + 	struct timer_list 	timer;
  28.191 +@@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
  28.192 + extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  28.193 + extern void wl_free(wl_info_t *wl);
  28.194 + extern int  wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  28.195 ++extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
  28.196 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
  28.197 + 
  28.198 + #endif 
  28.199 +diff --git a/amd64/src/wl/sys/wlc_pub.h b/amd64/src/wl/sys/wlc_pub.h
  28.200 +index 53a98b8..2b5a029 100644
  28.201 +--- a/amd64/src/wl/sys/wlc_pub.h
  28.202 ++++ b/amd64/src/wl/sys/wlc_pub.h
  28.203 +@@ -24,6 +24,7 @@
  28.204 + 
  28.205 + #include <wlc_types.h>
  28.206 + #include <wlc_utils.h>
  28.207 ++#include <siutils.h>
  28.208 + #include "proto/802.11.h"
  28.209 + #include "proto/bcmevent.h"
  28.210 + 
    29.1 --- a/broadcom-wl64/receipt	Wed Jan 17 12:05:22 2024 +0000
    29.2 +++ b/broadcom-wl64/receipt	Fri Jan 19 12:44:23 2024 +0000
    29.3 @@ -1,52 +1,69 @@
    29.4  # SliTaz package receipt.
    29.5  
    29.6  PACKAGE="broadcom-wl64"
    29.7 -VERSION="5_100_82_112"
    29.8 +VERSION="6_30_223_271"
    29.9  CATEGORY="network"
   29.10 -MAINTAINER="jozee@slitaz.org"
   29.11 +MAINTAINER="maintainer@slitaz.org"
   29.12  LICENSE="other"
   29.13  SHORT_DESC="Broadcom 802.11abg Linux STA Networking Drivers"
   29.14 -WEB_SITE="https://web.archive.org/web/20150506062632/http://www.broadcom.com/support/802.11/linux_sta.php"
   29.15 -TARBALL="hybrid-portsrc_x86_64-v${VERSION}.tar.gz"
   29.16 -WGET_URL="ftp://ftp.fr.freebsd.org/mirrors/rsync.frugalware.org/frugalware-testing/source/network-extra/bcmwl/$TARBALL"
   29.17 +WEB_SITE="https://www.broadcom.com/support/download-search/?pf=Wireless+LAN+Infrastructure"
   29.18 +TARBALL="hybrid-v35_64-nodebug-pcoem-$VERSION.tar.gz"
   29.19 +WGET_URL="https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/$TARBALL"
   29.20  TAGS="wireless wifi driver"
   29.21  PROVIDE="broadcom-wl:linux64"
   29.22  
   29.23  DEPENDS="linux"
   29.24 -BUILD_DEPENDS="linux64-module-headers xz uclibc-cross-compiler-x86_64"
   29.25 -
   29.26 -AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("
   29.27 +BUILD_DEPENDS="linux64-module-headers xz"
   29.28  
   29.29  # Rules to configure and make the package.
   29.30  compile_rules()
   29.31  {
   29.32 -	sed -i 's|ndo_set_multicast_list|ndo_set_rx_mode|' src/wl/sys/wl_linux.c
   29.33 -	sed -i 's|linux/autoconf.h|generated/autoconf.h|' src/include/linuxver.h
   29.34 -	for i in semaphore 3.4.0 3.6.0 3.8.0 3.9.0 3.14.0 ; do
   29.35 -		echo "patch $i ..."
   29.36 -		patch -Np2 -i $stuff/$i.patch
   29.37 -	done
   29.38 -	KBUILD_NOPEDANTIC=1 make -C /usr/src/linux M=`pwd`
   29.39 -	xz wl.ko
   29.40 +    # Use wlan instead eth
   29.41 +    sed -i -e '/BRCM_WLAN_IFNAME/s/eth/wlan/' src/wl/sys/wl_linux.c
   29.42 +
   29.43 +    while read file; do
   29.44 +        [ -f done.$file ] && continue
   29.45 +        echo "Apply $file..."
   29.46 +        patch -p1 < $stuff/$file || return 1
   29.47 +        cp $stuff/$file done.$file
   29.48 +    done <<EOT
   29.49 +001-null-pointer-fix.patch
   29.50 +002-rdtscl.patch
   29.51 +003-linux47.patch
   29.52 +004-linux48.patch
   29.53 +005-debian-fix-kernel-warnings.patch
   29.54 +006-linux411.patch
   29.55 +007-linux412.patch
   29.56 +008-linux415.patch
   29.57 +009-fix_mac_profile_discrepancy.patch
   29.58 +014-linux414.patch
   29.59 +EOT
   29.60 +
   29.61 +    # Use cross toolchain x86_64
   29.62 +    export PATH=$PATH:/cross/x86_64/tools/bin
   29.63 +
   29.64 +    KBUILD_NOPEDANTIC=1 make ARCH=x86_64 CROSS_COMPILE=x86_64-slitaz-linux- \
   29.65 +        -C /usr/src/linux M=`pwd`
   29.66 +    xz wl.ko
   29.67  }
   29.68  
   29.69  # Rules to gen a SliTaz package suitable for Tazpkg.
   29.70  genpkg_rules()
   29.71  {
   29.72 -	EXTRAVERSION=_${kvers}
   29.73 -	mkdir -p $fs/lib/modules/${kvers}-slitaz64/kernel/drivers/net/wireless
   29.74 -	# Compress and install module
   29.75 -	install -o root -m 0644 $src/wl.ko.xz \
   29.76 -		$fs/lib/modules/${kvers}-slitaz64/kernel/drivers/net/wireless/wl.ko.xz
   29.77 +    EXTRAVERSION=_${kvers}
   29.78 +    mkdir -p $fs/lib/modules/${kvers}-slitaz64/kernel/drivers/net/wireless
   29.79 +    # Compress and install module
   29.80 +    install -o root -m 0644 $src/wl.ko.xz \
   29.81 +        $fs/lib/modules/${kvers}-slitaz64/kernel/drivers/net/wireless/wl.ko.xz
   29.82  }
   29.83  
   29.84  # Post install/remove commands for Tazpkg.
   29.85  post_install()
   29.86  {
   29.87 -	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
   29.88 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
   29.89  }
   29.90  
   29.91  post_remove()
   29.92  {
   29.93 -	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
   29.94 +    chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
   29.95  }
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/broadcom-wl64/stuff/001-null-pointer-fix.patch	Fri Jan 19 12:44:23 2024 +0000
    30.3 @@ -0,0 +1,27 @@
    30.4 +Description: Fixing null pointer crash
    30.5 +
    30.6 +Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773713
    30.7 +Bug-Ubuntu: https://launchpad.net/bugs/1415880
    30.8 +Last-Update: 2015-08-18
    30.9 +
   30.10 +---
   30.11 + src/wl/sys/wl_linux.c | 2 +-
   30.12 + 1 file changed, 1 insertion(+), 1 deletion(-)
   30.13 +
   30.14 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
   30.15 +index 860b935..295156f 100644
   30.16 +--- a/src/wl/sys/wl_linux.c
   30.17 ++++ b/src/wl/sys/wl_linux.c
   30.18 +@@ -2157,8 +2157,8 @@ wl_start(struct sk_buff *skb, struct net_device *dev)
   30.19 + 	wlif = WL_DEV_IF(dev);
   30.20 + 	wl = WL_INFO(dev);
   30.21 + 
   30.22 ++	skb->prev = NULL;
   30.23 + 	if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) {
   30.24 +-		skb->prev = NULL;
   30.25 + 
   30.26 + 		TXQ_LOCK(wl);
   30.27 + 
   30.28 +-- 
   30.29 +1.9.1
   30.30 +
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/broadcom-wl64/stuff/002-rdtscl.patch	Fri Jan 19 12:44:23 2024 +0000
    31.3 @@ -0,0 +1,22 @@
    31.4 +Since Linux 4.3, rdtscl() is no longer available and native_read_tsc()
    31.5 +is renamed to rdtsc(). Move the macro contents in-line and call the
    31.6 +new function. References:
    31.7 +
    31.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=fe47ae6e1a5005b2e82f7eab57b5c3820453293a
    31.9 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=4ea1636b04dbd66536fa387bae2eea463efc705b
   31.10 +
   31.11 +diff -ru a/src/shared/linux_osl.c b/src/shared/linux_osl.c
   31.12 +--- a/src/shared/linux_osl.c	2015-09-19 01:47:15.000000000 +0300
   31.13 ++++ b/src/shared/linux_osl.c	2015-11-21 15:20:30.585902518 +0200
   31.14 +@@ -932,7 +932,11 @@
   31.15 + 	uint cycles;
   31.16 + 
   31.17 + #if defined(__i386__)
   31.18 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
   31.19 ++	cycles = (u32)rdtsc();
   31.20 ++#else
   31.21 + 	rdtscl(cycles);
   31.22 ++#endif
   31.23 + #else
   31.24 + 	cycles = 0;
   31.25 + #endif 
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/broadcom-wl64/stuff/003-linux47.patch	Fri Jan 19 12:44:23 2024 +0000
    32.3 @@ -0,0 +1,109 @@
    32.4 +Since Linux 4.7, the enum ieee80211_band is no longer used
    32.5 +
    32.6 +This shall cause no problem's since both enums ieee80211_band
    32.7 +and nl80211_band were added in the same commit:
    32.8 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=13ae75b103e07304a34ab40c9136e9f53e06475c
    32.9 +
   32.10 +This patch refactors the references of IEEE80211_BAND_* to NL80211_BAND_*
   32.11 +
   32.12 +Reference:
   32.13 +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=57fbcce37be7c1d2622b56587c10ade00e96afa3
   32.14 +
   32.15 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:57:36.159340297 -0500
   32.16 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2016-06-13 11:58:18.442323435 -0500
   32.17 +@@ -236,7 +236,7 @@
   32.18 + #endif				
   32.19 + 
   32.20 + #define CHAN2G(_channel, _freq, _flags) {			\
   32.21 +-	.band			= IEEE80211_BAND_2GHZ,		\
   32.22 ++	.band			= NL80211_BAND_2GHZ,		\
   32.23 + 	.center_freq		= (_freq),			\
   32.24 + 	.hw_value		= (_channel),			\
   32.25 + 	.flags			= (_flags),			\
   32.26 +@@ -245,7 +245,7 @@
   32.27 + }
   32.28 + 
   32.29 + #define CHAN5G(_channel, _flags) {				\
   32.30 +-	.band			= IEEE80211_BAND_5GHZ,		\
   32.31 ++	.band			= NL80211_BAND_5GHZ,		\
   32.32 + 	.center_freq		= 5000 + (5 * (_channel)),	\
   32.33 + 	.hw_value		= (_channel),			\
   32.34 + 	.flags			= (_flags),			\
   32.35 +@@ -379,7 +379,7 @@
   32.36 + };
   32.37 + 
   32.38 + static struct ieee80211_supported_band __wl_band_2ghz = {
   32.39 +-	.band = IEEE80211_BAND_2GHZ,
   32.40 ++	.band = NL80211_BAND_2GHZ,
   32.41 + 	.channels = __wl_2ghz_channels,
   32.42 + 	.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
   32.43 + 	.bitrates = wl_g_rates,
   32.44 +@@ -387,7 +387,7 @@
   32.45 + };
   32.46 + 
   32.47 + static struct ieee80211_supported_band __wl_band_5ghz_a = {
   32.48 +-	.band = IEEE80211_BAND_5GHZ,
   32.49 ++	.band = NL80211_BAND_5GHZ,
   32.50 + 	.channels = __wl_5ghz_a_channels,
   32.51 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
   32.52 + 	.bitrates = wl_a_rates,
   32.53 +@@ -395,7 +395,7 @@
   32.54 + };
   32.55 + 
   32.56 + static struct ieee80211_supported_band __wl_band_5ghz_n = {
   32.57 +-	.band = IEEE80211_BAND_5GHZ,
   32.58 ++	.band = NL80211_BAND_5GHZ,
   32.59 + 	.channels = __wl_5ghz_n_channels,
   32.60 + 	.n_channels = ARRAY_SIZE(__wl_5ghz_n_channels),
   32.61 + 	.bitrates = wl_a_rates,
   32.62 +@@ -1876,8 +1876,8 @@
   32.63 + 	wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
   32.64 + #endif
   32.65 + 	wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC);
   32.66 +-	wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
   32.67 +-	wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
   32.68 ++	wdev->wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
   32.69 ++	wdev->wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_a; 
   32.70 + 	wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
   32.71 + 	wdev->wiphy->cipher_suites = __wl_cipher_suites;
   32.72 + 	wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
   32.73 +@@ -2000,7 +2000,7 @@
   32.74 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
   32.75 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
   32.76 + 		(notif_bss_info->channel <= CH_MAX_2G_CHANNEL) ?
   32.77 +-		IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ);
   32.78 ++		NL80211_BAND_2GHZ : NL80211_BAND_5GHZ);
   32.79 + #else
   32.80 + 	freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
   32.81 + #endif
   32.82 +@@ -2116,7 +2116,7 @@
   32.83 + 				return err;
   32.84 + 			}
   32.85 + 			chan = wf_chspec_ctlchan(chanspec);
   32.86 +-			band = (chan <= CH_MAX_2G_CHANNEL) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
   32.87 ++			band = (chan <= CH_MAX_2G_CHANNEL) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
   32.88 + 			freq = ieee80211_channel_to_frequency(chan, band);
   32.89 + 			channel = ieee80211_get_channel(wiphy, freq);
   32.90 + 			cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL);
   32.91 +@@ -2250,10 +2250,10 @@
   32.92 + 		join_params->params.chanspec_list[0] =
   32.93 + 		    ieee80211_frequency_to_channel(chan->center_freq);
   32.94 + 
   32.95 +-		if (chan->band == IEEE80211_BAND_2GHZ) {
   32.96 ++		if (chan->band == NL80211_BAND_2GHZ) {
   32.97 + 			chanspec |= WL_CHANSPEC_BAND_2G;
   32.98 + 		}
   32.99 +-		else if (chan->band == IEEE80211_BAND_5GHZ) {
  32.100 ++		else if (chan->band == NL80211_BAND_5GHZ) {
  32.101 + 			chanspec |= WL_CHANSPEC_BAND_5G;
  32.102 + 		}
  32.103 + 		else {
  32.104 +@@ -2885,7 +2885,7 @@
  32.105 + 
  32.106 + 	if (phy == 'n' || phy == 'a' || phy == 'v') {
  32.107 + 		wiphy = wl_to_wiphy(wl);
  32.108 +-		wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  32.109 ++		wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  32.110 + 	}
  32.111 + 
  32.112 + 	return err;
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/broadcom-wl64/stuff/004-linux48.patch	Fri Jan 19 12:44:23 2024 +0000
    33.3 @@ -0,0 +1,64 @@
    33.4 +From d3f93542326a06d920c6eb89b703384290d37b8b Mon Sep 17 00:00:00 2001
    33.5 +From: Alberto Milone <alberto.milone@canonical.com>
    33.6 +Date: Fri, 2 Sep 2016 17:35:34 +0200
    33.7 +Subject: [PATCH 1/1] Add support for Linux 4.8
    33.8 +
    33.9 +Orginal author: Krzysztof Kolasa
   33.10 +---
   33.11 + src/wl/sys/wl_cfg80211_hybrid.c | 22 ++++++++++++++++++++++
   33.12 + 1 file changed, 22 insertions(+)
   33.13 +
   33.14 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
   33.15 +index 2fc71fe..ec5e472 100644
   33.16 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
   33.17 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
   33.18 +@@ -2388,8 +2388,16 @@ wl_bss_connect_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   33.19 + 	s32 err = 0;
   33.20 + 
   33.21 + 	if (wl->scan_request) {
   33.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   33.23 ++		struct cfg80211_scan_info info = {
   33.24 ++			.aborted = true,
   33.25 ++		};
   33.26 ++		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
   33.27 ++		cfg80211_scan_done(wl->scan_request, &info);
   33.28 ++#else
   33.29 + 		WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
   33.30 + 		cfg80211_scan_done(wl->scan_request, true);     
   33.31 ++#endif
   33.32 + 		wl->scan_request = NULL;
   33.33 + 	}
   33.34 + 
   33.35 +@@ -2490,7 +2498,14 @@ wl_notify_scan_status(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   33.36 + 
   33.37 + scan_done_out:
   33.38 + 	if (wl->scan_request) {
   33.39 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   33.40 ++		struct cfg80211_scan_info info = {
   33.41 ++			.aborted = false,
   33.42 ++		};
   33.43 ++		cfg80211_scan_done(wl->scan_request, &info);
   33.44 ++#else
   33.45 + 		cfg80211_scan_done(wl->scan_request, false);
   33.46 ++#endif
   33.47 + 		wl->scan_request = NULL;
   33.48 + 	}
   33.49 + 	rtnl_unlock();
   33.50 +@@ -2909,7 +2924,14 @@ s32 wl_cfg80211_down(struct net_device *ndev)
   33.51 + 	s32 err = 0;
   33.52 + 
   33.53 + 	if (wl->scan_request) {
   33.54 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
   33.55 ++		struct cfg80211_scan_info info = {
   33.56 ++			.aborted = true,
   33.57 ++		};
   33.58 ++		cfg80211_scan_done(wl->scan_request, &info);
   33.59 ++#else
   33.60 + 		cfg80211_scan_done(wl->scan_request, true);	
   33.61 ++#endif
   33.62 + 		wl->scan_request = NULL;
   33.63 + 	}
   33.64 + 
   33.65 +-- 
   33.66 +2.7.4
   33.67 +
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/broadcom-wl64/stuff/005-debian-fix-kernel-warnings.patch	Fri Jan 19 12:44:23 2024 +0000
    34.3 @@ -0,0 +1,161 @@
    34.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    34.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    34.6 +@@ -1968,7 +1968,7 @@
    34.7 + 
    34.8 + 	if (dtoh32(bi->length) > WL_BSS_INFO_MAX) {
    34.9 + 		WL_DBG(("Beacon is larger than buffer. Discarding\n"));
   34.10 +-		return err;
   34.11 ++		return -E2BIG;
   34.12 + 	}
   34.13 + 	notif_bss_info = kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
   34.14 + 	                         WL_BSS_INFO_MAX, GFP_KERNEL);
   34.15 +@@ -1992,9 +1992,15 @@
   34.16 + 	beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
   34.17 + 	wl_rst_ie(wl);
   34.18 + 
   34.19 +-	wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
   34.20 +-	wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
   34.21 ++	err = wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
   34.22 ++	if (err)
   34.23 ++		goto inform_single_bss_out;
   34.24 ++
   34.25 ++	err = wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
   34.26 + 	         offsetof(struct wl_cfg80211_bss_info, frame_buf));
   34.27 ++	if (err)
   34.28 ++		goto inform_single_bss_out;
   34.29 ++
   34.30 + 	notif_bss_info->frame_len = offsetof(struct ieee80211_mgmt, u.beacon.variable) +
   34.31 + 	                            wl_get_ielen(wl);
   34.32 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
   34.33 +@@ -2006,14 +2012,14 @@
   34.34 + #endif
   34.35 + 	if (freq == 0) {
   34.36 + 		WL_ERR(("Invalid channel, fail to chcnage channel to freq\n"));
   34.37 +-		kfree(notif_bss_info);
   34.38 +-		return -EINVAL;
   34.39 ++		err = -EINVAL;
   34.40 ++		goto inform_single_bss_out;
   34.41 + 	}
   34.42 + 	channel = ieee80211_get_channel(wiphy, freq);
   34.43 + 	if (unlikely(!channel)) {
   34.44 + 		WL_ERR(("ieee80211_get_channel error\n"));
   34.45 +-		kfree(notif_bss_info);
   34.46 +-		return -EINVAL;
   34.47 ++		err = -EINVAL;
   34.48 ++		goto inform_single_bss_out;
   34.49 + 	}
   34.50 + 
   34.51 + 	WL_DBG(("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
   34.52 +@@ -2021,28 +2027,37 @@
   34.53 + 		mgmt->u.beacon.capab_info, &bi->BSSID));
   34.54 + 
   34.55 + 	signal = notif_bss_info->rssi * 100;
   34.56 +-	cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
   34.57 +-	    le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
   34.58 +-	if (unlikely(!cbss)) {
   34.59 +-		WL_ERR(("cfg80211_inform_bss_frame error\n"));
   34.60 +-		kfree(notif_bss_info);
   34.61 +-		return -EINVAL;
   34.62 +-	}
   34.63 + 
   34.64 +-	notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
   34.65 +-	notify_ielen = le32_to_cpu(bi->ie_length);
   34.66 ++	if (!wl->scan_request) {
   34.67 ++		cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
   34.68 ++			le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
   34.69 ++		if (unlikely(!cbss)) {
   34.70 ++			WL_ERR(("cfg80211_inform_bss_frame error\n"));
   34.71 ++			err = -ENOMEM;
   34.72 ++			goto inform_single_bss_out;
   34.73 ++		}
   34.74 ++	} else {
   34.75 ++		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
   34.76 ++		notify_ielen = le32_to_cpu(bi->ie_length);
   34.77 + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
   34.78 +-	cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
   34.79 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   34.80 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   34.81 ++		cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
   34.82 ++			0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   34.83 ++			(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   34.84 + #else
   34.85 +-	cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, (const u8 *)(bi->BSSID.octet),
   34.86 +-		0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
   34.87 +-		(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   34.88 ++		cbss = cfg80211_inform_bss(wiphy, channel,
   34.89 ++				wl->active_scan ?
   34.90 ++				CFG80211_BSS_FTYPE_PRESP : CFG80211_BSS_FTYPE_BEACON,
   34.91 ++				(const u8 *)(bi->BSSID.octet), 0,
   34.92 ++				beacon_proberesp->capab_info,
   34.93 ++				beacon_proberesp->beacon_int,
   34.94 ++				(const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
   34.95 + #endif
   34.96 +-
   34.97 +-	if (unlikely(!cbss))
   34.98 +-		return -ENOMEM;
   34.99 ++		if (unlikely(!cbss)) {
  34.100 ++			WL_ERR(("cfg80211_inform_bss error\n"));
  34.101 ++			err = -ENOMEM;
  34.102 ++			goto inform_single_bss_out;
  34.103 ++		}
  34.104 ++	}
  34.105 + 
  34.106 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
  34.107 + 	cfg80211_put_bss(wiphy, cbss);
  34.108 +@@ -2050,6 +2065,7 @@
  34.109 + 	cfg80211_put_bss(cbss);
  34.110 + #endif
  34.111 + 
  34.112 ++inform_single_bss_out:
  34.113 + 	kfree(notif_bss_info);
  34.114 + 
  34.115 + 	return err;
  34.116 +@@ -2316,6 +2332,9 @@
  34.117 + 		if (err)
  34.118 + 			goto update_bss_info_out;
  34.119 + 
  34.120 ++		bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
  34.121 ++		      ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  34.122 ++
  34.123 + 		ie = ((u8 *)bi) + bi->ie_offset;
  34.124 + 		ie_len = bi->ie_length;
  34.125 + 	} else {
  34.126 +@@ -2328,11 +2347,18 @@
  34.127 + 		ie_len = bss->len_information_elements;
  34.128 + #endif
  34.129 + 		wl->conf->channel = *bss->channel;
  34.130 ++	}
  34.131 ++
  34.132 ++	if (bss) {
  34.133 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
  34.134 + 		cfg80211_put_bss(wiphy, bss);
  34.135 + #else
  34.136 + 		cfg80211_put_bss(bss);
  34.137 + #endif
  34.138 ++	} else {
  34.139 ++		WL_DBG(("Could not update BSS\n"));
  34.140 ++		err = -EINVAL;
  34.141 ++		goto update_bss_info_out;
  34.142 + 	}
  34.143 + 
  34.144 + 	tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
  34.145 +@@ -2360,10 +2386,17 @@
  34.146 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
  34.147 + 	s32 err = 0;
  34.148 + 
  34.149 +-	wl_get_assoc_ies(wl);
  34.150 ++	err = wl_get_assoc_ies(wl);
  34.151 ++	if (err)
  34.152 ++		return err;
  34.153 ++
  34.154 + 	memcpy(wl->profile->bssid, &e->addr, ETHER_ADDR_LEN);
  34.155 + 	memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
  34.156 +-	wl_update_bss_info(wl);
  34.157 ++
  34.158 ++	err = wl_update_bss_info(wl);
  34.159 ++	if (err)
  34.160 ++		return err;
  34.161 ++
  34.162 + 	cfg80211_roamed(ndev,
  34.163 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
  34.164 + 			&wl->conf->channel,	 
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/broadcom-wl64/stuff/006-linux411.patch	Fri Jan 19 12:44:23 2024 +0000
    35.3 @@ -0,0 +1,27 @@
    35.4 +diff -u sys0/wl_cfg80211_hybrid.c sys/wl_cfg80211_hybrid.c
    35.5 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    35.6 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    35.7 +@@ -39,6 +39,10 @@
    35.8 + #include <proto/802.11.h>
    35.9 + #include <wl_cfg80211_hybrid.h>
   35.10 + 
   35.11 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
   35.12 ++#include <linux/sched/signal.h>
   35.13 ++#endif
   35.14 ++
   35.15 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
   35.16 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
   35.17 + #define EVENT_STATUS(e) dtoh32((e)->status)
   35.18 +diff -u sys0/wl_linux.c sys/wl_linux.c
   35.19 +--- a/src/wl/sys/wl_linux.c
   35.20 ++++ b/src/wl/sys/wl_linux.c
   35.21 +@@ -2915,7 +2915,9 @@
   35.22 + 	if (skb == NULL) return;
   35.23 + 
   35.24 + 	skb->dev = wl->monitor_dev;
   35.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
   35.26 + 	skb->dev->last_rx = jiffies;
   35.27 ++#endif
   35.28 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
   35.29 + 	skb_reset_mac_header(skb);
   35.30 + #else
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/broadcom-wl64/stuff/007-linux412.patch	Fri Jan 19 12:44:23 2024 +0000
    36.3 @@ -0,0 +1,78 @@
    36.4 +From 0b888bf115612074df99654140a1980111c29748 Mon Sep 17 00:00:00 2001
    36.5 +From: Antoine Cotten <tonio.cotten@gmail.com>
    36.6 +Date: Fri, 7 Jul 2017 15:17:47 +0200
    36.7 +Subject: [PATCH] Apply patch from Debian bug #867258
    36.8 +
    36.9 +Compile fix with kernel 4.12
   36.10 +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=867258
   36.11 +---
   36.12 + src/wl/sys/wl_cfg80211_hybrid.c | 29 +++++++++++++++++++++++++----
   36.13 + 1 file changed, 25 insertions(+), 4 deletions(-)
   36.14 +
   36.15 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
   36.16 +index c46944a..1a9840a 100644
   36.17 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
   36.18 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
   36.19 +@@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
   36.20 + #endif
   36.21 + 
   36.22 + static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
   36.23 +-           enum nl80211_iftype type, u32 *flags, struct vif_params *params);
   36.24 ++           enum nl80211_iftype type,
   36.25 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
   36.26 ++           u32 *flags,
   36.27 ++#endif
   36.28 ++	   struct vif_params *params);
   36.29 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
   36.30 + static s32
   36.31 + wl_cfg80211_scan(struct wiphy *wiphy,
   36.32 +@@ -466,8 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
   36.33 + 
   36.34 + static s32
   36.35 + wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
   36.36 +-                         enum nl80211_iftype type, u32 *flags,
   36.37 +-   struct vif_params *params)
   36.38 ++                         enum nl80211_iftype type,
   36.39 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
   36.40 ++                         u32 *flags,
   36.41 ++#endif
   36.42 ++                         struct vif_params *params)
   36.43 + {
   36.44 + 	struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
   36.45 + 	struct wireless_dev *wdev;
   36.46 +@@ -2387,6 +2394,15 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   36.47 +                     const wl_event_msg_t *e, void *data)
   36.48 + {
   36.49 + 	struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
   36.50 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
   36.51 ++	struct cfg80211_roam_info roam_info = {
   36.52 ++		.bssid = wl->profile->bssid,
   36.53 ++		.req_ie = conn_info->req_ie,
   36.54 ++		.req_ie_len = conn_info->req_ie_len,
   36.55 ++		.resp_ie = conn_info->resp_ie,
   36.56 ++		.resp_ie_len = conn_info->resp_ie_len,
   36.57 ++	};
   36.58 ++#endif
   36.59 + 	s32 err = 0;
   36.60 + 
   36.61 + 	err = wl_get_assoc_ies(wl);
   36.62 +@@ -2401,12 +2417,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
   36.63 + 		return err;
   36.64 + 
   36.65 + 	cfg80211_roamed(ndev,
   36.66 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
   36.67 ++			&roam_info,
   36.68 ++#else
   36.69 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
   36.70 + 			&wl->conf->channel,	 
   36.71 + #endif
   36.72 + 			(u8 *)&wl->bssid,
   36.73 + 			conn_info->req_ie, conn_info->req_ie_len,
   36.74 +-			conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
   36.75 ++			conn_info->resp_ie, conn_info->resp_ie_len,
   36.76 ++#endif
   36.77 ++			GFP_KERNEL);
   36.78 + 	WL_DBG(("Report roaming result\n"));
   36.79 + 
   36.80 + 	set_bit(WL_STATUS_CONNECTED, &wl->status);
   36.81 +
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/broadcom-wl64/stuff/008-linux415.patch	Fri Jan 19 12:44:23 2024 +0000
    37.3 @@ -0,0 +1,46 @@
    37.4 +--- a/src/wl/sys/wl_linux.c	2017-07-17 00:11:24.000000000 +0100
    37.5 ++++ b/src/wl/sys/wl_linux.c	2018-01-27 09:49:47.057799596 +0000
    37.6 +@@ -93,7 +93,11 @@
    37.7 + 
    37.8 + #include <wlc_wowl.h>
    37.9 + 
   37.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   37.11 ++static void wl_timer(struct timer_list *tl);
   37.12 ++#else
   37.13 + static void wl_timer(ulong data);
   37.14 ++#endif
   37.15 + static void _wl_timer(wl_timer_t *t);
   37.16 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
   37.17 + 
   37.18 +@@ -2297,10 +2301,17 @@
   37.19 + 	atomic_dec(&t->wl->callbacks);
   37.20 + }
   37.21 + 
   37.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   37.23 ++static void
   37.24 ++wl_timer(struct timer_list *tl)
   37.25 ++{
   37.26 ++	wl_timer_t *t = (wl_timer_t *)tl;
   37.27 ++#else
   37.28 + static void
   37.29 + wl_timer(ulong data)
   37.30 + {
   37.31 + 	wl_timer_t *t = (wl_timer_t *)data;
   37.32 ++#endif
   37.33 + 
   37.34 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
   37.35 + 		_wl_timer(t);
   37.36 +@@ -2352,9 +2363,13 @@
   37.37 + 
   37.38 + 	bzero(t, sizeof(wl_timer_t));
   37.39 + 
   37.40 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   37.41 ++	timer_setup(&t->timer, wl_timer, 0);
   37.42 ++#else
   37.43 + 	init_timer(&t->timer);
   37.44 + 	t->timer.data = (ulong) t;
   37.45 + 	t->timer.function = wl_timer;
   37.46 ++#endif
   37.47 + 	t->wl = wl;
   37.48 + 	t->fn = fn;
   37.49 + 	t->arg = arg;
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/broadcom-wl64/stuff/009-fix_mac_profile_discrepancy.patch	Fri Jan 19 12:44:23 2024 +0000
    38.3 @@ -0,0 +1,14 @@
    38.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c	2015-09-19 00:47:30.000000000 +0200
    38.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c	2018-11-14 14:06:03.313487995 +0100
    38.6 +@@ -1444,11 +1444,10 @@
    38.7 + 	s32 rate;
    38.8 + 	s32 err = 0;
    38.9 + 
   38.10 + 	if (memcmp(mac, wl->profile->bssid, ETHER_ADDR_LEN)) {
   38.11 + 		WL_ERR(("Wrong Mac address, mac = %pM   profile =%pM\n", mac, wl->profile->bssid));
   38.12 +-		return -ENOENT;
   38.13 + 	}
   38.14 + 
   38.15 + 	err = wl_dev_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate));
   38.16 + 	if (err) {
   38.17 + 		WL_DBG(("Could not get rate (%d)\n", err));
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/broadcom-wl64/stuff/014-linux414.patch	Fri Jan 19 12:44:23 2024 +0000
    39.3 @@ -0,0 +1,37 @@
    39.4 +From: Gerardo Esteban Malazdrewicz <gerardo@malazdrewicz.com.ar>
    39.5 +Date: Fri, 29 Dec 2017 23:44:24 -0400
    39.6 +Subject: linux414
    39.7 +Origin: https://bugs.debian.org/885885
    39.8 +
    39.9 +linux 4.14 changed the kernel_read function prototype.
   39.10 +---
   39.11 + src/shared/linux_osl.c | 12 +++++++++++-
   39.12 + 1 files changed, 12 insertions(+), 1 deletion(-)
   39.13 +
   39.14 +diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
   39.15 +index 9adc392..b24a973 100644
   39.16 +--- a/src/shared/linux_osl.c
   39.17 ++++ b/src/shared/linux_osl.c
   39.18 +@@ -1076,11 +1076,21 @@ osl_os_get_image_block(char *buf, int len, void *image)
   39.19 + {
   39.20 + 	struct file *fp = (struct file *)image;
   39.21 + 	int rdlen;
   39.22 ++	loff_t pos;
   39.23 + 
   39.24 + 	if (!image)
   39.25 + 		return 0;
   39.26 + 
   39.27 +-	rdlen = kernel_read(fp, fp->f_pos, buf, len);
   39.28 ++	pos = fp->f_pos;
   39.29 ++	rdlen = kernel_read(fp,
   39.30 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
   39.31 ++			pos,
   39.32 ++#endif
   39.33 ++			buf, len
   39.34 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
   39.35 ++			,&pos
   39.36 ++#endif
   39.37 ++	);
   39.38 + 	if (rdlen > 0)
   39.39 + 		fp->f_pos += rdlen;
   39.40 + 
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/broadcom-wl64/stuff/015-linux419.patch	Fri Jan 19 12:44:23 2024 +0000
    40.3 @@ -0,0 +1,63 @@
    40.4 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
    40.5 +index 489c9f5..f8278ad 100644
    40.6 +--- a/src/wl/sys/wl_linux.c
    40.7 ++++ b/src/wl/sys/wl_linux.c
    40.8 +@@ -93,7 +93,11 @@
    40.9 + 
   40.10 + #include <wlc_wowl.h>
   40.11 + 
   40.12 ++#ifdef HAVE_TIMER_SETUP
   40.13 ++static void wl_timer(struct timer_list *list);
   40.14 ++#else
   40.15 + static void wl_timer(ulong data);
   40.16 ++#endif
   40.17 + static void _wl_timer(wl_timer_t *t);
   40.18 + static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
   40.19 + 
   40.20 +@@ -2296,12 +2300,17 @@
   40.21 + 
   40.22 + 	atomic_dec(&t->wl->callbacks);
   40.23 + }
   40.24 +-
   40.25 ++#ifdef HAVE_TIMER_SETUP
   40.26 ++static void
   40.27 ++wl_timer(struct timer_list *list)
   40.28 ++{
   40.29 ++	wl_timer_t *t = from_timer(t,list,timer);
   40.30 ++#else
   40.31 + static void
   40.32 + wl_timer(ulong data)
   40.33 + {
   40.34 + 	wl_timer_t *t = (wl_timer_t *)data;
   40.35 +-
   40.36 ++#endif
   40.37 + 	if (!WL_ALL_PASSIVE_ENAB(t->wl))
   40.38 + 		_wl_timer(t);
   40.39 + 	else
   40.40 +@@ -2351,10 +2360,13 @@
   40.41 + 	}
   40.42 + 
   40.43 + 	bzero(t, sizeof(wl_timer_t));
   40.44 +-
   40.45 ++#ifdef HAVE_TIMER_SETUP
   40.46 ++	timer_setup(&t->timer, wl_timer,0);
   40.47 ++#else
   40.48 + 	init_timer(&t->timer);
   40.49 + 	t->timer.data = (ulong) t;
   40.50 + 	t->timer.function = wl_timer;
   40.51 ++#endif
   40.52 + 	t->wl = wl;
   40.53 + 	t->fn = fn;
   40.54 + 	t->arg = arg;
   40.55 +diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
   40.56 +index 489c9f5..f8278ad 100644
   40.57 +--- a/src/wl/sys/wl_linux.h
   40.58 ++++ b/src/wl/sys/wl_linux.h
   40.59 +@@ -190,3 +190,7 @@
   40.60 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
   40.61 + 
   40.62 + #endif 
   40.63 ++
   40.64 ++#if defined(timer_setup) && defined(from_timer)
   40.65 ++#define HAVE_TIMER_SETUP
   40.66 ++#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/broadcom-wl64/stuff/016-linux51.patch	Fri Jan 19 12:44:23 2024 +0000
    41.3 @@ -0,0 +1,24 @@
    41.4 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    41.5 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    41.6 +@@ -43,6 +43,9 @@
    41.7 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
    41.8 + #define EVENT_STATUS(e) dtoh32((e)->status)
    41.9 + 
   41.10 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   41.11 ++#define get_ds() (KERNEL_DS)
   41.12 ++#endif
   41.13 + #ifdef BCMDBG
   41.14 + u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
   41.15 + #else
   41.16 +--- a/src/wl/sys/wl_iw.c
   41.17 ++++ b/src/wl/sys/wl_iw.c
   41.18 +@@ -61,6 +61,9 @@ typedef struct priv_link {
   41.19 + 	wl_iw_t *wliw;
   41.20 + } priv_link_t;
   41.21 + 
   41.22 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
   41.23 ++#define get_ds() (KERNEL_DS)
   41.24 ++#endif
   41.25 + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
   41.26 + #define WL_DEV_LINK(dev)       (priv_link_t*)(dev->priv)
   41.27 + #else
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/broadcom-wl64/stuff/017-get-rid-of-get_fs-set_fs-calls.patch	Fri Jan 19 12:44:23 2024 +0000
    42.3 @@ -0,0 +1,207 @@
    42.4 +From: Joan Bruguera <joanbrugueram@gmail.com>
    42.5 +Date: Sun, 13 Sep 2020 07:33:32 +0200
    42.6 +Subject: Get rid of get_fs/set_fs calls in Broadcom WL driver.
    42.7 +Origin: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
    42.8 +
    42.9 +Fixes linux-next where get_fs/set_fs is already removed for some architectures.
   42.10 +
   42.11 +NB: Some checks in wlc_ioctl_internal are likely superfluous,
   42.12 +    but I'm not familiar enough with the driver to remove them with confidence.
   42.13 +
   42.14 +See also: https://lwn.net/Articles/722267/
   42.15 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/x86/include/asm/uaccess.h?h=next-20200911&id=47058bb54b57962b3958a936ddbc59355e4c5504
   42.16 +          https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/linux/uaccess.h?h=next-20200911&id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
   42.17 +
   42.18 +Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
   42.19 +---
   42.20 + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 29 ++-----------------------
   42.21 + amd64/src/wl/sys/wl_iw.c              | 25 ++--------------------
   42.22 + amd64/src/wl/sys/wl_linux.c           | 40 ++++++++++++++++++++++++++++++-----
   42.23 + amd64/src/wl/sys/wl_linux.h           |  2 ++
   42.24 + amd64/src/wl/sys/wlc_pub.h            |  1 +
   42.25 + 5 files changed, 42 insertions(+), 55 deletions(-)
   42.26 +
   42.27 +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   42.28 +index 8e01841..111ec5a 100644
   42.29 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   42.30 ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
   42.31 +@@ -41,6 +41,7 @@
   42.32 + #include <wlioctl.h>
   42.33 + #include <proto/802.11.h>
   42.34 + #include <wl_cfg80211_hybrid.h>
   42.35 ++#include <wl_linux.h>
   42.36 + 
   42.37 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
   42.38 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
   42.39 +@@ -442,30 +443,8 @@
   42.40 + static s32
   42.41 + wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
   42.42 + {
   42.43 +-	struct ifreq ifr;
   42.44 +-	struct wl_ioctl ioc;
   42.45 +-	mm_segment_t fs;
   42.46 +-	s32 err = 0;
   42.47 +-
   42.48 + 	BUG_ON(len < sizeof(int));
   42.49 +-
   42.50 +-	memset(&ioc, 0, sizeof(ioc));
   42.51 +-	ioc.cmd = cmd;
   42.52 +-	ioc.buf = arg;
   42.53 +-	ioc.len = len;
   42.54 +-	strcpy(ifr.ifr_name, dev->name);
   42.55 +-	ifr.ifr_data = (caddr_t)&ioc;
   42.56 +-
   42.57 +-	fs = get_fs();
   42.58 +-	set_fs(get_ds());
   42.59 +-#if defined(WL_USE_NETDEV_OPS)
   42.60 +-	err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   42.61 +-#else
   42.62 +-	err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   42.63 +-#endif
   42.64 +-	set_fs(fs);
   42.65 +-
   42.66 +-	return err;
   42.67 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
   42.68 + }
   42.69 + 
   42.70 + static s32
   42.71 +diff --git a/amd64/src/wl/sys/wl_iw.c b/amd64/src/wl/sys/wl_iw.c
   42.72 +index c4c610b..e346b15 100644
   42.73 +--- a/amd64/src/wl/sys/wl_iw.c
   42.74 ++++ b/amd64/src/wl/sys/wl_iw.c
   42.75 +@@ -37,6 +37,7 @@ typedef const struct si_pub	si_t;
   42.76 + 
   42.77 + #include <wl_dbg.h>
   42.78 + #include <wl_iw.h>
   42.79 ++#include <wl_linux.h>
   42.80 + 
   42.81 + extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
   42.82 + 	uint32 reason, char* stringBuf, uint buflen);
   42.83 +@@ -103,29 +104,7 @@ dev_wlc_ioctl(
   42.84 + 	int len
   42.85 + )
   42.86 + {
   42.87 +-	struct ifreq ifr;
   42.88 +-	wl_ioctl_t ioc;
   42.89 +-	mm_segment_t fs;
   42.90 +-	int ret;
   42.91 +-
   42.92 +-	memset(&ioc, 0, sizeof(ioc));
   42.93 +-	ioc.cmd = cmd;
   42.94 +-	ioc.buf = arg;
   42.95 +-	ioc.len = len;
   42.96 +-
   42.97 +-	strcpy(ifr.ifr_name, dev->name);
   42.98 +-	ifr.ifr_data = (caddr_t) &ioc;
   42.99 +-
  42.100 +-	fs = get_fs();
  42.101 +-	set_fs(get_ds());
  42.102 +-#if defined(WL_USE_NETDEV_OPS)
  42.103 +-	ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  42.104 +-#else
  42.105 +-	ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  42.106 +-#endif
  42.107 +-	set_fs(fs);
  42.108 +-
  42.109 +-	return ret;
  42.110 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
  42.111 + }
  42.112 + 
  42.113 + static int
  42.114 +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c
  42.115 +index 66069d4..cc01d2b 100644
  42.116 +--- a/amd64/src/wl/sys/wl_linux.c
  42.117 ++++ b/amd64/src/wl/sys/wl_linux.c
  42.118 +@@ -1661,10 +1661,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  42.119 + 		goto done2;
  42.120 + 	}
  42.121 + 
  42.122 +-	if (segment_eq(get_fs(), KERNEL_DS))
  42.123 +-		buf = ioc.buf;
  42.124 +-
  42.125 +-	else if (ioc.buf) {
  42.126 ++	if (ioc.buf) {
  42.127 + 		if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
  42.128 + 			bcmerror = BCME_NORESOURCE;
  42.129 + 			goto done2;
  42.130 +@@ -1681,7 +1678,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  42.131 + 	WL_UNLOCK(wl);
  42.132 + 
  42.133 + done1:
  42.134 +-	if (ioc.buf && (ioc.buf != buf)) {
  42.135 ++	if (ioc.buf) {
  42.136 + 		if (copy_to_user(ioc.buf, buf, ioc.len))
  42.137 + 			bcmerror = BCME_BADADDR;
  42.138 + 		MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
  42.139 +@@ -1694,6 +1691,39 @@ done2:
  42.140 + 	return (OSL_ERROR(bcmerror));
  42.141 + }
  42.142 + 
  42.143 ++int
  42.144 ++wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
  42.145 ++{
  42.146 ++	wl_info_t *wl;
  42.147 ++	wl_if_t *wlif;
  42.148 ++	int bcmerror;
  42.149 ++
  42.150 ++	if (!dev)
  42.151 ++		return -ENETDOWN;
  42.152 ++
  42.153 ++	wl = WL_INFO(dev);
  42.154 ++	wlif = WL_DEV_IF(dev);
  42.155 ++	if (wlif == NULL || wl == NULL || wl->dev == NULL)
  42.156 ++		return -ENETDOWN;
  42.157 ++
  42.158 ++	bcmerror = 0;
  42.159 ++
  42.160 ++	WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
  42.161 ++
  42.162 ++	WL_LOCK(wl);
  42.163 ++	if (!capable(CAP_NET_ADMIN)) {
  42.164 ++		bcmerror = BCME_EPERM;
  42.165 ++	} else {
  42.166 ++		bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
  42.167 ++	}
  42.168 ++	WL_UNLOCK(wl);
  42.169 ++
  42.170 ++	ASSERT(VALID_BCMERROR(bcmerror));
  42.171 ++	if (bcmerror != 0)
  42.172 ++		wl->pub->bcmerror = bcmerror;
  42.173 ++	return (OSL_ERROR(bcmerror));
  42.174 ++}
  42.175 ++
  42.176 + static struct net_device_stats*
  42.177 + wl_get_stats(struct net_device *dev)
  42.178 + {
  42.179 +diff --git a/amd64/src/wl/sys/wl_linux.h b/amd64/src/wl/sys/wl_linux.h
  42.180 +index 5b1048e..c8c1f41 100644
  42.181 +--- a/amd64/src/wl/sys/wl_linux.h
  42.182 ++++ b/amd64/src/wl/sys/wl_linux.h
  42.183 +@@ -22,6 +22,7 @@
  42.184 + #define _wl_linux_h_
  42.185 + 
  42.186 + #include <wlc_types.h>
  42.187 ++#include <wlc_pub.h>
  42.188 + 
  42.189 + typedef struct wl_timer {
  42.190 + 	struct timer_list 	timer;
  42.191 +@@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
  42.192 + extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  42.193 + extern void wl_free(wl_info_t *wl);
  42.194 + extern int  wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  42.195 ++extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
  42.196 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
  42.197 + 
  42.198 + #endif 
  42.199 +diff --git a/amd64/src/wl/sys/wlc_pub.h b/amd64/src/wl/sys/wlc_pub.h
  42.200 +index 53a98b8..2b5a029 100644
  42.201 +--- a/amd64/src/wl/sys/wlc_pub.h
  42.202 ++++ b/amd64/src/wl/sys/wlc_pub.h
  42.203 +@@ -24,6 +24,7 @@
  42.204 + 
  42.205 + #include <wlc_types.h>
  42.206 + #include <wlc_utils.h>
  42.207 ++#include <siutils.h>
  42.208 + #include "proto/802.11.h"
  42.209 + #include "proto/bcmevent.h"
  42.210 +