Fixes Warning encounter this by applying checkpatch.pl against this file:
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses
are __aligned(2)

pahole output for respective structures:
- addr->sa_data
struct sockaddr {
        sa_family_t                sa_family;            /*     0     2 */
        char                       sa_data[14];          /*     2    14 */

        /* size: 16, cachelines: 1, members: 2 */
        /* last cacheline: 16 bytes */
};

- padapter->eeprompriv.mac_addr
struct _adapter {
        struct dvobj_priv          dvobjpriv;            /*     0    40 */
        struct mlme_priv           mlmepriv;             /*    40  1560 */
        /* --- cacheline 25 boundary (1600 bytes) --- */
        struct cmd_priv            cmdpriv;              /*  1600   136 */
        /* --- cacheline 27 boundary (1728 bytes) was 8 bytes ago --- */
        struct evt_priv            evtpriv;              /*  1736    96 */
        /* --- cacheline 28 boundary (1792 bytes) was 40 bytes ago --- */
        struct io_queue *          pio_queue;            /*  1832     8 */
        struct xmit_priv           xmitpriv;             /*  1840   912 */
        /* --- cacheline 43 boundary (2752 bytes) --- */
        struct recv_priv           recvpriv;             /*  2752  1088 */
        /* --- cacheline 60 boundary (3840 bytes) --- */
        struct sta_priv            stapriv;              /*  3840   672 */
        /* --- cacheline 70 boundary (4480 bytes) was 32 bytes ago --- */
        struct security_priv       securitypriv;         /*  4512  4816 */
        /* --- cacheline 145 boundary (9280 bytes) was 48 bytes ago --- */
        struct registry_priv       registrypriv;         /*  9328   968 */
        /* --- cacheline 160 boundary (10240 bytes) was 56 bytes ago --- */
        struct wlan_acl_pool       acl_list;             /* 10296  1536 */
        /* --- cacheline 184 boundary (11776 bytes) was 56 bytes ago --- */
        struct pwrctrl_priv        pwrctrlpriv;          /* 11832   224 */
        /* --- cacheline 188 boundary (12032 bytes) was 24 bytes ago --- */
        struct eeprom_priv         eeprompriv;           /* 12056   508 */
        ........
};

struct eeprom_priv {
        u8                         bautoload_fail_flag;  /*     0     1 */
        u8                         bempty;               /*     1     1 */
        u8                         sys_config;           /*     2     1 */
        u8                         mac_addr[6];          /*     3     6 */
        ......
};

- pnetdev->dev_addr
dev_addr is interface address infor from generic net_device structure
which is properly aligned and have some patches with this change as well.
"staging: rtl8712: fix Prefer ether_addr_copy() over memcpy()"
(sha1: 36e4d8826b317080e283e4edd08bf8d5ac706f38)

Signed-off-by: Jagan Teki <jt...@openedev.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: Larry Finger <larry.fin...@lwfinger.net>
Cc: Florian Schilhabel <florian.c.schilha...@googlemail.com>
---
Changes for v2:
        - Describe a changelog, to prove address are aligned.

 drivers/staging/rtl8712/os_intfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8712/os_intfs.c 
b/drivers/staging/rtl8712/os_intfs.c
index 6e776e5..0d27df6 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -181,7 +181,7 @@ static int r871x_net_set_mac_address(struct net_device 
*pnetdev, void *p)
        struct sockaddr *addr = p;
 
        if (padapter->bup == false)
-               memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
+               ether_addr_copy(pnetdev->dev_addr, addr->sa_data);
        return 0;
 }
 
@@ -395,8 +395,8 @@ static int netdev_open(struct net_device *pnetdev)
                        goto netdev_open_error;
                if (r8712_initmac == NULL)
                        /* Use the mac address stored in the Efuse */
-                       memcpy(pnetdev->dev_addr,
-                               padapter->eeprompriv.mac_addr, ETH_ALEN);
+                       ether_addr_copy(pnetdev->dev_addr,
+                                       padapter->eeprompriv.mac_addr);
                else {
                        /* We have to inform f/w to use user-supplied MAC
                         * address.
@@ -412,8 +412,8 @@ static int netdev_open(struct net_device *pnetdev)
                         * the eeprompriv.mac_addr should store the mac which
                         * users specify.
                         */
-                       memcpy(padapter->eeprompriv.mac_addr,
-                               pnetdev->dev_addr, ETH_ALEN);
+                       ether_addr_copy(padapter->eeprompriv.mac_addr,
+                                       pnetdev->dev_addr);
                }
                if (start_drv_threads(padapter) != _SUCCESS)
                        goto netdev_open_error;
-- 
1.9.1

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to