kernel: add support for kernel 5.4
[openwrt/openwrt.git] / target / linux / generic / files / drivers / net / phy / ar8216.c
index 5ace4e0b15c82e3f948a410443a575f3f7b8e477..031efe61816c9b7bc3d01671bcb4f1e44c40dd48 100644 (file)
@@ -2487,7 +2487,9 @@ ar8xxx_phy_read_status(struct phy_device *phydev)
        struct switch_port_link link;
 
        /* check for switch port link changes */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
        if (phydev->state == PHY_CHANGELINK)
+#endif
                ar8xxx_check_link_states(priv);
 
        if (phydev->mdio.addr != 0)
@@ -2628,6 +2630,14 @@ found:
        priv->use_count++;
 
        if (phydev->mdio.addr == 0) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+               linkmode_zero(phydev->supported);
+               if (ar8xxx_has_gige(priv))
+                       linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);
+               else
+                       linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported);
+               linkmode_copy(phydev->advertising, phydev->supported);
+#else
                if (ar8xxx_has_gige(priv)) {
                        phydev->supported = SUPPORTED_1000baseT_Full;
                        phydev->advertising = ADVERTISED_1000baseT_Full;
@@ -2635,6 +2645,7 @@ found:
                        phydev->supported = SUPPORTED_100baseT_Full;
                        phydev->advertising = ADVERTISED_100baseT_Full;
                }
+#endif
 
                if (priv->chip->config_at_probe) {
                        priv->phy = phydev;
@@ -2645,8 +2656,14 @@ found:
                }
        } else {
                if (ar8xxx_has_gige(priv)) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+                       linkmode_zero(phydev->supported);
+                       linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);
+                       linkmode_copy(phydev->advertising, phydev->supported);
+#else
                        phydev->supported |= SUPPORTED_1000baseT_Full;
                        phydev->advertising |= ADVERTISED_1000baseT_Full;
+#endif
                }
                if (priv->chip->phy_rgmii_set)
                        priv->chip->phy_rgmii_set(priv, phydev);