Skip to contentSkip to conversation

staging: rtl8712: fix Prefer ether_addr_copy() over memcpy()

PATCH In review Heba Aamer 2 participants 2 messages Jan 29, 2015 – Jan 30, 2015 Staging

lore
Share & tools
lore

Heba Aamer

author
#0 lore raw

PATCH v2 1/1 staging: rtl8712: fix Prefer ether_addr_copy() over memcpy()

This patch fixes the following checkpatch.pl warning:
Prefer ether_addr_copy() over memcpy()
if the Ethernet addresses are __aligned(2)

pahole showed that the struct used pnetdev->dev_addr is aligned to u16.

Moreover mac is a simple array, pdata is a pointer that starts from an even offset.

---
v2: modifying patch description

 drivers/staging/rtl8712/usb_intf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/usb_intf.c +2 -2
index 15f0d42..a2f2dfb 100644
@@ -463,7 +463,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
 				/* Use the mac address stored in the Efuse
 				 * offset = 0x12 for usb in efuse
 				 */
-				memcpy(mac, &pdata[0x12], ETH_ALEN);
+				ether_addr_copy(mac, &pdata[0x12]);
 			}
 			eeprom_CustomerID = pdata[0x52];
 			switch (eeprom_CustomerID) {
@@ -580,7 +580,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
 		} else
 			dev_info(&udev->dev,
 				"r8712u: MAC Address from efuse = %pM\n", mac);
-		memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
+		ether_addr_copy(pnetdev->dev_addr, mac);
 	}
 	/* step 6. Load the firmware asynchronously */
 	if (rtl871x_load_fw(padapter))
Signature · 1 line
1.7.9.5
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Heba Aamer

This patch fixes the following checkpatch.pl warning:
Prefer ether_addr_copy() over memcpy()
if the Ethernet addresses are __aligned(2)

pahole showed that the struct used pnetdev->dev_addr is aligned to u16.

Moreover mac is a simple array, pdata is a pointer that starts from an even offset.

Quoted 6 lines

---
v2: modifying patch description

  drivers/staging/rtl8712/usb_intf.c |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

This is much better.

Larry

Quoted 24 lines
drivers/staging/rtl8712/usb_intf.c +2 -2
index 15f0d42..a2f2dfb 100644
@@ -463,7 +463,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
  				/* Use the mac address stored in the Efuse
  				 * offset = 0x12 for usb in efuse
  				 */
-				memcpy(mac, &pdata[0x12], ETH_ALEN);
+				ether_addr_copy(mac, &pdata[0x12]);
  			}
  			eeprom_CustomerID = pdata[0x52];
  			switch (eeprom_CustomerID) {
@@ -580,7 +580,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
  		} else
  			dev_info(&udev->dev,
  				"r8712u: MAC Address from efuse = %pM\n", mac);
-		memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
+		ether_addr_copy(pnetdev->dev_addr, mac);
  	}
  	/* step 6. Load the firmware asynchronously */
  	if (rtl871x_load_fw(padapter))