Skip to content

Commit b77049f

Browse files
Li Zetaokuba-moo
authored andcommitted
ethernet: s2io: Use ether_addr_to_u64() to convert ethernet address
Use ether_addr_to_u64() to convert an Ethernet address into a u64 value, instead of directly calculating, as this is exactly what this function does. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 052059b commit b77049f

File tree

1 file changed

+5
-12
lines changed
  • drivers/net/ethernet/neterion

1 file changed

+5
-12
lines changed

drivers/net/ethernet/neterion/s2io.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5091,13 +5091,10 @@ static void do_s2io_restore_unicast_mc(struct s2io_nic *sp)
50915091
static int do_s2io_add_mc(struct s2io_nic *sp, u8 *addr)
50925092
{
50935093
int i;
5094-
u64 mac_addr = 0;
5094+
u64 mac_addr;
50955095
struct config_param *config = &sp->config;
50965096

5097-
for (i = 0; i < ETH_ALEN; i++) {
5098-
mac_addr <<= 8;
5099-
mac_addr |= addr[i];
5100-
}
5097+
mac_addr = ether_addr_to_u64(addr);
51015098
if ((0ULL == mac_addr) || (mac_addr == S2IO_DISABLE_MAC_ENTRY))
51025099
return SUCCESS;
51035100

@@ -5220,7 +5217,7 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p)
52205217
static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr)
52215218
{
52225219
struct s2io_nic *sp = netdev_priv(dev);
5223-
register u64 mac_addr = 0, perm_addr = 0;
5220+
register u64 mac_addr, perm_addr;
52245221
int i;
52255222
u64 tmp64;
52265223
struct config_param *config = &sp->config;
@@ -5230,12 +5227,8 @@ static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr)
52305227
* change on the device address registered with the OS. It will be
52315228
* at offset 0.
52325229
*/
5233-
for (i = 0; i < ETH_ALEN; i++) {
5234-
mac_addr <<= 8;
5235-
mac_addr |= addr[i];
5236-
perm_addr <<= 8;
5237-
perm_addr |= sp->def_mac_addr[0].mac_addr[i];
5238-
}
5230+
mac_addr = ether_addr_to_u64(addr);
5231+
perm_addr = ether_addr_to_u64(sp->def_mac_addr[0].mac_addr);
52395232

52405233
/* check if the dev_addr is different than perm_addr */
52415234
if (mac_addr == perm_addr)

0 commit comments

Comments
 (0)