wl12xx: move some logic into wl12xx_init_vif_data
authorEliad Peller <eliad@wizery.com>
Wed, 5 Oct 2011 09:55:56 +0000 (11:55 +0200)
committerLuciano Coelho <coelho@ti.com>
Fri, 7 Oct 2011 05:32:47 +0000 (08:32 +0300)
Initialize the vif data according to the vif type

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/wl12xx/main.c

index 63871b46c0c136ca0966b17159e82f7ec4a868b1..effba53eb3f4b3b4a2018f54fdffe232ba50f2eb 100644 (file)
@@ -1854,20 +1854,52 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif)
        return WL12XX_INVALID_ROLE_TYPE;
 }
 
-static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif)
+static int wl12xx_init_vif_data(struct ieee80211_vif *vif)
 {
-       wlvif->bss_type = MAX_BSS_TYPE;
+       struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
+
+       /* make sure wlvif is zeroed */
+       memset(wlvif, 0, sizeof(*wlvif));
+
+       switch (ieee80211_vif_type_p2p(vif)) {
+       case NL80211_IFTYPE_P2P_CLIENT:
+               wlvif->p2p = 1;
+               /* fall-through */
+       case NL80211_IFTYPE_STATION:
+               wlvif->bss_type = BSS_TYPE_STA_BSS;
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               wlvif->bss_type = BSS_TYPE_IBSS;
+               break;
+       case NL80211_IFTYPE_P2P_GO:
+               wlvif->p2p = 1;
+               /* fall-through */
+       case NL80211_IFTYPE_AP:
+               wlvif->bss_type = BSS_TYPE_AP_BSS;
+               break;
+       default:
+               wlvif->bss_type = MAX_BSS_TYPE;
+               return -EOPNOTSUPP;
+       }
+
        wlvif->role_id = WL12XX_INVALID_ROLE_ID;
        wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID;
 
-       /* TODO: init union by type */
-       wlvif->sta.hlid = WL12XX_INVALID_LINK_ID;
-       wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID;
-       wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID;
+       if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
+           wlvif->bss_type == BSS_TYPE_IBSS) {
+               /* init sta/ibss data */
+               wlvif->sta.hlid = WL12XX_INVALID_LINK_ID;
+
+       } else {
+               /* init ap data */
+               wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID;
+               wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID;
+       }
 
        wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
        wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC;
        wlvif->rate_set = CONF_TX_RATE_MASK_BASIC;
+       return 0;
 }
 
 static int wl1271_op_add_interface(struct ieee80211_hw *hw,
@@ -1891,7 +1923,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
                ret = -EBUSY;
                goto out;
        }
-       wl12xx_init_vif_data(wlvif);
 
        /*
         * in some very corner case HW recovery scenarios its possible to
@@ -1903,26 +1934,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
                goto out;
        }
 
-       switch (ieee80211_vif_type_p2p(vif)) {
-       case NL80211_IFTYPE_P2P_CLIENT:
-               wlvif->p2p = 1;
-               /* fall-through */
-       case NL80211_IFTYPE_STATION:
-               wlvif->bss_type = BSS_TYPE_STA_BSS;
-               break;
-       case NL80211_IFTYPE_ADHOC:
-               wlvif->bss_type = BSS_TYPE_IBSS;
-               break;
-       case NL80211_IFTYPE_P2P_GO:
-               wlvif->p2p = 1;
-               /* fall-through */
-       case NL80211_IFTYPE_AP:
-               wlvif->bss_type = BSS_TYPE_AP_BSS;
-               break;
-       default:
-               ret = -EOPNOTSUPP;
+       ret = wl12xx_init_vif_data(vif);
+       if (ret < 0)
                goto out;
-       }
 
        role_type = wl12xx_get_role_type(wl, wlvif);
        if (role_type == WL12XX_INVALID_ROLE_TYPE) {