drivers: ethernet: phy: use kernel timepoint api

use kernel timepoint api.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2025-06-11 16:51:10 +02:00 committed by Dan Kalowsky
commit b0048e34cd

View file

@ -41,7 +41,7 @@ struct phy_mii_dev_data {
struct k_work_delayable autoneg_work; struct k_work_delayable autoneg_work;
bool gigabit_supported; bool gigabit_supported;
bool restart_autoneg; bool restart_autoneg;
uint32_t autoneg_timeout; k_timepoint_t autoneg_timeout;
#endif #endif
}; };
@ -213,7 +213,7 @@ static int update_link_state(const struct device *dev)
data->restart_autoneg = false; data->restart_autoneg = false;
/* We have to wait for the auto-negotiation process to complete */ /* We have to wait for the auto-negotiation process to complete */
data->autoneg_timeout = CONFIG_PHY_AUTONEG_TIMEOUT_MS / MII_AUTONEG_POLL_INTERVAL_MS; data->autoneg_timeout = sys_timepoint_calc(K_MSEC(CONFIG_PHY_AUTONEG_TIMEOUT_MS));
return -EINPROGRESS; return -EINPROGRESS;
} }
@ -245,7 +245,7 @@ static int check_autonegotiation_completion(const struct device *dev)
} }
if (!(bmsr_reg & MII_BMSR_AUTONEG_COMPLETE)) { if (!(bmsr_reg & MII_BMSR_AUTONEG_COMPLETE)) {
if (data->autoneg_timeout-- == 0U) { if (sys_timepoint_expired(data->autoneg_timeout)) {
LOG_DBG("PHY (%d) auto-negotiate timedout", cfg->phy_addr); LOG_DBG("PHY (%d) auto-negotiate timedout", cfg->phy_addr);
return -ETIMEDOUT; return -ETIMEDOUT;
} }