aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/chan.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-07-25 09:01:59 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-08-26 05:15:35 -0400
commit649b2a4da5d8a39c4d7be2fd228cf797819656f9 (patch)
tree5c051ac462a2ae57f0fc2cae06e6b480a6818adb /net/mac80211/chan.c
parentf8134fed8346c05007ca23e22e1504097afcd7c9 (diff)
mac80211: make ieee80211_vif_use_reserved_switch static
Reorder some code to make ieee80211_vif_use_reserved_switch() static, no other changes. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/chan.c')
-rw-r--r--net/mac80211/chan.c187
1 files changed, 93 insertions, 94 deletions
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 6d537f03c0ba..792eac6cc7b3 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -637,41 +637,6 @@ out:
637 return ret; 637 return ret;
638} 638}
639 639
640static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
641{
642 struct ieee80211_local *local = sdata->local;
643 struct ieee80211_chanctx_conf *conf;
644 struct ieee80211_chanctx *ctx;
645 bool use_reserved_switch = false;
646
647 lockdep_assert_held(&local->chanctx_mtx);
648
649 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
650 lockdep_is_held(&local->chanctx_mtx));
651 if (!conf)
652 return;
653
654 ctx = container_of(conf, struct ieee80211_chanctx, conf);
655
656 if (sdata->reserved_chanctx) {
657 if (sdata->reserved_chanctx->replace_state ==
658 IEEE80211_CHANCTX_REPLACES_OTHER &&
659 ieee80211_chanctx_num_reserved(local,
660 sdata->reserved_chanctx) > 1)
661 use_reserved_switch = true;
662
663 ieee80211_vif_unreserve_chanctx(sdata);
664 }
665
666 ieee80211_assign_vif_chanctx(sdata, NULL);
667 if (ieee80211_chanctx_refcount(local, ctx) == 0)
668 ieee80211_free_chanctx(local, ctx);
669
670 /* Unreserving may ready an in-place reservation. */
671 if (use_reserved_switch)
672 ieee80211_vif_use_reserved_switch(local);
673}
674
675void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, 640void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
676 struct ieee80211_chanctx *chanctx) 641 struct ieee80211_chanctx *chanctx)
677{ 642{
@@ -762,63 +727,6 @@ void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
762 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS); 727 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
763} 728}
764 729
765int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
766 const struct cfg80211_chan_def *chandef,
767 enum ieee80211_chanctx_mode mode)
768{
769 struct ieee80211_local *local = sdata->local;
770 struct ieee80211_chanctx *ctx;
771 u8 radar_detect_width = 0;
772 int ret;
773
774 lockdep_assert_held(&local->mtx);
775
776 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
777
778 mutex_lock(&local->chanctx_mtx);
779
780 ret = cfg80211_chandef_dfs_required(local->hw.wiphy,
781 chandef,
782 sdata->wdev.iftype);
783 if (ret < 0)
784 goto out;
785 if (ret > 0)
786 radar_detect_width = BIT(chandef->width);
787
788 sdata->radar_required = ret;
789
790 ret = ieee80211_check_combinations(sdata, chandef, mode,
791 radar_detect_width);
792 if (ret < 0)
793 goto out;
794
795 __ieee80211_vif_release_channel(sdata);
796
797 ctx = ieee80211_find_chanctx(local, chandef, mode);
798 if (!ctx)
799 ctx = ieee80211_new_chanctx(local, chandef, mode);
800 if (IS_ERR(ctx)) {
801 ret = PTR_ERR(ctx);
802 goto out;
803 }
804
805 sdata->vif.bss_conf.chandef = *chandef;
806
807 ret = ieee80211_assign_vif_chanctx(sdata, ctx);
808 if (ret) {
809 /* if assign fails refcount stays the same */
810 if (ieee80211_chanctx_refcount(local, ctx) == 0)
811 ieee80211_free_chanctx(local, ctx);
812 goto out;
813 }
814
815 ieee80211_recalc_smps_chanctx(local, ctx);
816 ieee80211_recalc_radar_chanctx(local, ctx);
817 out:
818 mutex_unlock(&local->chanctx_mtx);
819 return ret;
820}
821
822static void 730static void
823__ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, 731__ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
824 bool clear) 732 bool clear)
@@ -1267,8 +1175,7 @@ err:
1267 return err; 1175 return err;
1268} 1176}
1269 1177
1270int 1178static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
1271ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
1272{ 1179{
1273 struct ieee80211_sub_if_data *sdata, *sdata_tmp; 1180 struct ieee80211_sub_if_data *sdata, *sdata_tmp;
1274 struct ieee80211_chanctx *ctx, *ctx_tmp, *old_ctx; 1181 struct ieee80211_chanctx *ctx, *ctx_tmp, *old_ctx;
@@ -1520,6 +1427,98 @@ err:
1520 return err; 1427 return err;
1521} 1428}
1522 1429
1430static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
1431{
1432 struct ieee80211_local *local = sdata->local;
1433 struct ieee80211_chanctx_conf *conf;
1434 struct ieee80211_chanctx *ctx;
1435 bool use_reserved_switch = false;
1436
1437 lockdep_assert_held(&local->chanctx_mtx);
1438
1439 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
1440 lockdep_is_held(&local->chanctx_mtx));
1441 if (!conf)
1442 return;
1443
1444 ctx = container_of(conf, struct ieee80211_chanctx, conf);
1445
1446 if (sdata->reserved_chanctx) {
1447 if (sdata->reserved_chanctx->replace_state ==
1448 IEEE80211_CHANCTX_REPLACES_OTHER &&
1449 ieee80211_chanctx_num_reserved(local,
1450 sdata->reserved_chanctx) > 1)
1451 use_reserved_switch = true;
1452
1453 ieee80211_vif_unreserve_chanctx(sdata);
1454 }
1455
1456 ieee80211_assign_vif_chanctx(sdata, NULL);
1457 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1458 ieee80211_free_chanctx(local, ctx);
1459
1460 /* Unreserving may ready an in-place reservation. */
1461 if (use_reserved_switch)
1462 ieee80211_vif_use_reserved_switch(local);
1463}
1464
1465int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
1466 const struct cfg80211_chan_def *chandef,
1467 enum ieee80211_chanctx_mode mode)
1468{
1469 struct ieee80211_local *local = sdata->local;
1470 struct ieee80211_chanctx *ctx;
1471 u8 radar_detect_width = 0;
1472 int ret;
1473
1474 lockdep_assert_held(&local->mtx);
1475
1476 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
1477
1478 mutex_lock(&local->chanctx_mtx);
1479
1480 ret = cfg80211_chandef_dfs_required(local->hw.wiphy,
1481 chandef,
1482 sdata->wdev.iftype);
1483 if (ret < 0)
1484 goto out;
1485 if (ret > 0)
1486 radar_detect_width = BIT(chandef->width);
1487
1488 sdata->radar_required = ret;
1489
1490 ret = ieee80211_check_combinations(sdata, chandef, mode,
1491 radar_detect_width);
1492 if (ret < 0)
1493 goto out;
1494
1495 __ieee80211_vif_release_channel(sdata);
1496
1497 ctx = ieee80211_find_chanctx(local, chandef, mode);
1498 if (!ctx)
1499 ctx = ieee80211_new_chanctx(local, chandef, mode);
1500 if (IS_ERR(ctx)) {
1501 ret = PTR_ERR(ctx);
1502 goto out;
1503 }
1504
1505 sdata->vif.bss_conf.chandef = *chandef;
1506
1507 ret = ieee80211_assign_vif_chanctx(sdata, ctx);
1508 if (ret) {
1509 /* if assign fails refcount stays the same */
1510 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1511 ieee80211_free_chanctx(local, ctx);
1512 goto out;
1513 }
1514
1515 ieee80211_recalc_smps_chanctx(local, ctx);
1516 ieee80211_recalc_radar_chanctx(local, ctx);
1517 out:
1518 mutex_unlock(&local->chanctx_mtx);
1519 return ret;
1520}
1521
1523int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata) 1522int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata)
1524{ 1523{
1525 struct ieee80211_local *local = sdata->local; 1524 struct ieee80211_local *local = sdata->local;