drivers/net/ksz9477.c: Check return values in init

Check that writes to configuration registers success.

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
This commit is contained in:
Jani Paalijarvi 2024-11-28 08:55:34 +02:00 committed by Xiang Xiao
parent 0641e6f287
commit e1fb0b30c4

View file

@ -387,6 +387,12 @@ int ksz9477_init(ksz9477_port_t master_port)
ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_AUTONEG_CONTROL,
&regval16, 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,
&regval16, 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;