aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/wext-compat.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-06-02 07:01:39 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 14:06:14 -0400
commit7643a2c3fcc13cd6fbd731f214463547383418ae (patch)
treee2e41315f0d38a8627456303820b5c1c2a9b54a6 /net/wireless/wext-compat.c
parentc64fb01627e24725d1f9d535e4426475a4415753 (diff)
cfg80211: move txpower wext from mac80211
This patch introduces new cfg80211 API to set the TX power via cfg80211, puts the wext code into cfg80211 and updates mac80211 to use all that. The -ENETDOWN bits are a hack but will go away soon. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/wext-compat.c')
-rw-r--r--net/wireless/wext-compat.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 711e00a0c9b5..9fbfb8536e75 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -744,3 +744,83 @@ int cfg80211_wext_giwencode(struct net_device *dev,
744 return err; 744 return err;
745} 745}
746EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode); 746EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode);
747
748int cfg80211_wext_siwtxpower(struct net_device *dev,
749 struct iw_request_info *info,
750 union iwreq_data *data, char *extra)
751{
752 struct wireless_dev *wdev = dev->ieee80211_ptr;
753 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
754 enum tx_power_setting type;
755 int dbm = 0;
756
757 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
758 return -EINVAL;
759 if (data->txpower.flags & IW_TXPOW_RANGE)
760 return -EINVAL;
761
762 if (!rdev->ops->set_tx_power)
763 return -EOPNOTSUPP;
764
765 /* only change when not disabling */
766 if (!data->txpower.disabled) {
767 if (data->txpower.fixed) {
768 /*
769 * wext doesn't support negative values, see
770 * below where it's for automatic
771 */
772 if (data->txpower.value < 0)
773 return -EINVAL;
774 dbm = data->txpower.value;
775 type = TX_POWER_FIXED;
776 /* TODO: do regulatory check! */
777 } else {
778 /*
779 * Automatic power level setting, max being the value
780 * passed in from userland.
781 */
782 if (data->txpower.value < 0) {
783 type = TX_POWER_AUTOMATIC;
784 } else {
785 dbm = data->txpower.value;
786 type = TX_POWER_LIMITED;
787 }
788 }
789 } else {
790 type = TX_POWER_OFF;
791 }
792
793 return rdev->ops->set_tx_power(wdev->wiphy, type, dbm);;
794}
795EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower);
796
797int cfg80211_wext_giwtxpower(struct net_device *dev,
798 struct iw_request_info *info,
799 union iwreq_data *data, char *extra)
800{
801 struct wireless_dev *wdev = dev->ieee80211_ptr;
802 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
803 int err, val;
804
805 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
806 return -EINVAL;
807 if (data->txpower.flags & IW_TXPOW_RANGE)
808 return -EINVAL;
809
810 if (!rdev->ops->get_tx_power)
811 return -EOPNOTSUPP;
812
813 err = rdev->ops->get_tx_power(wdev->wiphy, &val);
814 /* HACK!!! */
815 if (err && err != -ENETDOWN)
816 return err;
817
818 /* well... oh well */
819 data->txpower.fixed = 1;
820 data->txpower.disabled = err == -ENETDOWN;
821 data->txpower.value = val;
822 data->txpower.flags = IW_TXPOW_DBM;
823
824 return 0;
825}
826EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower);