wok-current annotate broadcom-wl-pae/stuff/017-get-rid-of-get_fs-set_fs-calls.patch @ rev 25694

Fix cifs-utils, up grub2-efi-x64 stuff for iso EFI
author Stanislas Leduc <shann@slitaz.org>
date Sat Mar 30 18:05:22 2024 +0000 (3 months ago)
parents
children
rev   line source
shann@25643 1 From: Joan Bruguera <joanbrugueram@gmail.com>
shann@25643 2 Date: Sun, 13 Sep 2020 07:33:32 +0200
shann@25643 3 Subject: Get rid of get_fs/set_fs calls in Broadcom WL driver.
shann@25643 4 Origin: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
shann@25643 5
shann@25643 6 Fixes linux-next where get_fs/set_fs is already removed for some architectures.
shann@25643 7
shann@25643 8 NB: Some checks in wlc_ioctl_internal are likely superfluous,
shann@25643 9 but I'm not familiar enough with the driver to remove them with confidence.
shann@25643 10
shann@25643 11 See also: https://lwn.net/Articles/722267/
shann@25643 12 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
shann@25643 13 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/linux/uaccess.h?h=next-20200911&id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
shann@25643 14
shann@25643 15 Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
shann@25643 16 ---
shann@25643 17 amd64/src/wl/sys/wl_cfg80211_hybrid.c | 29 ++-----------------------
shann@25643 18 amd64/src/wl/sys/wl_iw.c | 25 ++--------------------
shann@25643 19 amd64/src/wl/sys/wl_linux.c | 40 ++++++++++++++++++++++++++++++-----
shann@25643 20 amd64/src/wl/sys/wl_linux.h | 2 ++
shann@25643 21 amd64/src/wl/sys/wlc_pub.h | 1 +
shann@25643 22 5 files changed, 42 insertions(+), 55 deletions(-)
shann@25643 23
shann@25643 24 diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
shann@25643 25 index 8e01841..111ec5a 100644
shann@25643 26 --- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c
shann@25643 27 +++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c
shann@25643 28 @@ -41,6 +41,7 @@
shann@25643 29 #include <wlioctl.h>
shann@25643 30 #include <proto/802.11.h>
shann@25643 31 #include <wl_cfg80211_hybrid.h>
shann@25643 32 +#include <wl_linux.h>
shann@25643 33
shann@25643 34 #define EVENT_TYPE(e) dtoh32((e)->event_type)
shann@25643 35 #define EVENT_FLAGS(e) dtoh16((e)->flags)
shann@25643 36 @@ -442,30 +443,8 @@
shann@25643 37 static s32
shann@25643 38 wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
shann@25643 39 {
shann@25643 40 - struct ifreq ifr;
shann@25643 41 - struct wl_ioctl ioc;
shann@25643 42 - mm_segment_t fs;
shann@25643 43 - s32 err = 0;
shann@25643 44 -
shann@25643 45 BUG_ON(len < sizeof(int));
shann@25643 46 -
shann@25643 47 - memset(&ioc, 0, sizeof(ioc));
shann@25643 48 - ioc.cmd = cmd;
shann@25643 49 - ioc.buf = arg;
shann@25643 50 - ioc.len = len;
shann@25643 51 - strcpy(ifr.ifr_name, dev->name);
shann@25643 52 - ifr.ifr_data = (caddr_t)&ioc;
shann@25643 53 -
shann@25643 54 - fs = get_fs();
shann@25643 55 - set_fs(get_ds());
shann@25643 56 -#if defined(WL_USE_NETDEV_OPS)
shann@25643 57 - err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25643 58 -#else
shann@25643 59 - err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25643 60 -#endif
shann@25643 61 - set_fs(fs);
shann@25643 62 -
shann@25643 63 - return err;
shann@25643 64 + return wlc_ioctl_internal(dev, cmd, arg, len);
shann@25643 65 }
shann@25643 66
shann@25643 67 static s32
shann@25643 68 diff --git a/amd64/src/wl/sys/wl_iw.c b/amd64/src/wl/sys/wl_iw.c
shann@25643 69 index c4c610b..e346b15 100644
shann@25643 70 --- a/amd64/src/wl/sys/wl_iw.c
shann@25643 71 +++ b/amd64/src/wl/sys/wl_iw.c
shann@25643 72 @@ -37,6 +37,7 @@ typedef const struct si_pub si_t;
shann@25643 73
shann@25643 74 #include <wl_dbg.h>
shann@25643 75 #include <wl_iw.h>
shann@25643 76 +#include <wl_linux.h>
shann@25643 77
shann@25643 78 extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
shann@25643 79 uint32 reason, char* stringBuf, uint buflen);
shann@25643 80 @@ -103,29 +104,7 @@ dev_wlc_ioctl(
shann@25643 81 int len
shann@25643 82 )
shann@25643 83 {
shann@25643 84 - struct ifreq ifr;
shann@25643 85 - wl_ioctl_t ioc;
shann@25643 86 - mm_segment_t fs;
shann@25643 87 - int ret;
shann@25643 88 -
shann@25643 89 - memset(&ioc, 0, sizeof(ioc));
shann@25643 90 - ioc.cmd = cmd;
shann@25643 91 - ioc.buf = arg;
shann@25643 92 - ioc.len = len;
shann@25643 93 -
shann@25643 94 - strcpy(ifr.ifr_name, dev->name);
shann@25643 95 - ifr.ifr_data = (caddr_t) &ioc;
shann@25643 96 -
shann@25643 97 - fs = get_fs();
shann@25643 98 - set_fs(get_ds());
shann@25643 99 -#if defined(WL_USE_NETDEV_OPS)
shann@25643 100 - ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25643 101 -#else
shann@25643 102 - ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25643 103 -#endif
shann@25643 104 - set_fs(fs);
shann@25643 105 -
shann@25643 106 - return ret;
shann@25643 107 + return wlc_ioctl_internal(dev, cmd, arg, len);
shann@25643 108 }
shann@25643 109
shann@25643 110 static int
shann@25643 111 diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c
shann@25643 112 index 66069d4..cc01d2b 100644
shann@25643 113 --- a/amd64/src/wl/sys/wl_linux.c
shann@25643 114 +++ b/amd64/src/wl/sys/wl_linux.c
shann@25643 115 @@ -1661,10 +1661,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
shann@25643 116 goto done2;
shann@25643 117 }
shann@25643 118
shann@25643 119 - if (segment_eq(get_fs(), KERNEL_DS))
shann@25643 120 - buf = ioc.buf;
shann@25643 121 -
shann@25643 122 - else if (ioc.buf) {
shann@25643 123 + if (ioc.buf) {
shann@25643 124 if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
shann@25643 125 bcmerror = BCME_NORESOURCE;
shann@25643 126 goto done2;
shann@25643 127 @@ -1681,7 +1678,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
shann@25643 128 WL_UNLOCK(wl);
shann@25643 129
shann@25643 130 done1:
shann@25643 131 - if (ioc.buf && (ioc.buf != buf)) {
shann@25643 132 + if (ioc.buf) {
shann@25643 133 if (copy_to_user(ioc.buf, buf, ioc.len))
shann@25643 134 bcmerror = BCME_BADADDR;
shann@25643 135 MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
shann@25643 136 @@ -1694,6 +1691,39 @@ done2:
shann@25643 137 return (OSL_ERROR(bcmerror));
shann@25643 138 }
shann@25643 139
shann@25643 140 +int
shann@25643 141 +wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
shann@25643 142 +{
shann@25643 143 + wl_info_t *wl;
shann@25643 144 + wl_if_t *wlif;
shann@25643 145 + int bcmerror;
shann@25643 146 +
shann@25643 147 + if (!dev)
shann@25643 148 + return -ENETDOWN;
shann@25643 149 +
shann@25643 150 + wl = WL_INFO(dev);
shann@25643 151 + wlif = WL_DEV_IF(dev);
shann@25643 152 + if (wlif == NULL || wl == NULL || wl->dev == NULL)
shann@25643 153 + return -ENETDOWN;
shann@25643 154 +
shann@25643 155 + bcmerror = 0;
shann@25643 156 +
shann@25643 157 + WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
shann@25643 158 +
shann@25643 159 + WL_LOCK(wl);
shann@25643 160 + if (!capable(CAP_NET_ADMIN)) {
shann@25643 161 + bcmerror = BCME_EPERM;
shann@25643 162 + } else {
shann@25643 163 + bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
shann@25643 164 + }
shann@25643 165 + WL_UNLOCK(wl);
shann@25643 166 +
shann@25643 167 + ASSERT(VALID_BCMERROR(bcmerror));
shann@25643 168 + if (bcmerror != 0)
shann@25643 169 + wl->pub->bcmerror = bcmerror;
shann@25643 170 + return (OSL_ERROR(bcmerror));
shann@25643 171 +}
shann@25643 172 +
shann@25643 173 static struct net_device_stats*
shann@25643 174 wl_get_stats(struct net_device *dev)
shann@25643 175 {
shann@25643 176 diff --git a/amd64/src/wl/sys/wl_linux.h b/amd64/src/wl/sys/wl_linux.h
shann@25643 177 index 5b1048e..c8c1f41 100644
shann@25643 178 --- a/amd64/src/wl/sys/wl_linux.h
shann@25643 179 +++ b/amd64/src/wl/sys/wl_linux.h
shann@25643 180 @@ -22,6 +22,7 @@
shann@25643 181 #define _wl_linux_h_
shann@25643 182
shann@25643 183 #include <wlc_types.h>
shann@25643 184 +#include <wlc_pub.h>
shann@25643 185
shann@25643 186 typedef struct wl_timer {
shann@25643 187 struct timer_list timer;
shann@25643 188 @@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
shann@25643 189 extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
shann@25643 190 extern void wl_free(wl_info_t *wl);
shann@25643 191 extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
shann@25643 192 +extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
shann@25643 193 extern struct net_device * wl_netdev_get(wl_info_t *wl);
shann@25643 194
shann@25643 195 #endif
shann@25643 196 diff --git a/amd64/src/wl/sys/wlc_pub.h b/amd64/src/wl/sys/wlc_pub.h
shann@25643 197 index 53a98b8..2b5a029 100644
shann@25643 198 --- a/amd64/src/wl/sys/wlc_pub.h
shann@25643 199 +++ b/amd64/src/wl/sys/wlc_pub.h
shann@25643 200 @@ -24,6 +24,7 @@
shann@25643 201
shann@25643 202 #include <wlc_types.h>
shann@25643 203 #include <wlc_utils.h>
shann@25643 204 +#include <siutils.h>
shann@25643 205 #include "proto/802.11.h"
shann@25643 206 #include "proto/bcmevent.h"
shann@25643 207