X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_date.c;h=751159847a487da0fd3c034d355417eed03ca646;hb=fa60edfc4c952626e048c0e065f654b3c1822fa5;hp=4648a0e6b054ecc642a623c5d59ac021f79d4953;hpb=0d4983930a3559be92452761cfa268ee9d0f2773;p=u-boot diff --git a/common/cmd_date.c b/common/cmd_date.c index 4648a0e6b0..751159847a 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -27,8 +27,9 @@ #include #include #include +#include -#if (CONFIG_COMMANDS & CFG_CMD_DATE) +DECLARE_GLOBAL_DATA_PTR; const char *weekdays[] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", @@ -40,22 +41,26 @@ int mk_date (char *, struct rtc_time *); int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - DECLARE_GLOBAL_DATA_PTR; struct rtc_time tm; int rcode = 0; + int old_bus; + + /* switch to correct I2C bus */ + old_bus = I2C_GET_BUS(); + I2C_SET_BUS(CFG_RTC_BUS_NUM); switch (argc) { case 2: /* set date & time */ if (strcmp(argv[1],"reset") == 0) { - printf ("Reset RTC...\n"); + puts ("Reset RTC...\n"); rtc_reset (); } else { /* initialize tm with current time */ rtc_get (&tm); /* insert new date & time */ if (mk_date (argv[1], &tm) != 0) { - printf ("## Bad date format\n"); - return 1; + puts ("## Bad date format\n"); + break; } /* and write to RTC */ rtc_set (&tm); @@ -70,11 +75,15 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) "unknown " : RELOC(weekdays[tm.tm_wday]), tm.tm_hour, tm.tm_min, tm.tm_sec); - return 0; + break; default: printf ("Usage:\n%s\n", cmdtp->usage); rcode = 1; } + + /* switch back to original I2C bus */ + I2C_SET_BUS(old_bus); + return rcode; } @@ -199,5 +208,3 @@ U_BOOT_CMD( " - with numeric argument: set the system date & time\n" " - with 'reset' argument: reset the RTC\n" ); - -#endif /* CFG_CMD_DATE */