Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1218446 > unrolled thread
| Started by | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| First post | 2015-09-03 19:10 +0200 |
| Last post | 2015-09-06 04:20 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCHv2 18/19] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-03 19:10 +0200
Re: [PATCHv2 18/19] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-06 00:20 +0200
Re: [PATCHv2 18/19] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-06 02:50 +0200
[PATCHv2] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-06 04:20 +0200
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2015-09-03 19:10 +0200 |
| Subject | Re: [PATCHv2 18/19] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue |
| Message-ID | <q4Gbn-1nO-5@gated-at.bofh.it> |
On Tue, Aug 18, 2015 at 12:58:19PM -0400, Raphaël Beamonte wrote: > Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) You need to prove that they are aligned before I can take this patch :( -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Raphaël Beamonte <raphael.beamonte@gmail.com> |
|---|---|
| Date | 2015-09-06 00:20 +0200 |
| Message-ID | <q5tYu-55g-17@gated-at.bofh.it> |
| In reply to | #1218446 |
2015-09-03 13:00 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>: > You need to prove that they are aligned before I can take this patch :( Right! I looked at those structs using pahole. The structs used are net_device from include/linux/netdevice.h and sockaddr from include/linux/socket.h, in which we use the elements dev_addr and sa_data respectively. Using pahole, the output for both those elements in the structs are: unsigned char * dev_addr; /* 888 8 */ char sa_data[14]; /* 2 14 */ If I understand correctly how pahole is outputing the information and what a u16 alignment means in the struct, I should, for both those cases, have a multiple of 2 (sizeof(u16)) as first value in the comment following the line (first value being the position of the element in the struct, second value its size). So if I understood correctly, in both those cases, it's working: they're u16 aligned. Also, to be sure, I searched in the kernel sources and found multiple files that are currently using both those structs and ether_addr_copy: (line numbers are those for commit 34fca4b of your staging-testing tree) drivers/net/ethernet/broadcom/genet/bcmgenet.c (line 2957) drivers/net/ethernet/brocade/bna/bnad.c (line 3250) drivers/net/ethernet/emulex/benet/be_main.c (line 315) drivers/net/ethernet/ezchip/nps_enet.c (line 421) drivers/net/ethernet/ibm/ibmveth.c (line 1460) drivers/net/ethernet/intel/fm10k/fm10k_netdev.c (line 911) drivers/net/ethernet/intel/i40e/i40e_main.c (line 1518) drivers/net/ethernet/mellanox/mlx5/core/en_main.c (line 1796) drivers/net/usb/lan78xx.c (line 1777) drivers/staging/rtl8192e/rtl8192e/rtl_core.c (line 2285) drivers/staging/rtl8712/os_intfs.c (line 181) net/8021q/vlan_dev.c (line 338) net/batman-adv/soft-interface.c (line 140) net/dsa/slave.c (line 198) Given that information, it should be fine for that change in rtl8192u! But if I'm mistaken somewhere please tell me! Should I update my patch with those information in the changelog? If so, how verbose do you expect it to be? Thanks! -R -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2015-09-06 02:50 +0200 |
| Message-ID | <q5wjE-8h9-3@gated-at.bofh.it> |
| In reply to | #1219652 |
On Sat, Sep 05, 2015 at 06:16:16PM -0400, Raphaël Beamonte wrote: > 2015-09-03 13:00 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>: > > You need to prove that they are aligned before I can take this patch :( > > Right! > > I looked at those structs using pahole. The structs used are > net_device from include/linux/netdevice.h and sockaddr from > include/linux/socket.h, in which we use the elements dev_addr and > sa_data respectively. > > Using pahole, the output for both those elements in the structs are: > unsigned char * dev_addr; /* 888 8 */ > char sa_data[14]; /* 2 14 */ > > If I understand correctly how pahole is outputing the information and > what a u16 alignment means in the struct, I should, for both those > cases, have a multiple of 2 (sizeof(u16)) as first value in the > comment following the line (first value being the position of the > element in the struct, second value its size). So if I understood > correctly, in both those cases, it's working: they're u16 aligned. > > Also, to be sure, I searched in the kernel sources and found multiple > files that are currently using both those structs and ether_addr_copy: > (line numbers are those for commit 34fca4b of your staging-testing > tree) > drivers/net/ethernet/broadcom/genet/bcmgenet.c (line 2957) > drivers/net/ethernet/brocade/bna/bnad.c (line 3250) > drivers/net/ethernet/emulex/benet/be_main.c (line 315) > drivers/net/ethernet/ezchip/nps_enet.c (line 421) > drivers/net/ethernet/ibm/ibmveth.c (line 1460) > drivers/net/ethernet/intel/fm10k/fm10k_netdev.c (line 911) > drivers/net/ethernet/intel/i40e/i40e_main.c (line 1518) > drivers/net/ethernet/mellanox/mlx5/core/en_main.c (line 1796) > drivers/net/usb/lan78xx.c (line 1777) > drivers/staging/rtl8192e/rtl8192e/rtl_core.c (line 2285) > drivers/staging/rtl8712/os_intfs.c (line 181) > net/8021q/vlan_dev.c (line 338) > net/batman-adv/soft-interface.c (line 140) > net/dsa/slave.c (line 198) > > Given that information, it should be fine for that change in rtl8192u! > But if I'm mistaken somewhere please tell me! > Should I update my patch with those information in the changelog? Yes. > If so, how verbose do you expect it to be? Very :) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Raphaël Beamonte <raphael.beamonte@gmail.com> |
|---|---|
| Date | 2015-09-06 04:20 +0200 |
| Subject | [PATCHv2] staging: rtl8192u: r8192U_core: fix use ether_addr_copy() over memcpy() code style issue |
| Message-ID | <q5xIJ-1Zz-3@gated-at.bofh.it> |
| In reply to | #1219665 |
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) The values used are stored as dev_addr in net_device (declared in include/linux/netdevice.h) and sa_data in sockaddr (declared in include/linux/socket.h). Both these elements are u16 aligned as shown by using pahole (position must be a multiple of sizeof(u16)): unsigned char * dev_addr; /* 888 8 */ char sa_data[14]; /* 2 14 */ It is thus safe to use ether_addr_copy() instead of memcpy() for that call, as it is already done in multiple files in the Linux kernel sources: drivers/net/ethernet/broadcom/genet/bcmgenet.c drivers/net/ethernet/brocade/bna/bnad.c drivers/net/ethernet/emulex/benet/be_main.c drivers/net/ethernet/ezchip/nps_enet.c drivers/net/ethernet/ibm/ibmveth.c drivers/net/ethernet/intel/fm10k/fm10k_netdev.c drivers/net/ethernet/intel/i40e/i40e_main.c drivers/net/ethernet/mellanox/mlx5/core/en_main.c drivers/net/usb/lan78xx.c net/8021q/vlan_dev.c net/batman-adv/soft-interface.c net/dsa/slave.c Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com> --- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 76255cb..b143b36 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3469,7 +3469,7 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac) down(&priv->wx_sem); - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + ether_addr_copy(dev->dev_addr, addr->sa_data); schedule_work(&priv->reset_wq); up(&priv->wx_sem); -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web