Commit cf1239e5 authored by Hans de Goede's avatar Hans de Goede Committed by Kalle Valo

wifi: brcmfmac: Add brcmf_c_set_cur_etheraddr() helper

Add a little helper to send "cur_etheraddr" commands to the interface
and to handle the error reporting of it in a single place.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarArend van Spriel <aspriel@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220708133712.102179-1-hdegoede@redhat.com
parent 02a186f1
...@@ -190,6 +190,17 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) ...@@ -190,6 +190,17 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
return err; return err;
} }
int brcmf_c_set_cur_etheraddr(struct brcmf_if *ifp, const u8 *addr)
{
s32 err;
err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", addr, ETH_ALEN);
if (err < 0)
bphy_err(ifp->drvr, "Setting cur_etheraddr failed, %d\n", err);
return err;
}
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
{ {
struct brcmf_pub *drvr = ifp->drvr; struct brcmf_pub *drvr = ifp->drvr;
...@@ -204,12 +215,9 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) ...@@ -204,12 +215,9 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
if (is_valid_ether_addr(ifp->mac_addr)) { if (is_valid_ether_addr(ifp->mac_addr)) {
/* set mac address */ /* set mac address */
err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", ifp->mac_addr, err = brcmf_c_set_cur_etheraddr(ifp, ifp->mac_addr);
ETH_ALEN); if (err < 0)
if (err < 0) {
bphy_err(ifp->drvr, "Setting cur_etheraddr failed, %d\n", err);
goto done; goto done;
}
} else { } else {
/* retrieve mac address */ /* retrieve mac address */
err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr, err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
......
...@@ -65,6 +65,7 @@ void brcmf_release_module_param(struct brcmf_mp_device *module_param); ...@@ -65,6 +65,7 @@ void brcmf_release_module_param(struct brcmf_mp_device *module_param);
/* Sets dongle media info (drv_version, mac address). */ /* Sets dongle media info (drv_version, mac address). */
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp); int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
int brcmf_c_set_cur_etheraddr(struct brcmf_if *ifp, const u8 *addr);
#ifdef CONFIG_DMI #ifdef CONFIG_DMI
void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev); void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev);
......
...@@ -233,16 +233,12 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) ...@@ -233,16 +233,12 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr)
{ {
struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_if *ifp = netdev_priv(ndev);
struct sockaddr *sa = (struct sockaddr *)addr; struct sockaddr *sa = (struct sockaddr *)addr;
struct brcmf_pub *drvr = ifp->drvr;
int err; int err;
brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx); brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", sa->sa_data, err = brcmf_c_set_cur_etheraddr(ifp, sa->sa_data);
ETH_ALEN); if (err >= 0) {
if (err < 0) {
bphy_err(drvr, "Setting cur_etheraddr failed, %d\n", err);
} else {
brcmf_dbg(TRACE, "updated to %pM\n", sa->sa_data); brcmf_dbg(TRACE, "updated to %pM\n", sa->sa_data);
memcpy(ifp->mac_addr, sa->sa_data, ETH_ALEN); memcpy(ifp->mac_addr, sa->sa_data, ETH_ALEN);
eth_hw_addr_set(ifp->ndev, ifp->mac_addr); eth_hw_addr_set(ifp->ndev, ifp->mac_addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment