diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2008-09-01 21:06:23 (GMT) |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-09-06 22:56:36 (GMT) |
commit | d1e2319414ea5218ba801163e4530ecf2dfcbf36 (patch) | |
tree | 78c74e4a7a154c267bfcc1812d3493f7d4f979c9 /common | |
parent | ee9536a28cb149bcb6c5dee9d08c62c91f4c72d2 (diff) | |
download | u-boot-fsl-qoriq-d1e2319414ea5218ba801163e4530ecf2dfcbf36.tar.xz |
rtc: allow rtc_set to return an error and use it in cmd_date
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_date.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/common/cmd_date.c b/common/cmd_date.c index 7511598..d6cd565 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -56,18 +56,30 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) rtc_reset (); } else { /* initialize tm with current time */ - rtc_get (&tm); - /* insert new date & time */ - if (mk_date (argv[1], &tm) != 0) { - puts ("## Bad date format\n"); - break; + rcode = rtc_get (&tm); + + if(!rcode) { + /* insert new date & time */ + if (mk_date (argv[1], &tm) != 0) { + puts ("## Bad date format\n"); + break; + } + /* and write to RTC */ + rcode = rtc_set (&tm); + if(rcode) + puts("## Set date failled\n"); + } else { + puts("## Get date failled\n"); } - /* and write to RTC */ - rtc_set (&tm); } /* FALL TROUGH */ case 1: /* get date & time */ - rtc_get (&tm); + rcode = rtc_get (&tm); + + if (rcode) { + puts("## Get date failled\n"); + break; + } printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, |