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
This commit is contained in:
parent
6a032a2db1
commit
ff1c567417
3 changed files with 20 additions and 1 deletions
|
@ -105,6 +105,7 @@ int set_time(const struct tm *tm)
|
||||||
#endif /* RTC */
|
#endif /* RTC */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
void set_day_of_week(struct tm *tm)
|
void set_day_of_week(struct tm *tm)
|
||||||
{
|
{
|
||||||
int y=tm->tm_year+1900;
|
int y=tm->tm_year+1900;
|
||||||
|
@ -115,4 +116,5 @@ void set_day_of_week(struct tm *tm)
|
||||||
if(m == 0 || m == 1) y--;
|
if(m == 0 || m == 1) y--;
|
||||||
tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7;
|
tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ struct tm *get_time(void);
|
||||||
int set_time(const struct tm *tm);
|
int set_time(const struct tm *tm);
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
bool valid_time(const struct tm *tm);
|
bool valid_time(const struct tm *tm);
|
||||||
#endif
|
|
||||||
void set_day_of_week(struct tm *tm);
|
void set_day_of_week(struct tm *tm);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _TIMEFUNCS_H_ */
|
#endif /* _TIMEFUNCS_H_ */
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
/* Needed to get at the audio buffer */
|
/* Needed to get at the audio buffer */
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "usb_storage.h"
|
#include "usb_storage.h"
|
||||||
|
#if CONFIG_RTC
|
||||||
#include "timefuncs.h"
|
#include "timefuncs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* For sector filter macro definitions */
|
/* For sector filter macro definitions */
|
||||||
#include "usb-target.h"
|
#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_command_failed_result(void);
|
||||||
static void send_block_data(void *data,int size);
|
static void send_block_data(void *data,int size);
|
||||||
static void receive_block_data(void *data,int size);
|
static void receive_block_data(void *data,int size);
|
||||||
|
#if CONFIG_RTC
|
||||||
static void receive_time(void);
|
static void receive_time(void);
|
||||||
|
#endif
|
||||||
static void fill_inquiry(IF_MD_NONVOID(int lun));
|
static void fill_inquiry(IF_MD_NONVOID(int lun));
|
||||||
static void send_and_read_next(void);
|
static void send_and_read_next(void);
|
||||||
static bool ejected[NUM_DRIVES];
|
static bool ejected[NUM_DRIVES];
|
||||||
|
@ -322,11 +326,14 @@ static enum {
|
||||||
SENDING_RESULT,
|
SENDING_RESULT,
|
||||||
SENDING_FAILED_RESULT,
|
SENDING_FAILED_RESULT,
|
||||||
RECEIVING_BLOCKS,
|
RECEIVING_BLOCKS,
|
||||||
|
#if CONFIG_RTC
|
||||||
RECEIVING_TIME,
|
RECEIVING_TIME,
|
||||||
|
#endif
|
||||||
WAITING_FOR_CSW_COMPLETION_OR_COMMAND,
|
WAITING_FOR_CSW_COMPLETION_OR_COMMAND,
|
||||||
WAITING_FOR_CSW_COMPLETION
|
WAITING_FOR_CSW_COMPLETION
|
||||||
} state = WAITING_FOR_COMMAND;
|
} state = WAITING_FOR_COMMAND;
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
static void yearday_to_daymonth(int yd, int y, int *d, int *m)
|
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 };
|
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;
|
*d = yd+1;
|
||||||
*m = i;
|
*m = i;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
|
|
||||||
static bool check_disk_present(IF_MD_NONVOID(int volume))
|
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;
|
(void)ep;
|
||||||
struct command_block_wrapper* cbw = (void*)cbw_buffer;
|
struct command_block_wrapper* cbw = (void*)cbw_buffer;
|
||||||
|
#if CONFIG_RTC
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
#endif
|
||||||
|
|
||||||
logf("transfer result for ep %d/%d %X %d", ep,dir,status, length);
|
logf("transfer result for ep %d/%d %X %d", ep,dir,status, length);
|
||||||
switch(state) {
|
switch(state) {
|
||||||
|
@ -654,6 +664,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
cur_sense_data.ascq=0;
|
cur_sense_data.ascq=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#if CONFIG_RTC
|
||||||
case RECEIVING_TIME:
|
case RECEIVING_TIME:
|
||||||
tm.tm_year=(tb.transfer_buffer[0]<<8)+tb.transfer_buffer[1] - 1900;
|
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];
|
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);
|
set_time(&tm);
|
||||||
send_csw(UMS_STATUS_GOOD);
|
send_csw(UMS_STATUS_GOOD);
|
||||||
break;
|
break;
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,6 +1143,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
case SCSI_WRITE_BUFFER:
|
case SCSI_WRITE_BUFFER:
|
||||||
if(cbw->command_block[1]==1 /* mode = vendor specific */
|
if(cbw->command_block[1]==1 /* mode = vendor specific */
|
||||||
&& cbw->command_block[2]==0 /* buffer id = 0 */
|
&& 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)
|
&& cbw->command_block[9]==0)
|
||||||
receive_time();
|
receive_time();
|
||||||
break;
|
break;
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logf("scsi unknown cmd %x",cbw->command_block[0x0]);
|
logf("scsi unknown cmd %x",cbw->command_block[0x0]);
|
||||||
|
@ -1177,11 +1191,14 @@ static void send_command_failed_result(void)
|
||||||
state = SENDING_FAILED_RESULT;
|
state = SENDING_FAILED_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
static void receive_time(void)
|
static void receive_time(void)
|
||||||
{
|
{
|
||||||
usb_drv_recv(ep_out, tb.transfer_buffer, 12);
|
usb_drv_recv(ep_out, tb.transfer_buffer, 12);
|
||||||
state = RECEIVING_TIME;
|
state = RECEIVING_TIME;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
|
|
||||||
static void receive_block_data(void *data,int size)
|
static void receive_block_data(void *data,int size)
|
||||||
{
|
{
|
||||||
usb_drv_recv(ep_out, data, size);
|
usb_drv_recv(ep_out, data, size);
|
||||||
|
|
Loading…
Reference in a new issue