]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phylink: provide phylink_mac_implements_lpi()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 10 Feb 2025 10:36:44 +0000 (10:36 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 13 Feb 2025 02:20:04 +0000 (18:20 -0800)
Provide a helper to determine whether the MAC operations structure
implements the LPI operations, which will be used by both phylink and
DSA.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1thR9g-003vX6-4s@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phylink.c
include/linux/phylink.h

index 214b62fba991ed04063fa35061b57b5522bf86b4..6fbb5fd5b400d80e6264b55eacf9ad7224f982b4 100644 (file)
@@ -1957,8 +1957,7 @@ struct phylink *phylink_create(struct phylink_config *config,
                return ERR_PTR(-EINVAL);
        }
 
-       pl->mac_supports_eee_ops = mac_ops->mac_disable_tx_lpi &&
-                                  mac_ops->mac_enable_tx_lpi;
+       pl->mac_supports_eee_ops = phylink_mac_implements_lpi(mac_ops);
        pl->mac_supports_eee = pl->mac_supports_eee_ops &&
                               pl->config->lpi_capabilities &&
                               !phy_interface_empty(pl->config->lpi_interfaces);
index 898b00451bbfd294ca818cd52e7b1b0f10a8062a..0de78673172de7595c4961c188235031dcae84b3 100644 (file)
@@ -737,6 +737,18 @@ static inline int phylink_get_link_timer_ns(phy_interface_t interface)
        }
 }
 
+/**
+ * phylink_mac_implements_lpi() - determine if MAC implements LPI ops
+ * @ops: phylink_mac_ops structure
+ *
+ * Returns true if the phylink MAC operations structure indicates that the
+ * LPI operations have been implemented, false otherwise.
+ */
+static inline bool phylink_mac_implements_lpi(const struct phylink_mac_ops *ops)
+{
+       return ops && ops->mac_disable_tx_lpi && ops->mac_enable_tx_lpi;
+}
+
 void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
                                      unsigned int neg_mode, u16 bmsr, u16 lpa);
 void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,