r8168: refresh patches

Fixes: #9480
This commit is contained in:
AmadeusGhost 2022-05-24 23:40:20 +08:00 committed by AmadeusGhost
parent 78b1611182
commit 98f703f4b1
2 changed files with 42 additions and 92 deletions

View File

@ -1,50 +0,0 @@
--- a/src/r8168_n.c 2021-07-05 01:30:48.000000000 +0100
+++ b/src/r8168_n.c 2022-02-02 09:13:11.165555448 +0000
@@ -96,6 +96,10 @@
#include <linux/seq_file.h>
#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0))
+#define PDE_DATA pde_data
+#endif
+
#define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw"
#define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw"
#define FIRMWARE_8168E_1 "rtl_nic/rtl8168e-1.fw"
@@ -524,6 +528,12 @@
MODULE_VERSION(RTL8168_VERSION);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
+static inline void dev_addr_mod(struct net_device *dev, unsigned int offset, const void *addr, size_t len) {
+ memcpy(&dev->dev_addr[offset], addr, len);
+}
+#endif
+
static void rtl8168_sleep_rx_enable(struct net_device *dev);
static void rtl8168_dsm(struct net_device *dev, int dev_state);
@@ -24146,11 +24156,13 @@
}
rtl8168_rar_set(tp, mac_addr);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
for (i = 0; i < MAC_ADDR_LEN; i++) {
dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
tp->org_mac_addr[i] = dev->dev_addr[i]; /* keep the original MAC address */
}
+#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
#endif
@@ -24178,9 +24190,9 @@
return -EADDRNOTAVAIL;
spin_lock_irqsave(&tp->lock, flags);
-
- memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+ dev_addr_mod(dev, 0, addr->sa_data, dev->addr_len);
+ /* memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);*/
rtl8168_rar_set(tp, dev->dev_addr);

View File

@ -1,42 +1,42 @@
--- a/src/r8168_n.c --- a/src/r8168_n.c
+++ b/src/r8168_n.c +++ b/src/r8168_n.c
@@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mii.h> #include <linux/mii.h>
+#include <linux/of.h> +#include <linux/of.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
@@ -23482,6 +23483,22 @@ rtl8168_set_bios_setting(struct net_devi @@ -24607,6 +24608,22 @@ rtl8168_set_bios_setting(struct net_devi
} }
} }
+static int rtl8168_led_configuration(struct rtl8168_private *tp) +static int rtl8168_led_configuration(struct rtl8168_private *tp)
+{ +{
+ u32 led_data; + u32 led_data;
+ int ret; + int ret;
+ +
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node, + ret = of_property_read_u32(tp->pci_dev->dev.of_node,
+ "realtek,led-data", &led_data); + "realtek,led-data", &led_data);
+ +
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
+ RTL_W16(tp, CustomLED, led_data); + RTL_W16(tp, CustomLED, led_data);
+ +
+ return 0; + return 0;
+} +}
+ +
static void static void
rtl8168_init_software_variable(struct net_device *dev) rtl8168_init_software_variable(struct net_device *dev)
{ {
@@ -24000,6 +24017,8 @@ rtl8168_init_software_variable(struct ne @@ -25169,6 +25186,8 @@ rtl8168_init_software_variable(struct ne
tp->NotWrMcuPatchCode = TRUE; tp->NotWrMcuPatchCode = TRUE;
} }
+ rtl8168_led_configuration(tp); + rtl8168_led_configuration(tp);
+ +
tp->NicCustLedValue = RTL_R16(tp, CustomLED); tp->NicCustLedValue = RTL_R16(tp, CustomLED);
rtl8168_get_hw_wol(dev); rtl8168_get_hw_wol(dev);