From e1fb0b30c45df392be399bde73f633db01b566f2 Mon Sep 17 00:00:00 2001 From: Jani Paalijarvi Date: Thu, 28 Nov 2024 08:55:34 +0200 Subject: [PATCH] drivers/net/ksz9477.c: Check return values in init Check that writes to configuration registers success. Signed-off-by: Jani Paalijarvi --- drivers/net/ksz9477.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ksz9477.c b/drivers/net/ksz9477.c index 561536ea77..0cbd404c65 100644 --- a/drivers/net/ksz9477.c +++ b/drivers/net/ksz9477.c @@ -387,6 +387,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. */ @@ -394,6 +400,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 */ @@ -413,6 +425,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 @@ -426,6 +444,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;