Check and if unknown display:
  lx2160a serdes: unknown hwconfig serdes1:split, ignored

Signed-off-by: Vincent Jardin <[email protected]>

---

Changes in v4:
- New patch

 board/nxp/lx2160a/serdes_split.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/board/nxp/lx2160a/serdes_split.c b/board/nxp/lx2160a/serdes_split.c
index 11bec35fd22..a8fbb278b3a 100644
--- a/board/nxp/lx2160a/serdes_split.c
+++ b/board/nxp/lx2160a/serdes_split.c
@@ -443,17 +443,23 @@ static const struct sd1_mode sd1_modes[] = {
        },
 };
 
-static const struct sd1_mode *sd1_mode_find(const char *name)
+static const struct sd1_mode *sd1_mode_findn(const char *name, size_t n)
 {
        int i;
 
        for (i = 0; i < ARRAY_SIZE(sd1_modes); i++)
-               if (!strcmp(sd1_modes[i].name, name))
+               if (strlen(sd1_modes[i].name) == n &&
+                   !strncmp(sd1_modes[i].name, name, n))
                        return &sd1_modes[i];
 
        return NULL;
 }
 
+static const struct sd1_mode *sd1_mode_find(const char *name)
+{
+       return sd1_mode_findn(name, strlen(name));
+}
+
 static void sd1_print_pcc(unsigned long base)
 {
        printf("PCCC=%08x PCCD=%08x PCCE=%08x",
@@ -503,6 +509,26 @@ static int sd1_enter(const struct sd1_mode *mode,
        return 0;
 }
 
+static void sd1_report_unknown(void)
+{
+       const char *arg, *comma, *eq;
+       size_t len, n;
+
+       arg = hwconfig_arg("serdes1", &len);
+       while (arg && len) {
+               comma = memchr(arg, ',', len);
+               n = comma ? comma - arg : len;
+               eq = memchr(arg, '=', n);
+               if (n && !sd1_mode_findn(arg, eq ? eq - arg : n))
+                       printf("lx2160a serdes: unknown hwconfig serdes1:%.*s, 
ignored\n",
+                              (int)n, arg);
+               if (!comma)
+                       break;
+               len -= n + 1;
+               arg = comma + 1;
+       }
+}
+
 /*
  *   setenv hwconfig serdes1:<mode>
  *
@@ -517,6 +543,8 @@ void lx2160a_serdes_apply_hwconfig(void)
        const struct sd1_mode *mode = NULL;
        int i;
 
+       sd1_report_unknown();
+
        for (i = 0; i < ARRAY_SIZE(sd1_modes); i++) {
                if (!hwconfig_sub("serdes1", sd1_modes[i].name))
                        continue;
-- 
2.43.0

Reply via email to