aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r--net/mac80211/cfg.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index d2fc18c1ae0d..81258acf48bc 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1334,6 +1334,58 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1334 return 0; 1334 return 0;
1335} 1335}
1336 1336
1337static int ieee80211_set_tx_power(struct wiphy *wiphy,
1338 enum tx_power_setting type, int dbm)
1339{
1340 struct ieee80211_local *local = wiphy_priv(wiphy);
1341 struct ieee80211_channel *chan = local->hw.conf.channel;
1342 u32 changes = 0;
1343 bool radio_enabled = true;
1344
1345 switch (type) {
1346 case TX_POWER_AUTOMATIC:
1347 local->user_power_level = -1;
1348 break;
1349 case TX_POWER_LIMITED:
1350 if (dbm < 0)
1351 return -EINVAL;
1352 local->user_power_level = dbm;
1353 break;
1354 case TX_POWER_FIXED:
1355 if (dbm < 0)
1356 return -EINVAL;
1357 /* TODO: move to cfg80211 when it knows the channel */
1358 if (dbm > chan->max_power)
1359 return -EINVAL;
1360 local->user_power_level = dbm;
1361 break;
1362 case TX_POWER_OFF:
1363 radio_enabled = false;
1364 break;
1365 }
1366
1367 if (radio_enabled != local->hw.conf.radio_enabled) {
1368 changes |= IEEE80211_CONF_CHANGE_RADIO_ENABLED;
1369 local->hw.conf.radio_enabled = radio_enabled;
1370 }
1371
1372 ieee80211_hw_config(local, changes);
1373
1374 return 0;
1375}
1376
1377static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1378{
1379 struct ieee80211_local *local = wiphy_priv(wiphy);
1380
1381 *dbm = local->hw.conf.power_level;
1382
1383 if (!local->hw.conf.radio_enabled)
1384 return -ENETDOWN;
1385
1386 return 0;
1387}
1388
1337struct cfg80211_ops mac80211_config_ops = { 1389struct cfg80211_ops mac80211_config_ops = {
1338 .add_virtual_intf = ieee80211_add_iface, 1390 .add_virtual_intf = ieee80211_add_iface,
1339 .del_virtual_intf = ieee80211_del_iface, 1391 .del_virtual_intf = ieee80211_del_iface,
@@ -1373,4 +1425,6 @@ struct cfg80211_ops mac80211_config_ops = {
1373 .join_ibss = ieee80211_join_ibss, 1425 .join_ibss = ieee80211_join_ibss,
1374 .leave_ibss = ieee80211_leave_ibss, 1426 .leave_ibss = ieee80211_leave_ibss,
1375 .set_wiphy_params = ieee80211_set_wiphy_params, 1427 .set_wiphy_params = ieee80211_set_wiphy_params,
1428 .set_tx_power = ieee80211_set_tx_power,
1429 .get_tx_power = ieee80211_get_tx_power,
1376}; 1430};