Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

orinoco: convert mode setting to cfg80211

Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

David Kilroy and committed by
John W. Linville
5217c571 721aa2f7

+70 -80
+45 -1
drivers/net/wireless/orinoco/cfg.c
··· 93 93 return wiphy_register(wiphy); 94 94 } 95 95 96 - const struct cfg80211_ops orinoco_cfg_ops = { 96 + static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev, 97 + enum nl80211_iftype type, u32 *flags, 98 + struct vif_params *params) 99 + { 100 + struct orinoco_private *priv = wiphy_priv(wiphy); 101 + int err = 0; 102 + unsigned long lock; 97 103 104 + if (orinoco_lock(priv, &lock) != 0) 105 + return -EBUSY; 106 + 107 + switch (type) { 108 + case NL80211_IFTYPE_ADHOC: 109 + if (!priv->has_ibss && !priv->has_port3) 110 + err = -EINVAL; 111 + break; 112 + 113 + case NL80211_IFTYPE_STATION: 114 + break; 115 + 116 + case NL80211_IFTYPE_MONITOR: 117 + if (priv->broken_monitor && !force_monitor) { 118 + printk(KERN_WARNING "%s: Monitor mode support is " 119 + "buggy in this firmware, not enabling\n", 120 + wiphy_name(wiphy)); 121 + err = -EINVAL; 122 + } 123 + break; 124 + 125 + default: 126 + err = -EINVAL; 127 + } 128 + 129 + if (!err) { 130 + priv->iw_mode = type; 131 + set_port_type(priv); 132 + err = orinoco_commit(priv); 133 + } 134 + 135 + orinoco_unlock(priv, &lock); 136 + 137 + return err; 138 + } 139 + 140 + const struct cfg80211_ops orinoco_cfg_ops = { 141 + .change_virtual_intf = orinoco_change_vif, 98 142 };
+8 -4
drivers/net/wireless/orinoco/hw.c
··· 7 7 #include <linux/if_arp.h> 8 8 #include <linux/ieee80211.h> 9 9 #include <linux/wireless.h> 10 - 10 + #include <net/cfg80211.h> 11 11 #include "hermes.h" 12 12 #include "hermes_rid.h" 13 13 #include "orinoco.h" ··· 409 409 int orinoco_hw_program_rids(struct orinoco_private *priv) 410 410 { 411 411 struct net_device *dev = priv->ndev; 412 + struct wireless_dev *wdev = netdev_priv(dev); 412 413 hermes_t *hw = &priv->hw; 413 414 int err; 414 415 struct hermes_idstring idbuf; ··· 432 431 return err; 433 432 } 434 433 /* Set the channel/frequency */ 435 - if (priv->channel != 0 && priv->iw_mode != IW_MODE_INFRA) { 434 + if (priv->channel != 0 && priv->iw_mode != NL80211_IFTYPE_STATION) { 436 435 err = hermes_write_wordrec(hw, USER_BAP, 437 436 HERMES_RID_CNFOWNCHANNEL, 438 437 priv->channel); ··· 613 612 } 614 613 } 615 614 616 - if (priv->iw_mode == IW_MODE_MONITOR) { 615 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 617 616 /* Enable monitor mode */ 618 617 dev->type = ARPHRD_IEEE80211; 619 618 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | ··· 630 629 /* Reset promiscuity / multicast*/ 631 630 priv->promiscuous = 0; 632 631 priv->mc_count = 0; 632 + 633 + /* Record mode change */ 634 + wdev->iftype = priv->iw_mode; 633 635 634 636 return 0; 635 637 } ··· 888 884 } else 889 885 master_wep_flag = 0; 890 886 891 - if (priv->iw_mode == IW_MODE_MONITOR) 887 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) 892 888 master_wep_flag |= HERMES_WEP_HOST_DECRYPT; 893 889 894 890 /* Master WEP setting : on/off */
+8 -7
drivers/net/wireless/orinoco/main.c
··· 222 222 void set_port_type(struct orinoco_private *priv) 223 223 { 224 224 switch (priv->iw_mode) { 225 - case IW_MODE_INFRA: 225 + case NL80211_IFTYPE_STATION: 226 226 priv->port_type = 1; 227 227 priv->createibss = 0; 228 228 break; 229 - case IW_MODE_ADHOC: 229 + case NL80211_IFTYPE_ADHOC: 230 230 if (priv->prefer_port3) { 231 231 priv->port_type = 3; 232 232 priv->createibss = 0; ··· 235 235 priv->createibss = 1; 236 236 } 237 237 break; 238 - case IW_MODE_MONITOR: 238 + case NL80211_IFTYPE_MONITOR: 239 239 priv->port_type = 3; 240 240 priv->createibss = 0; 241 241 break; ··· 359 359 return NETDEV_TX_BUSY; 360 360 } 361 361 362 - if (!netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) { 362 + if (!netif_carrier_ok(dev) || 363 + (priv->iw_mode == NL80211_IFTYPE_MONITOR)) { 363 364 /* Oops, the firmware hasn't established a connection, 364 365 silently drop the packet (this seems to be the 365 366 safest approach). */ ··· 821 820 } 822 821 823 822 /* Handle frames in monitor mode */ 824 - if (priv->iw_mode == IW_MODE_MONITOR) { 823 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 825 824 orinoco_rx_monitor(dev, rxfid, desc); 826 825 goto out; 827 826 } ··· 1332 1331 u16 newstatus; 1333 1332 int connected; 1334 1333 1335 - if (priv->iw_mode == IW_MODE_MONITOR) 1334 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) 1336 1335 break; 1337 1336 1338 1337 if (len != sizeof(linkstatus)) { ··· 1982 1981 } 1983 1982 1984 1983 /* Set up the default configuration */ 1985 - priv->iw_mode = IW_MODE_INFRA; 1984 + priv->iw_mode = NL80211_IFTYPE_STATION; 1986 1985 /* By default use IEEE/IBSS ad-hoc mode if we have it */ 1987 1986 priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss); 1988 1987 set_port_type(priv);
+1 -1
drivers/net/wireless/orinoco/orinoco.h
··· 121 121 unsigned int broken_monitor:1; 122 122 123 123 /* Configuration paramaters */ 124 - u32 iw_mode; 124 + enum nl80211_iftype iw_mode; 125 125 int prefer_port3; 126 126 u16 encode_alg, wep_restrict, tx_key; 127 127 struct orinoco_key keys[ORINOCO_MAX_KEYS];
+8 -67
drivers/net/wireless/orinoco/wext.c
··· 52 52 * here so we're not safe to sleep here. */ 53 53 hermes_inquire(hw, HERMES_INQ_TALLIES); 54 54 55 - if (priv->iw_mode == IW_MODE_ADHOC) { 55 + if (priv->iw_mode == NL80211_IFTYPE_ADHOC) { 56 56 memset(&wstats->qual, 0, sizeof(wstats->qual)); 57 57 /* If a spy address is defined, we report stats of the 58 58 * first spy address - Jean II */ ··· 124 124 goto out; 125 125 } 126 126 127 - if (priv->iw_mode != IW_MODE_INFRA) { 127 + if (priv->iw_mode != NL80211_IFTYPE_STATION) { 128 128 printk(KERN_WARNING "%s: Manual roaming supported only in " 129 129 "managed mode\n", dev->name); 130 130 err = -EOPNOTSUPP; ··· 170 170 orinoco_unlock(priv, &flags); 171 171 172 172 return err; 173 - } 174 - 175 - static int orinoco_ioctl_setmode(struct net_device *dev, 176 - struct iw_request_info *info, 177 - u32 *mode, 178 - char *extra) 179 - { 180 - struct orinoco_private *priv = ndev_priv(dev); 181 - int err = -EINPROGRESS; /* Call commit handler */ 182 - unsigned long flags; 183 - 184 - if (priv->iw_mode == *mode) 185 - return 0; 186 - 187 - if (orinoco_lock(priv, &flags) != 0) 188 - return -EBUSY; 189 - 190 - switch (*mode) { 191 - case IW_MODE_ADHOC: 192 - if (!priv->has_ibss && !priv->has_port3) 193 - err = -EOPNOTSUPP; 194 - break; 195 - 196 - case IW_MODE_INFRA: 197 - break; 198 - 199 - case IW_MODE_MONITOR: 200 - if (priv->broken_monitor && !force_monitor) { 201 - printk(KERN_WARNING "%s: Monitor mode support is " 202 - "buggy in this firmware, not enabling\n", 203 - dev->name); 204 - err = -EOPNOTSUPP; 205 - } 206 - break; 207 - 208 - default: 209 - err = -EOPNOTSUPP; 210 - break; 211 - } 212 - 213 - if (err == -EINPROGRESS) { 214 - priv->iw_mode = *mode; 215 - set_port_type(priv); 216 - } 217 - 218 - orinoco_unlock(priv, &flags); 219 - 220 - return err; 221 - } 222 - 223 - static int orinoco_ioctl_getmode(struct net_device *dev, 224 - struct iw_request_info *info, 225 - u32 *mode, 226 - char *extra) 227 - { 228 - struct orinoco_private *priv = ndev_priv(dev); 229 - 230 - *mode = priv->iw_mode; 231 - return 0; 232 173 } 233 174 234 175 static int orinoco_ioctl_getiwrange(struct net_device *dev, ··· 221 280 if (priv->has_wpa) 222 281 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP; 223 282 224 - if ((priv->iw_mode == IW_MODE_ADHOC) && (!SPY_NUMBER(priv))) { 283 + if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && (!SPY_NUMBER(priv))) { 225 284 /* Quality stats meaningless in ad-hoc mode */ 226 285 } else { 227 286 range->max_qual.qual = 0x8b - 0x2f; ··· 537 596 int err = -EINPROGRESS; /* Call commit handler */ 538 597 539 598 /* In infrastructure mode the AP sets the channel */ 540 - if (priv->iw_mode == IW_MODE_INFRA) 599 + if (priv->iw_mode == NL80211_IFTYPE_STATION) 541 600 return -EBUSY; 542 601 543 602 if ((frq->e == 0) && (frq->m <= 1000)) { ··· 563 622 return -EBUSY; 564 623 565 624 priv->channel = chan; 566 - if (priv->iw_mode == IW_MODE_MONITOR) { 625 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 567 626 /* Fast channel change - no commit if successful */ 568 627 hermes_t *hw = &priv->hw; 569 628 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | ··· 1614 1673 /* In monitor mode, the scan results are always empty. 1615 1674 * Probe responses are passed to the driver as received 1616 1675 * frames and could be processed in software. */ 1617 - if (priv->iw_mode == IW_MODE_MONITOR) { 1676 + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 1618 1677 err = -EOPNOTSUPP; 1619 1678 goto out; 1620 1679 } ··· 2150 2209 STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), 2151 2210 STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), 2152 2211 STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), 2153 - STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode), 2154 - STD_IW_HANDLER(SIOCGIWMODE, orinoco_ioctl_getmode), 2212 + STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode), 2213 + STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode), 2155 2214 STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), 2156 2215 STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), 2157 2216 STD_IW_HANDLER(SIOCGIWRANGE, orinoco_ioctl_getiwrange),