Skip to content

Commit

Permalink
Supported old platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-qq committed Dec 13, 2020
1 parent 6a7b61b commit 1f24cbb
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
75 changes: 75 additions & 0 deletions compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) \
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit 1f24cbb

Please sign in to comment.