rt2x00: Block all unsupported modes

It was possible for unsupported operating modes
to be accepted by the add_interface callback function.
This patch will block those modes until proper support
has been implemented for them.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Ivo van Doorn and committed by John W. Linville 0fc98039 8dbc1722

+36 -16
+36 -16
drivers/net/wireless/rt2x00/rt2x00mac.c
··· 203 203 !test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 204 204 return -ENODEV; 205 205 206 - /* 207 - * We don't support mixed combinations of sta and ap virtual 208 - * interfaces. We can only add this interface when the rival 209 - * interface count is 0. 210 - */ 211 - if ((conf->type == IEEE80211_IF_TYPE_AP && rt2x00dev->intf_sta_count) || 212 - (conf->type != IEEE80211_IF_TYPE_AP && rt2x00dev->intf_ap_count)) 213 - return -ENOBUFS; 206 + switch (conf->type) { 207 + case IEEE80211_IF_TYPE_AP: 208 + /* 209 + * We don't support mixed combinations of 210 + * sta and ap interfaces. 211 + */ 212 + if (rt2x00dev->intf_sta_count) 213 + return -ENOBUFS; 214 214 215 - /* 216 - * Check if we exceeded the maximum amount of supported interfaces. 217 - */ 218 - if ((conf->type == IEEE80211_IF_TYPE_AP && 219 - rt2x00dev->intf_ap_count >= rt2x00dev->ops->max_ap_intf) || 220 - (conf->type != IEEE80211_IF_TYPE_AP && 221 - rt2x00dev->intf_sta_count >= rt2x00dev->ops->max_sta_intf)) 222 - return -ENOBUFS; 215 + /* 216 + * Check if we exceeded the maximum amount 217 + * of supported interfaces. 218 + */ 219 + if (rt2x00dev->intf_ap_count >= rt2x00dev->ops->max_ap_intf) 220 + return -ENOBUFS; 221 + 222 + break; 223 + case IEEE80211_IF_TYPE_STA: 224 + case IEEE80211_IF_TYPE_IBSS: 225 + /* 226 + * We don't support mixed combinations of 227 + * sta and ap interfaces. 228 + */ 229 + if (rt2x00dev->intf_ap_count) 230 + return -ENOBUFS; 231 + 232 + /* 233 + * Check if we exceeded the maximum amount 234 + * of supported interfaces. 235 + */ 236 + if (rt2x00dev->intf_sta_count >= rt2x00dev->ops->max_sta_intf) 237 + return -ENOBUFS; 238 + 239 + break; 240 + default: 241 + return -EINVAL; 242 + } 223 243 224 244 /* 225 245 * Loop through all beacon queues to find a free