diff --git a/arch/risc-v/src/mpfs/mpfs_ethernet.c b/arch/risc-v/src/mpfs/mpfs_ethernet.c index b985c7fedaf1c..5a3632a365ded 100644 --- a/arch/risc-v/src/mpfs/mpfs_ethernet.c +++ b/arch/risc-v/src/mpfs/mpfs_ethernet.c @@ -3390,6 +3390,10 @@ static int mpfs_phyinit(struct mpfs_ethmac_s *priv) { ret = ksz9477_i2c_init(bus, KSZ9477_PORT_SGMII); } + else + { + ret = -EINVAL; + } #endif diff --git a/drivers/net/ksz9477.c b/drivers/net/ksz9477.c index d33dff1552ab6..6fa14ca09ac13 100644 --- a/drivers/net/ksz9477.c +++ b/drivers/net/ksz9477.c @@ -729,6 +729,12 @@ int ksz9477_init(ksz9477_port_t master_port) ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_AUTONEG_CONTROL, ®val16, 1); + if (ret != OK) + { + nerr("Failed to set SGMII port into PHY mode, ret %d\n", ret); + return ret ? ret : -EINVAL; + } + /* Write to autonegotiation advertisement register activates the new * setting. Advertise only full duplex. */ @@ -736,6 +742,12 @@ int ksz9477_init(ksz9477_port_t master_port) regval16 = SGMII_AUTONEG_ADVERTISE_FD; ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_AUTONEG_ADVERTISE, ®val16, 1); + + if (ret != OK) + { + nerr("Failed to set autoneg, ret %d\n", ret); + return ret ? ret : -EINVAL; + } } /* Configure the static port-based VLANs */ @@ -755,6 +767,12 @@ int ksz9477_init(ksz9477_port_t master_port) g_port_vlan_config[i]); } + if (ret != OK) + { + nerr("Failed to configure VLANs, ret %d\n", ret); + return ret ? ret : -EINVAL; + } + #endif #ifdef CONFIG_NET_KSZ9477_PORT_SNIFF @@ -768,6 +786,12 @@ int ksz9477_init(ksz9477_port_t master_port) g_port_mirror_config[i]); } + if (ret != OK) + { + nerr("Failed to configure sniffer port, ret %d\n", ret); + return ret ? ret : -EINVAL; + } + #endif return ret;