From e25bcf32c374ebf4c46ec33466fdc9f025667199 Mon Sep 17 00:00:00 2001 From: Jani Paalijarvi Date: Thu, 28 Nov 2024 08:55:34 +0200 Subject: [PATCH] net: Minor error handling improvements arch/risc-v/src/mpfs/mpfs_ethernet.c and drivers/net/ksz9477.c Signed-off-by: Jani Paalijarvi --- arch/risc-v/src/mpfs/mpfs_ethernet.c | 4 ++++ drivers/net/ksz9477.c | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) 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 55f1d49eda6af..a07b9066e603a 100644 --- a/drivers/net/ksz9477.c +++ b/drivers/net/ksz9477.c @@ -728,6 +728,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. */ @@ -735,6 +741,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 */ @@ -754,6 +766,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 @@ -767,6 +785,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;