diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-09-08 16:40:43 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-09-08 16:40:43 +0200 |
commit | d167945e4049406e8bc0c4f432ec97684b687242 (patch) | |
tree | da318591e46c6c705191d619ad2327ba7a5f541d | |
parent | 2f3125ad030c87d6ac7dfe1581876bb93e3226a6 (diff) |
backport: add some ethtool conversion functions
These weren't always exported, so we need them on some kernels.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | backport/compat/backport-4.10.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/backport/compat/backport-4.10.c b/backport/compat/backport-4.10.c index b4d7edea..4c8125fb 100644 --- a/backport/compat/backport-4.10.c +++ b/backport/compat/backport-4.10.c @@ -14,6 +14,30 @@ #include <linux/mii.h> #if LINUX_VERSION_IS_GEQ(4,6,0) +#if LINUX_VERSION_IS_LESS(4,7,0) +static bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, + const unsigned long *src) +{ + bool retval = true; + + /* TODO: following test will soon always be true */ + if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(ext); + + bitmap_zero(ext, __ETHTOOL_LINK_MODE_MASK_NBITS); + bitmap_fill(ext, 32); + bitmap_complement(ext, ext, __ETHTOOL_LINK_MODE_MASK_NBITS); + if (bitmap_intersects(ext, src, + __ETHTOOL_LINK_MODE_MASK_NBITS)) { + /* src mask goes beyond bit 31 */ + retval = false; + } + } + *legacy_u32 = src[0]; + return retval; +} +#endif + static u32 mii_get_an(struct mii_if_info *mii, u16 addr) { int advert; |