This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e1fb0b30c45df392be399bde73f633db01b566f2
Author: Jani Paalijarvi <[email protected]>
AuthorDate: Thu Nov 28 08:55:34 2024 +0200

    drivers/net/ksz9477.c: Check return values in init
    
    Check that writes to configuration registers success.
    
    Signed-off-by: Jani Paalijarvi <[email protected]>
---
 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,
                                          &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;

Reply via email to