From: Roland Vossen Date: Fri, 16 Sep 2011 19:27:59 +0000 (-0700) Subject: staging: brcm80211: fixed sparse endianness warnings on fullmac assoc pars X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c57d25025ddbcd41eb37044f82446dbda538e23b;p=openwrt%2Fstaging%2Fblogic.git staging: brcm80211: fixed sparse endianness warnings on fullmac assoc pars Structures that are sent to the dongle have been annotated. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky Lin Signed-off-by: Franky Lin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index e1d7c57482b8..c34cc7b315aa 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -462,20 +462,20 @@ struct brcmf_scan_results { }; /* used for association with a specific BSSID and chanspec list */ -struct brcmf_assoc_params { +struct brcmf_assoc_params_le { /* 00:00:00:00:00:00: broadcast scan */ u8 bssid[ETH_ALEN]; /* 0: all available channels, otherwise count of chanspecs in * chanspec_list */ - s32 chanspec_num; + __le32 chanspec_num; /* list of chanspecs */ - u16 chanspec_list[1]; + __le16 chanspec_list[1]; }; /* used for join with or without a specific bssid and channel list */ struct brcmf_join_params { - struct brcmf_ssid ssid; - struct brcmf_assoc_params params; + struct brcmf_ssid_le ssid_le; + struct brcmf_assoc_params_le params_le; }; /* size of brcmf_scan_results not including variable length array */ diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 2dced70ac2f3..67955d3d59d0 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -34,7 +34,7 @@ #include "wl_cfg80211.h" #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ - (sizeof(struct brcmf_assoc_params) - sizeof(u16)) + (sizeof(struct brcmf_assoc_params_le) - sizeof(u16)) static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; @@ -777,10 +777,7 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, u16 chanspec = 0; if (ch != 0) { - join_params->params.chanspec_num = 1; - join_params->params.chanspec_list[0] = ch; - - if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL) + if (ch <= CH_MAX_2G_CHANNEL) chanspec |= WL_CHANSPEC_BAND_2G; else chanspec |= WL_CHANSPEC_BAND_5G; @@ -789,19 +786,15 @@ static void brcmf_ch_to_chanspec(int ch, struct brcmf_join_params *join_params, chanspec |= WL_CHANSPEC_CTL_SB_NONE; *join_params_size += BRCMF_ASSOC_PARAMS_FIXED_SIZE + - join_params->params.chanspec_num * sizeof(u16); - - join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK; - join_params->params.chanspec_list[0] |= chanspec; - join_params->params.chanspec_list[0] = - cpu_to_le16(join_params->params.chanspec_list[0]); + sizeof(u16); - join_params->params.chanspec_num = - cpu_to_le32(join_params->params.chanspec_num); + chanspec |= (ch & WL_CHANSPEC_CHAN_MASK); + join_params->params_le.chanspec_list[0] = cpu_to_le16(chanspec); + join_params->params_le.chanspec_num = cpu_to_le32(1); WL_CONN("join_params->params.chanspec_list[0]= %#X," "channel %d, chanspec %#X\n", - join_params->params.chanspec_list[0], ch, chanspec); + chanspec, ch, chanspec); } } @@ -833,6 +826,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, s32 err = 0; s32 wsec = 0; s32 bcnprd; + struct brcmf_ssid ssid; WL_TRACE("Enter\n"); if (!check_sys_up(wiphy)) @@ -910,24 +904,24 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, memset(&join_params, 0, sizeof(struct brcmf_join_params)); /* SSID */ - join_params.ssid.SSID_len = - (params->ssid_len > 32) ? 32 : params->ssid_len; - memcpy(join_params.ssid.SSID, params->ssid, join_params.ssid.SSID_len); - join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); - join_params_size = sizeof(join_params.ssid); - brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); + ssid.SSID_len = min_t(u32, params->ssid_len, 32); + memcpy(ssid.SSID, params->ssid, ssid.SSID_len); + memcpy(join_params.ssid_le.SSID, params->ssid, ssid.SSID_len); + join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); + join_params_size = sizeof(join_params.ssid_le); + brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); /* BSSID */ if (params->bssid) { - memcpy(join_params.params.bssid, params->bssid, ETH_ALEN); - join_params_size = sizeof(join_params.ssid) + - BRCMF_ASSOC_PARAMS_FIXED_SIZE; + memcpy(join_params.params_le.bssid, params->bssid, ETH_ALEN); + join_params_size = sizeof(join_params.ssid_le) + + BRCMF_ASSOC_PARAMS_FIXED_SIZE; } else { - memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); + memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); } brcmf_update_prof(cfg_priv, NULL, - &join_params.params.bssid, WL_PROF_BSSID); + &join_params.params_le.bssid, WL_PROF_BSSID); /* Channel */ if (params->channel) { @@ -1244,6 +1238,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan = sme->channel; struct brcmf_join_params join_params; size_t join_params_size; + struct brcmf_ssid ssid; s32 err = 0; @@ -1299,19 +1294,19 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } memset(&join_params, 0, sizeof(join_params)); - join_params_size = sizeof(join_params.ssid); + join_params_size = sizeof(join_params.ssid_le); - join_params.ssid.SSID_len = - min(sizeof(join_params.ssid.SSID), sme->ssid_len); - memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len); - join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); - brcmf_update_prof(cfg_priv, NULL, &join_params.ssid, WL_PROF_SSID); + ssid.SSID_len = min_t(u32, sizeof(ssid.SSID), sme->ssid_len); + memcpy(&join_params.ssid_le.SSID, sme->ssid, ssid.SSID_len); + memcpy(&ssid.SSID, sme->ssid, ssid.SSID_len); + join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); + brcmf_update_prof(cfg_priv, NULL, &ssid, WL_PROF_SSID); - memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); + memcpy(join_params.params_le.bssid, ether_bcast, ETH_ALEN); - if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) + if (ssid.SSID_len < IEEE80211_MAX_SSID_LEN) WL_CONN("ssid \"%s\", len (%d)\n", - join_params.ssid.SSID, join_params.ssid.SSID_len); + ssid.SSID, ssid.SSID_len); brcmf_ch_to_chanspec(cfg_priv->channel, &join_params, &join_params_size);