In case dm_rtc_reset() returns -ENOSYS, it means the .reset callback
in RTC driver is not implemented, likely because the callback is not
needed. Handle the -ENOSYS return code as success and proceed, else
the 'date reset' invocation incorrectly prints a bogus warning:
"## Failed to set date after RTC reset".

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Alexander Feilke <[email protected]>
Cc: Alexander Sverdlin <[email protected]>
Cc: Markus Niebel <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Yao Zi <[email protected]>
Cc: [email protected]
---
 cmd/date.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/date.c b/cmd/date.c
index 67cfaed0d48..8d15018253b 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -44,7 +44,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
                if (strcmp(argv[1],"reset") == 0) {
                        puts ("Reset RTC...\n");
                        rcode = dm_rtc_reset(dev);
-                       if (!rcode)
+                       if (!rcode || rcode == -ENOSYS)
                                rcode = dm_rtc_set(dev, &default_tm);
                        if (rcode)
                                puts("## Failed to set date after RTC reset\n");
-- 
2.53.0

Reply via email to