diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2025-01-10 07:05:15 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-01-14 11:44:19 +0100 |
commit | f2bc1c2655728ac00c35cfb992bdb3243ca17e7e (patch) | |
tree | 52d0f1e68e6add98375f9ac94d200d0cb6c30703 /drivers | |
parent | 7d66c74a171d6c667cbf36f4b6cf1cc98744a83c (diff) |
net: phy: introduce optional polling interface for PHY statistics
Add an optional polling interface for PHY statistics to simplify driver
implementation.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/phy/phy.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 508f3ae3240f..c008fe050245 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1442,6 +1442,23 @@ static int phy_enable_interrupts(struct phy_device *phydev) } /** + * phy_update_stats - Update PHY device statistics if supported. + * @phydev: Pointer to the PHY device structure. + * + * If the PHY driver provides an update_stats callback, this function + * invokes it to update the PHY statistics. If not, it returns 0. + * + * Return: 0 on success, or a negative error code if the callback fails. + */ +static int phy_update_stats(struct phy_device *phydev) +{ + if (!phydev->drv->update_stats) + return 0; + + return phydev->drv->update_stats(phydev); +} + +/** * phy_request_interrupt - request and enable interrupt for a PHY device * @phydev: target phy_device struct * @@ -1510,6 +1527,9 @@ static enum phy_state_work _phy_state_machine(struct phy_device *phydev) case PHY_RUNNING: err = phy_check_link_status(phydev); func = &phy_check_link_status; + + if (!err) + err = phy_update_stats(phydev); break; case PHY_CABLETEST: err = phydev->drv->cable_test_get_status(phydev, &finished); |