aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00dev.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-09-25 14:55:39 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:03 -0400
commit066cb637b1b562bebd09d237bfaaca6724f247e5 (patch)
tree340b3902e69246cb73e820bbd9994bd1bdcca402 /drivers/net/wireless/rt2x00/rt2x00dev.c
parent12dadb9009723dd0512091643e6e403f9e1b25cb (diff)
[PATCH] rt2x00: Reorganize rt2x00dev->flags
The rt2x00dev->flags has become a chaos over time, this will reorganize the flags by renaming, deleting, adding and properly implement the flags. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00dev.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 4f66adc5b09c..f8f7e6e47f80 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -40,7 +40,7 @@
40struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev, 40struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev,
41 const unsigned int queue) 41 const unsigned int queue)
42{ 42{
43 int beacon = test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags); 43 int beacon = test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);
44 44
45 /* 45 /*
46 * Check if we are requesting a reqular TX ring, 46 * Check if we are requesting a reqular TX ring,
@@ -102,7 +102,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
102 * And check if the hardware button has been disabled. 102 * And check if the hardware button has been disabled.
103 */ 103 */
104 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 104 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) ||
105 (test_bit(DEVICE_SUPPORT_HW_BUTTON, &rt2x00dev->flags) && 105 (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) &&
106 !test_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags))) 106 !test_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags)))
107 return 0; 107 return 0;
108 108
@@ -162,6 +162,9 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable)
162{ 162{
163 enum dev_state state = enable ? STATE_RADIO_RX_ON : STATE_RADIO_RX_OFF; 163 enum dev_state state = enable ? STATE_RADIO_RX_ON : STATE_RADIO_RX_OFF;
164 164
165 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
166 return;
167
165 /* 168 /*
166 * When we are disabling the RX, we should also stop the link tuner. 169 * When we are disabling the RX, we should also stop the link tuner.
167 */ 170 */
@@ -721,7 +724,7 @@ exit:
721 724
722static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) 725static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
723{ 726{
724 if (test_bit(DEVICE_INITIALIZED_HW, &rt2x00dev->flags)) 727 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags))
725 ieee80211_unregister_hw(rt2x00dev->hw); 728 ieee80211_unregister_hw(rt2x00dev->hw);
726 729
727 if (likely(rt2x00dev->hwmodes)) { 730 if (likely(rt2x00dev->hwmodes)) {
@@ -753,7 +756,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
753 return status; 756 return status;
754 } 757 }
755 758
756 __set_bit(DEVICE_INITIALIZED_HW, &rt2x00dev->flags); 759 __set_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags);
757 760
758 return 0; 761 return 0;
759} 762}
@@ -810,7 +813,7 @@ static int rt2x00lib_alloc_ring_entries(struct rt2x00_dev *rt2x00dev)
810 return -ENOMEM; 813 return -ENOMEM;
811 } 814 }
812 815
813 if (!test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags)) 816 if (!test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags))
814 return 0; 817 return 0;
815 818
816 /* 819 /*
@@ -919,7 +922,7 @@ static int rt2x00lib_alloc_rings(struct rt2x00_dev *rt2x00dev)
919 * Atim: 1 (if required) 922 * Atim: 1 (if required)
920 */ 923 */
921 rt2x00dev->data_rings = 1 + rt2x00dev->hw->queues + 924 rt2x00dev->data_rings = 1 + rt2x00dev->hw->queues +
922 (2 * test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags)); 925 (2 * test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags));
923 926
924 ring = kzalloc(rt2x00dev->data_rings * sizeof(*ring), GFP_KERNEL); 927 ring = kzalloc(rt2x00dev->data_rings * sizeof(*ring), GFP_KERNEL);
925 if (!ring) { 928 if (!ring) {
@@ -932,7 +935,7 @@ static int rt2x00lib_alloc_rings(struct rt2x00_dev *rt2x00dev)
932 */ 935 */
933 rt2x00dev->rx = ring; 936 rt2x00dev->rx = ring;
934 rt2x00dev->tx = &rt2x00dev->rx[1]; 937 rt2x00dev->tx = &rt2x00dev->rx[1];
935 if (test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags)) 938 if (test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags))
936 rt2x00dev->bcn = &rt2x00dev->tx[rt2x00dev->hw->queues]; 939 rt2x00dev->bcn = &rt2x00dev->tx[rt2x00dev->hw->queues];
937 940
938 /* 941 /*
@@ -1011,6 +1014,8 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1011 */ 1014 */
1012 rt2x00debug_register(rt2x00dev); 1015 rt2x00debug_register(rt2x00dev);
1013 1016
1017 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1018
1014 return 0; 1019 return 0;
1015 1020
1016exit: 1021exit:
@@ -1022,6 +1027,8 @@ EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev);
1022 1027
1023void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) 1028void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1024{ 1029{
1030 __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1031
1025 /* 1032 /*
1026 * Disable radio. 1033 * Disable radio.
1027 */ 1034 */
@@ -1068,6 +1075,13 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1068 int retval; 1075 int retval;
1069 1076
1070 NOTICE(rt2x00dev, "Going to sleep.\n"); 1077 NOTICE(rt2x00dev, "Going to sleep.\n");
1078 __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1079
1080 /*
1081 * Only continue if mac80211 has open interfaces.
1082 */
1083 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
1084 goto exit;
1071 1085
1072 /* 1086 /*
1073 * Disable radio and unitialize all items 1087 * Disable radio and unitialize all items
@@ -1077,6 +1091,7 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1077 rt2x00lib_uninitialize(rt2x00dev); 1091 rt2x00lib_uninitialize(rt2x00dev);
1078 rt2x00debug_deregister(rt2x00dev); 1092 rt2x00debug_deregister(rt2x00dev);
1079 1093
1094exit:
1080 /* 1095 /*
1081 * Set device mode to sleep for power management. 1096 * Set device mode to sleep for power management.
1082 */ 1097 */
@@ -1094,7 +1109,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1094 int retval; 1109 int retval;
1095 1110
1096 NOTICE(rt2x00dev, "Waking up.\n"); 1111 NOTICE(rt2x00dev, "Waking up.\n");
1097 __set_bit(INTERFACE_RESUME, &rt2x00dev->flags); 1112 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1098 1113
1099 /* 1114 /*
1100 * Open the debugfs entry. 1115 * Open the debugfs entry.
@@ -1102,6 +1117,12 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1102 rt2x00debug_register(rt2x00dev); 1117 rt2x00debug_register(rt2x00dev);
1103 1118
1104 /* 1119 /*
1120 * Only continue if mac80211 has open interfaces.
1121 */
1122 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
1123 return 0;
1124
1125 /*
1105 * Reinitialize device and all active interfaces. 1126 * Reinitialize device and all active interfaces.
1106 */ 1127 */
1107 retval = rt2x00mac_start(rt2x00dev->hw); 1128 retval = rt2x00mac_start(rt2x00dev->hw);
@@ -1111,15 +1132,23 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1111 /* 1132 /*
1112 * Reconfigure device. 1133 * Reconfigure device.
1113 */ 1134 */
1114 retval = rt2x00mac_config(rt2x00dev->hw, &rt2x00dev->hw->conf); 1135 rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, 1);
1115 if (retval) 1136 if (!rt2x00dev->hw->conf.radio_enabled)
1116 goto exit; 1137 rt2x00lib_disable_radio(rt2x00dev);
1117 1138
1118 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac); 1139 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac);
1119 rt2x00lib_config_bssid(rt2x00dev, intf->bssid); 1140 rt2x00lib_config_bssid(rt2x00dev, intf->bssid);
1120 rt2x00lib_config_type(rt2x00dev, intf->type); 1141 rt2x00lib_config_type(rt2x00dev, intf->type);
1121 1142
1122 /* 1143 /*
1144 * It is possible that during that mac80211 has attempted
1145 * to send frames while we were suspending or resuming.
1146 * In that case we have disabled the TX queue and should
1147 * now enable it again
1148 */
1149 ieee80211_start_queues(rt2x00dev->hw);
1150
1151 /*
1123 * When in Master or Ad-hoc mode, 1152 * When in Master or Ad-hoc mode,
1124 * restart Beacon transmitting by faking a beacondone event. 1153 * restart Beacon transmitting by faking a beacondone event.
1125 */ 1154 */
@@ -1127,8 +1156,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1127 intf->type == IEEE80211_IF_TYPE_IBSS) 1156 intf->type == IEEE80211_IF_TYPE_IBSS)
1128 rt2x00lib_beacondone(rt2x00dev); 1157 rt2x00lib_beacondone(rt2x00dev);
1129 1158
1130 __clear_bit(INTERFACE_RESUME, &rt2x00dev->flags);
1131
1132 return 0; 1159 return 0;
1133 1160
1134exit: 1161exit:
@@ -1136,8 +1163,6 @@ exit:
1136 rt2x00lib_uninitialize(rt2x00dev); 1163 rt2x00lib_uninitialize(rt2x00dev);
1137 rt2x00debug_deregister(rt2x00dev); 1164 rt2x00debug_deregister(rt2x00dev);
1138 1165
1139 __clear_bit(INTERFACE_RESUME, &rt2x00dev->flags);
1140
1141 return retval; 1166 return retval;
1142} 1167}
1143EXPORT_SYMBOL_GPL(rt2x00lib_resume); 1168EXPORT_SYMBOL_GPL(rt2x00lib_resume);