Skip to content

Commit

Permalink
net: Minor error handling improvements
Browse files Browse the repository at this point in the history
arch/risc-v/src/mpfs/mpfs_ethernet.c and drivers/net/ksz9477.c

Signed-off-by: Jani Paalijarvi <[email protected]>
  • Loading branch information
jpaali committed Dec 20, 2024
1 parent 8fec8d1 commit a894081
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions drivers/net/ksz9477.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,25 @@ 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.
*/

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 */
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit a894081

Please sign in to comment.