r8169: make use of the unaligned access helpers
Heiner Kallweit
maintainerPATCH 1/1 r8169: make use of the unaligned access helpers
Instead of open-coding unaligned access let's use the predefined unaligned access helpers.
Signed-off-by Heiner Kallweit <[email protected]>
--- drivers/net/ethernet/realtek/r8169_main.c | 35 +++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +13 -22
@@ -28,6 +28,7 @@#include <linux/bitfield.h> #include <linux/prefetch.h> #include <linux/ipv6.h> +#include <asm/unaligned.h> #include <net/ip6_checksum.h> #include "r8169.h"
@@ -2074,18 +2075,12 @@ static void rtl8125b_config_eee_mac(struct rtl8169_private *tp)r8168_mac_ocp_modify (tp,0xe040 ,0 ,BIT (1 ) |BIT (0 )); } -static void rtl_rar_exgmac_set (struct rtl8169_private *tp,u8 *addr) +static void rtl_rar_exgmac_set (struct rtl8169_private *tp,const u8 *addr) { -const u16 w[] = { - addr[0 ] | (addr[1 ] <<8 ), - addr[2 ] | (addr[3 ] <<8 ), - addr[4 ] | (addr[5 ] <<8 ) - }; - -rtl_eri_write (tp,0xe0 ,ERIAR_MASK_1111 , w[0 ] | (w[1 ] <<16 )); -rtl_eri_write (tp,0xe4 ,ERIAR_MASK_1111 , w[2 ]); -rtl_eri_write (tp,0xf0 ,ERIAR_MASK_1111 , w[0 ] <<16 ); -rtl_eri_write (tp,0xf4 ,ERIAR_MASK_1111 , w[1 ] | (w[2 ] <<16 )); +rtl_eri_write (tp,0xe0 ,ERIAR_MASK_1111 ,get_unaligned_le32 (addr)); +rtl_eri_write (tp,0xe4 ,ERIAR_MASK_1111 ,get_unaligned_le16 (addr +4 )); +rtl_eri_write (tp,0xf0 ,ERIAR_MASK_1111 ,get_unaligned_le16 (addr) <<16 ); +rtl_eri_write (tp,0xf4 ,ERIAR_MASK_1111 ,get_unaligned_le32 (addr +2 )); }u16 rtl8168h_2_get_adc_bias_ioffset (struct rtl8169_private *tp)
@@ -2135,14 +2130,14 @@ static void rtl8169_init_phy(struct rtl8169_private *tp)genphy_soft_reset (tp->phydev); } -static void rtl_rar_set (struct rtl8169_private *tp,u8 *addr) +static void rtl_rar_set (struct rtl8169_private *tp,const u8 *addr) {rtl_unlock_config_regs (tp); -RTL_W32 (tp,MAC4 , addr[4 ] | addr[5 ] <<8 ); +RTL_W32 (tp,MAC4 ,get_unaligned_le16 (addr +4 ));rtl_pci_commit (tp); -RTL_W32 (tp,MAC0 , addr[0 ] | addr[1 ] <<8 | addr[2 ] <<16 | addr[3 ] <<24 ); +RTL_W32 (tp,MAC0 ,get_unaligned_le32 (addr));rtl_pci_commit (tp);if (tp->mac_version ==RTL_GIGA_MAC_VER_34 )
@@ -4965,16 +4960,12 @@ static void rtl_read_mac_address(struct rtl8169_private *tp, {/* Get MAC address */ if (rtl_is_8168evl_up (tp) && tp->mac_version !=RTL_GIGA_MAC_VER_34 ) { -u32 value =rtl_eri_read (tp,0xe0 ); - - mac_addr[0 ] = (value >>0 ) &0xff ; - mac_addr[1 ] = (value >>8 ) &0xff ; - mac_addr[2 ] = (value >>16 ) &0xff ; - mac_addr[3 ] = (value >>24 ) &0xff ; +u32 value; + value =rtl_eri_read (tp,0xe0 ); +put_unaligned_le32 (value, mac_addr); value =rtl_eri_read (tp,0xe4 ); - mac_addr[4 ] = (value >>0 ) &0xff ; - mac_addr[5 ] = (value >>8 ) &0xff ; +put_unaligned_le16 (value, mac_addr +4 ); }else if (rtl_is_8125 (tp)) {rtl_read_mac_from_reg (tp, mac_addr,MAC0_BKP ); }
Signature · 1 line
2.29.2
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 7 lines · On Sat, 9 Jan 2021 23:53:26 +0100 you wrote:
Instead of open-coding unaligned access let's use the predefined unaligned access helpers.
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 35 +++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-)
Here is the summary with links:
- [net-next] r8169: make use of the unaligned access helpers
https://git.kernel.org/netdev/net-next/c/ae1e82c6b741
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html