cfg80211: combine iwfreq implementations
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / wireless / wext-compat.c
index e6731bf550626e29e90a52bf592fc34bd1f793e0..fc2e7768967d70eab8ad375caae689c8e199c928 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/etherdevice.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
+#include "wext-compat.h"
 #include "core.h"
 
 int cfg80211_wext_giwname(struct net_device *dev,
@@ -300,7 +301,6 @@ struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
                return ERR_PTR(-EINVAL);
        return chan;
 }
-EXPORT_SYMBOL_GPL(cfg80211_wext_freq);
 
 int cfg80211_wext_siwrts(struct net_device *dev,
                         struct iw_request_info *info,
@@ -531,7 +531,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
                        wdev->wext.keys->data[idx];
        }
 
-       if (params->cipher != WLAN_CIPHER_SUITE_AES_CMAC &&
+       if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+            params->cipher == WLAN_CIPHER_SUITE_WEP104) &&
            (tx_key || (!addr && wdev->wext.default_key == -1))) {
                if (wdev->current_bss)
                        err = rdev->ops->set_default_key(&rdev->wiphy,
@@ -758,6 +759,58 @@ int cfg80211_wext_giwencode(struct net_device *dev,
 }
 EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode);
 
+int cfg80211_wext_siwfreq(struct net_device *dev,
+                         struct iw_request_info *info,
+                         struct iw_freq *freq, char *extra)
+{
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+       struct ieee80211_channel *chan;
+       int err;
+
+       switch (wdev->iftype) {
+       case NL80211_IFTYPE_STATION:
+               return cfg80211_mgd_wext_siwfreq(dev, info, freq, extra);
+       case NL80211_IFTYPE_ADHOC:
+               return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra);
+       default:
+               chan = cfg80211_wext_freq(wdev->wiphy, freq);
+               if (!chan)
+                       return -EINVAL;
+               if (IS_ERR(chan))
+                       return PTR_ERR(chan);
+               err = rdev->ops->set_channel(wdev->wiphy, chan,
+                                            NL80211_CHAN_NO_HT);
+               if (err)
+                       return err;
+               rdev->channel = chan;
+               return 0;
+       }
+}
+EXPORT_SYMBOL_GPL(cfg80211_wext_siwfreq);
+
+int cfg80211_wext_giwfreq(struct net_device *dev,
+                         struct iw_request_info *info,
+                         struct iw_freq *freq, char *extra)
+{
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+
+       switch (wdev->iftype) {
+       case NL80211_IFTYPE_STATION:
+               return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
+       case NL80211_IFTYPE_ADHOC:
+               return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
+       default:
+               if (!rdev->channel)
+                       return -EINVAL;
+               freq->m = rdev->channel->center_freq;
+               freq->e = 6;
+               return 0;
+       }
+}
+EXPORT_SYMBOL_GPL(cfg80211_wext_giwfreq);
+
 int cfg80211_wext_siwtxpower(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *data, char *extra)