From 1f24cbbce59db74f7aeef2458d76ae209c753af4 Mon Sep 17 00:00:00 2001 From: bb-qq Date: Sun, 13 Dec 2020 16:26:01 +0900 Subject: [PATCH] Supported old platforms. --- compatibility.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ r8152.c | 8 ++++++ 2 files changed, 83 insertions(+) diff --git a/compatibility.h b/compatibility.h index cf63530..f623e92 100644 --- a/compatibility.h +++ b/compatibility.h @@ -52,15 +52,84 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) #define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN) + + // Added for old platforms + enum skb_free_reason { + SKB_REASON_CONSUMED, + SKB_REASON_DROPPED, + }; + static inline void dev_consume_skb_irq(struct sk_buff *skb) + { + dev_kfree_skb_irq(skb); + } + static inline void dev_consume_skb_any(struct sk_buff *skb) + { + dev_kfree_skb_any(skb); + } #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) #define BIT(nr) (1UL << (nr)) #define BIT_ULL(nr) (1ULL << (nr)) #define BITS_PER_BYTE 8 #define reinit_completion(x) ((x)->done = 0) + #if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) + // Added for old platforms + #ifndef DEVICE_ATTR_RO + #define DEVICE_ATTR_RO(_name) \ + struct device_attribute dev_attr_ ## _name = __ATTR_RO(_name); + #endif + #ifndef DEVICE_ATTR_RW + #define DEVICE_ATTR_RW(_name) \ + struct device_attribute dev_attr_ ## _name = __ATTR_RW(_name) + #endif + + #ifndef CLASS_ATTR_RW + #define CLASS_ATTR_RW(_name) \ + struct class_attribute class_attr_##_name = __ATTR_RW(_name) + #endif + #ifndef CLASS_ATTR_RO + #define CLASS_ATTR_RO(_name) \ + struct class_attribute class_attr_##_name = __ATTR_RO(_name) + #endif + #define ATTRIBUTE_GROUPS_BACKPORT(_name) \ + static struct BP_ATTR_GRP_STRUCT _name##_dev_attrs[ARRAY_SIZE(_name##_attrs)];\ + static void init_##_name##_attrs(void) \ + { \ + int i; \ + for (i = 0; _name##_attrs[i]; i++) \ + _name##_dev_attrs[i] = \ + *container_of(_name##_attrs[i], \ + struct BP_ATTR_GRP_STRUCT, \ + attr); \ + } + #ifndef __ATTRIBUTE_GROUPS + #define __ATTRIBUTE_GROUPS(_name) \ + static const struct attribute_group *_name##_groups[] = { \ + &_name##_group, \ + NULL, \ + } + #endif /* __ATTRIBUTE_GROUPS */ + #undef ATTRIBUTE_GROUPS + #define ATTRIBUTE_GROUPS(_name) \ + static const struct attribute_group _name##_group = { \ + .attrs = _name##_attrs, \ + }; \ + static inline void init_##_name##_attrs(void) {} \ + __ATTRIBUTE_GROUPS(_name) + + #define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) + #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) #define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX #define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX + + // Added for armadaxp and evansport + static inline void sg_unmark_end(struct scatterlist *sg) + { + sg->page_link &= ~0x02; + } + #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) #define USB_DEVICE_INTERFACE_CLASS(vend, prod, iclass) \ USB_DEVICE_AND_INTERFACE_INFO(vend, prod, iclass, 0xff, 0) @@ -81,6 +150,10 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) #define ETH_MDIO_SUPPORTS_C22 MDIO_SUPPORTS_C22 + // Added for armadaxp and evansport + #define skb_add_rx_frag(skb, i, page, off, size, truesize) \ + skb_add_rx_frag(skb, i, page, off, size) + #if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) #define module_usb_driver(__driver) \ static int __init __driver##_init(void) \ @@ -466,9 +539,11 @@ { return 0; } +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) */ + static inline int skb_to_sgvec_nomark(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) diff --git a/r8152.c b/r8152.c index fe1f8f3..393a53d 100644 --- a/r8152.c +++ b/r8152.c @@ -263,6 +263,9 @@ /* PLA_CR */ #define CR_RST 0x10 #define CR_RE 0x08 +#ifdef CR_TE +#undef CR_TE +#endif #define CR_TE 0x04 /* PLA_CRWECR */ @@ -1357,6 +1360,7 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p) return ret; } +#ifdef ACPI_TYPE_BUFFER static int rtl_mapt_read(struct r8152 *tp, char *mac_obj_name, acpi_object_type mac_obj_type, int mac_strlen, struct sockaddr *sa) @@ -1403,6 +1407,7 @@ static int rtl_mapt_read(struct r8152 *tp, char *mac_obj_name, kfree(obj); return ret; } +#endif /* Devices containing proper chips can support a persistent * host system provided MAC address. @@ -1412,6 +1417,7 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) { int ret = -EOPNOTSUPP; +#ifdef ACPI_TYPE_BUFFER if (tp->dell_macpassthru || tp->bl_macpassthru) { ret = rtl_mapt_read(tp, "\\_SB.AMAC", ACPI_TYPE_BUFFER, 0x17, sa); @@ -1423,6 +1429,8 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa) ret = rtl_mapt_read(tp, "\\MACA", ACPI_TYPE_STRING, 0x16, sa); out: +#endif + return ret; }