From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759511AbbA3CC5 (ORCPT ); Thu, 29 Jan 2015 21:02:57 -0500 Received: from mail-oi0-f53.google.com ([209.85.218.53]:35545 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758757AbbA3CC4 (ORCPT ); Thu, 29 Jan 2015 21:02:56 -0500 Message-ID: <54CAE64D.2040703@lwfinger.net> Date: Thu, 29 Jan 2015 20:02:53 -0600 From: Larry Finger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Heba Aamer , devel@driverdev.osuosl.org CC: florian.c.schilhabel@googlemail.com, gregkh@linuxfoundation.org, tapaswenipathak@gmail.com, thomas@grouk.net, sudipm.mukherjee@gmail.com, rickard_strandqvist@spectrumdigital.se, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] staging: rtl8712: fix Prefer ether_addr_copy() over memcpy() References: <20150129221136.GA22253@mohammed-Inspiron-3537> In-Reply-To: <20150129221136.GA22253@mohammed-Inspiron-3537> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/29/2015 04:11 PM, Heba Aamer wrote: > 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. > > Signed-off-by: Heba Aamer > --- > v2: modifying patch description > > drivers/staging/rtl8712/usb_intf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) This is much better. Acked-by: Larry Finger Larry > > diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c > index 15f0d42..a2f2dfb 100644 > --- a/drivers/staging/rtl8712/usb_intf.c > +++ b/drivers/staging/rtl8712/usb_intf.c > @@ -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)) >