Re: [PATCH 4/5] staging: r8188eu: use helper to set broadcast address

Phillip Potter
2021-10-20T21:08:33Z

On Wed, Oct 20, 2021 at 09:54:00PM +0200, Martin Kaiser wrote:
> The eth_broadcast_addr helper assigns the broadcast address to an address
> array. Call this function instead of copying the address bytes manually.
>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> drivers/staging/r8188eu/core/rtw_mlme_ext.c | 13 +++++--------
> drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 3 +--
> 2 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> index b0dfafe526f7..7b372374e638 100644
> --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> @@ -3409,7 +3409,6 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack)
> unsigned char *mac;
> struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
> - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
> struct wifidirect_info *pwdinfo = &padapter->wdinfo;
> u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
> u16 wpsielen = 0, p2pielen = 0;
> @@ -3443,8 +3442,8 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack)
> memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN);
> } else {
> /* broadcast probe request frame */
> - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
> - memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN);
> + eth_broadcast_addr(pwlanhdr->addr1);
> + eth_broadcast_addr(pwlanhdr->addr3);
> }
> }
> memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
> @@ -4311,7 +4310,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
> struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
> struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
> - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
> struct wifidirect_info *pwdinfo = &padapter->wdinfo;
>
> pmgntframe = alloc_mgtxmitframe(pxmitpriv);
> @@ -4334,7 +4332,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
> fctrl = &pwlanhdr->frame_ctl;
> *(fctrl) = 0;
>
> - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
> + eth_broadcast_addr(pwlanhdr->addr1);
> memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
> memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
>
> @@ -4676,7 +4674,6 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
> struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
> int bssrate_len = 0;
> - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
>
> pmgntframe = alloc_mgtxmitframe(pxmitpriv);
> if (!pmgntframe)
> @@ -4702,8 +4699,8 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
> memcpy(pwlanhdr->addr3, da, ETH_ALEN);
> } else {
> /* broadcast probe request frame */
> - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
> - memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN);
> + eth_broadcast_addr(pwlanhdr->addr1);
> + eth_broadcast_addr(pwlanhdr->addr3);
> }
>
> memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
> index c5f9353fe3e6..14eed14a4c6a 100644
> --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
> +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
> @@ -226,14 +226,13 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength)
> struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
> struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
> struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
> - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
>
> pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
>
> fctrl = &pwlanhdr->frame_ctl;
> *(fctrl) = 0;
>
> - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
> + eth_broadcast_addr(pwlanhdr->addr1);
> memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN);
> memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
>
> --
> 2.20.1
>

Looks good.

Acked-by: Phillip Potter <phil@philpotter.co.uk>

Regards,
Phil