From ff1c5674172c4d0a5c420b8b20e7db0bd20f71ff Mon Sep 17 00:00:00 2001 From: Boris Gjenero Date: Fri, 16 Dec 2011 00:09:28 +0000 Subject: Remove USB time sync code when there's no RTC. Without an RTC, Rockbox doesn't keep time. In that situation, USB time sync previously did nothing but reported success. After this change, the USB time sync request won't be recognized on those targets. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31319 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/timefuncs.c | 2 ++ firmware/include/timefuncs.h | 2 +- firmware/usbstack/usb_storage.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index af4b596dd0..cffdb3951a 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c @@ -105,6 +105,7 @@ int set_time(const struct tm *tm) #endif /* RTC */ } +#if CONFIG_RTC void set_day_of_week(struct tm *tm) { int y=tm->tm_year+1900; @@ -115,4 +116,5 @@ void set_day_of_week(struct tm *tm) if(m == 0 || m == 1) y--; tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7; } +#endif /* CONFIG_RTC */ diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h index b7e9be53c6..4c5f0fbb42 100644 --- a/firmware/include/timefuncs.h +++ b/firmware/include/timefuncs.h @@ -30,8 +30,8 @@ struct tm *get_time(void); int set_time(const struct tm *tm); #if CONFIG_RTC bool valid_time(const struct tm *tm); -#endif void set_day_of_week(struct tm *tm); +#endif #endif /* _TIMEFUNCS_H_ */ diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 4954c9272e..0b9e6a95db 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -31,7 +31,9 @@ /* Needed to get at the audio buffer */ #include "audio.h" #include "usb_storage.h" +#if CONFIG_RTC #include "timefuncs.h" +#endif /* For sector filter macro definitions */ #include "usb-target.h" @@ -299,7 +301,9 @@ static void send_command_result(void *data,int size); static void send_command_failed_result(void); static void send_block_data(void *data,int size); static void receive_block_data(void *data,int size); +#if CONFIG_RTC static void receive_time(void); +#endif static void fill_inquiry(IF_MD_NONVOID(int lun)); static void send_and_read_next(void); static bool ejected[NUM_DRIVES]; @@ -322,11 +326,14 @@ static enum { SENDING_RESULT, SENDING_FAILED_RESULT, RECEIVING_BLOCKS, +#if CONFIG_RTC RECEIVING_TIME, +#endif WAITING_FOR_CSW_COMPLETION_OR_COMMAND, WAITING_FOR_CSW_COMPLETION } state = WAITING_FOR_COMMAND; +#if CONFIG_RTC static void yearday_to_daymonth(int yd, int y, int *d, int *m) { static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -351,6 +358,7 @@ static void yearday_to_daymonth(int yd, int y, int *d, int *m) *d = yd+1; *m = i; } +#endif /* CONFIG_RTC */ static bool check_disk_present(IF_MD_NONVOID(int volume)) { @@ -491,7 +499,9 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) { (void)ep; struct command_block_wrapper* cbw = (void*)cbw_buffer; +#if CONFIG_RTC struct tm tm; +#endif logf("transfer result for ep %d/%d %X %d", ep,dir,status, length); switch(state) { @@ -654,6 +664,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) cur_sense_data.ascq=0; } break; +#if CONFIG_RTC case RECEIVING_TIME: tm.tm_year=(tb.transfer_buffer[0]<<8)+tb.transfer_buffer[1] - 1900; tm.tm_yday=(tb.transfer_buffer[2]<<8)+tb.transfer_buffer[3]; @@ -665,6 +676,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) set_time(&tm); send_csw(UMS_STATUS_GOOD); break; +#endif /* CONFIG_RTC */ } } @@ -1131,6 +1143,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) } break; +#if CONFIG_RTC case SCSI_WRITE_BUFFER: if(cbw->command_block[1]==1 /* mode = vendor specific */ && cbw->command_block[2]==0 /* buffer id = 0 */ @@ -1148,6 +1161,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) && cbw->command_block[9]==0) receive_time(); break; +#endif /* CONFIG_RTC */ default: logf("scsi unknown cmd %x",cbw->command_block[0x0]); @@ -1177,11 +1191,14 @@ static void send_command_failed_result(void) state = SENDING_FAILED_RESULT; } +#if CONFIG_RTC static void receive_time(void) { usb_drv_recv(ep_out, tb.transfer_buffer, 12); state = RECEIVING_TIME; } +#endif /* CONFIG_RTC */ + static void receive_block_data(void *data,int size) { usb_drv_recv(ep_out, data, size); -- cgit v1.2.3