Skip to contentSkip to conversation

cmd: date: Handle -ENOSYS return from dm_rtc_reset()

PATCH In review Marek Vasut 3 participants 3 messages Jul 11 – Jul 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: date: Handle -ENOSYS return from dm_rtc_reset()

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".

---
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(-)
cmd/date.c +1 -1
index 67cfaed0d48..8d15018253b 100644
@@ -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");
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Marek Vasut

cmd: date: Handle -ENOSYS return from dm_rtc_reset()

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".

Quoted 4 lines

cmd/date.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw
In reply to Marek Vasut
Quoted 8 lines · Marek Vasut

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".

[...]

Applied to u-boot/main, thanks!

[1/1] cmd: date: Handle -ENOSYS return from dm_rtc_reset()

      commit: bc61758cbce38921310f668854bb8047f06c8c01
Signature · 1 line
Tom