broadcom_sta: fix build on 5.6

+89
+2
pkgs/os-specific/linux/broadcom-sta/default.nix
··· 35 35 ./linux-4.12.patch 36 36 ./linux-4.15.patch 37 37 ./linux-5.1.patch 38 + # source: https://salsa.debian.org/Herrie82-guest/broadcom-sta/-/commit/247307926e5540ad574a17c062c8da76990d056f 39 + ./linux-5.6.patch 38 40 ./null-pointer-fix.patch 39 41 ./gcc.patch 40 42 ];
+87
pkgs/os-specific/linux/broadcom-sta/linux-5.6.patch
··· 1 + From dd057e40a167f4febb1a7c77dd32b7d36056952c Mon Sep 17 00:00:00 2001 2 + From: Herman van Hazendonk <github.com@herrie.org> 3 + Date: Tue, 31 Mar 2020 17:09:55 +0200 4 + Subject: [PATCH] Add fixes for 5.6 kernel 5 + 6 + Use ioremap instead of ioremap_nocache and proc_ops instead of file_operations on Linux kernel 5.6 and above. 7 + 8 + Signed-off-by: Herman van Hazendonk <github.com@herrie.org> 9 + --- 10 + src/shared/linux_osl.c | 6 +++++- 11 + src/wl/sys/wl_linux.c | 21 ++++++++++++++++++++- 12 + 2 files changed, 25 insertions(+), 2 deletions(-) 13 + 14 + diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c 15 + index 6157d18..dcfc075 100644 16 + --- a/src/shared/linux_osl.c 17 + +++ b/src/shared/linux_osl.c 18 + @@ -942,7 +942,11 @@ osl_getcycles(void) 19 + void * 20 + osl_reg_map(uint32 pa, uint size) 21 + { 22 + - return (ioremap_nocache((unsigned long)pa, (unsigned long)size)); 23 + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) 24 + + return (ioremap((unsigned long)pa, (unsigned long)size)); 25 + + #else 26 + + return (ioremap_nocache((unsigned long)pa, (unsigned long)size)); 27 + + #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ 28 + } 29 + 30 + void 31 + diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c 32 + index 0d05100..6d9dd0d 100644 33 + --- a/src/wl/sys/wl_linux.c 34 + +++ b/src/wl/sys/wl_linux.c 35 + @@ -582,10 +582,17 @@ wl_attach(uint16 vendor, uint16 device, ulong regs, 36 + } 37 + wl->bcm_bustype = bustype; 38 + 39 + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) 40 + + if ((wl->regsva = ioremap(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) { 41 + + WL_ERROR(("wl%d: ioremap() failed\n", unit)); 42 + + goto fail; 43 + + } 44 + + #else 45 + if ((wl->regsva = ioremap_nocache(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) { 46 + WL_ERROR(("wl%d: ioremap() failed\n", unit)); 47 + goto fail; 48 + } 49 + + #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ 50 + 51 + wl->bar1_addr = bar1_addr; 52 + wl->bar1_size = bar1_size; 53 + @@ -772,8 +779,13 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 54 + if ((val & 0x0000ff00) != 0) 55 + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); 56 + bar1_size = pci_resource_len(pdev, 2); 57 + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) 58 + + bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2), 59 + + bar1_size); 60 + + #else 61 + bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2), 62 + bar1_size); 63 + + #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ 64 + wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), PCI_BUS, pdev, 65 + pdev->irq, bar1_addr, bar1_size); 66 + 67 + @@ -3335,12 +3347,19 @@ wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t 68 + } 69 + 70 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) 71 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) 72 + +static const struct proc_ops wl_fops = { 73 + + .proc_read = wl_proc_read, 74 + + .proc_write = wl_proc_write, 75 + +}; 76 + +#else 77 + static const struct file_operations wl_fops = { 78 + .owner = THIS_MODULE, 79 + .read = wl_proc_read, 80 + .write = wl_proc_write, 81 + }; 82 + -#endif 83 + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ 84 + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */ 85 + 86 + static int 87 + wl_reg_proc_entry(wl_info_t *wl)