The protection settings (struct brcms_protection) have the same lifetime as struct brcms_c_info. Embed them directly instead of allocating them separately, removing one kzalloc()/kfree() pair and its OOM error path. Signed-off-by: Rosen Penev --- .../broadcom/brcm80211/brcmsmac/channel.c | 6 ++-- .../broadcom/brcm80211/brcmsmac/main.c | 31 +++++++------------ .../broadcom/brcm80211/brcmsmac/main.h | 2 +- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c index a5c1c4d45683..b4c575f8c0f6 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c @@ -312,13 +312,13 @@ brcms_c_set_country(struct brcms_cm_info *wlc_cm, struct brcms_c_info *wlc = wlc_cm->wlc; if ((wlc->pub->_n_enab & SUPPORT_11N) != - wlc->protection->nmode_user) + wlc->protection.nmode_user) brcms_c_set_nmode(wlc); brcms_c_stf_ss_update(wlc, &wlc->bandstate[BAND_2G_INDEX]); brcms_c_stf_ss_update(wlc, &wlc->bandstate[BAND_5G_INDEX]); - brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); + brcms_c_set_gmode(wlc, wlc->protection.gmode_user, false); return; } @@ -387,7 +387,7 @@ brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, if (ch->flags & IEEE80211_CHAN_NO_OFDM) brcms_c_set_gmode(wlc, GMODE_LEGACY_B, false); else - brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false); + brcms_c_set_gmode(wlc, wlc->protection.gmode_user, false); brcms_b_set_chanspec(wlc->hw, chanspec, !!(ch->flags & IEEE80211_CHAN_NO_IR), diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c index 2140feb86964..bd1880e3738f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c @@ -420,7 +420,6 @@ static void brcms_c_detach_mfree(struct brcms_c_info *wlc) kfree(wlc->bsscfg); kfree(wlc->pub); - kfree(wlc->protection); kfree(wlc->stf); kfree(wlc->corestate); kfree(wlc->hw); @@ -466,12 +465,6 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) goto fail; } - wlc->protection = kzalloc_obj(*wlc->protection, GFP_ATOMIC); - if (wlc->protection == NULL) { - *err = 1016; - goto fail; - } - wlc->stf = kzalloc_obj(*wlc->stf, GFP_ATOMIC); if (wlc->stf == NULL) { *err = 1017; @@ -3878,37 +3871,37 @@ void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) switch (idx) { case BRCMS_PROT_G_SPEC: - wlc->protection->_g = (bool) val; + wlc->protection._g = (bool) val; break; case BRCMS_PROT_G_OVR: - wlc->protection->g_override = (s8) val; + wlc->protection.g_override = (s8) val; break; case BRCMS_PROT_G_USER: - wlc->protection->gmode_user = (u8) val; + wlc->protection.gmode_user = (u8) val; break; case BRCMS_PROT_OVERLAP: - wlc->protection->overlap = (s8) val; + wlc->protection.overlap = (s8) val; break; case BRCMS_PROT_N_USER: - wlc->protection->nmode_user = (s8) val; + wlc->protection.nmode_user = (s8) val; break; case BRCMS_PROT_N_CFG: - wlc->protection->n_cfg = (s8) val; + wlc->protection.n_cfg = (s8) val; break; case BRCMS_PROT_N_CFG_OVR: - wlc->protection->n_cfg_override = (s8) val; + wlc->protection.n_cfg_override = (s8) val; break; case BRCMS_PROT_N_NONGF: - wlc->protection->nongf = (bool) val; + wlc->protection.nongf = (bool) val; break; case BRCMS_PROT_N_NONGF_OVR: - wlc->protection->nongf_override = (s8) val; + wlc->protection.nongf_override = (s8) val; break; case BRCMS_PROT_N_PAM_OVR: - wlc->protection->n_pam_override = (s8) val; + wlc->protection.n_pam_override = (s8) val; break; case BRCMS_PROT_N_OBSS: - wlc->protection->n_obss = (bool) val; + wlc->protection.n_obss = (bool) val; break; default: @@ -6800,7 +6793,7 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, if (use_rspec) /* use frame rate as rts rate */ rts_rspec = rspec; - else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) + else if (wlc->band->gmode && wlc->protection._g && !is_cck_rate(rspec)) /* Use 11Mbps as the g protection RTS target rate and fallback. * Use the brcms_basic_rate() lookup to find the best basic rate * under the target in case 11 Mbps is not Basic. diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h index 94966418b069..266fe7825042 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h @@ -549,7 +549,7 @@ struct brcms_c_info { s8 shortslot_override; bool include_legacy_erp; - struct brcms_protection *protection; + struct brcms_protection protection; s8 PLCPHdr_override; struct brcms_stf *stf; -- 2.56.0