Leave "usb mode" when all LUNs are ejected again

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20139 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2009-02-28 15:16:54 +00:00
parent b6a1af2a9b
commit afedfcf44e
5 changed files with 24 additions and 42 deletions

View file

@ -115,9 +115,6 @@
#if defined(HAVE_USBSTACK)
#include "usb_core.h"
#endif
#ifdef USB_STORAGE
#include "usbstack/usb_storage.h"
#endif
/*---------------------------------------------------*/
/* SPECIAL DEBUG STUFF */
@ -2584,15 +2581,6 @@ static bool logf_usb_serial(void)
}
#endif
#if 0 && defined(HAVE_USBSTACK) && defined(USB_STORAGE)
static bool usb_reconnect(void)
{
splash(HZ, "Reconnect mass storage");
usb_storage_reconnect();
return false;
}
#endif
#if CONFIG_USBOTG == USBOTG_ISP1583
extern int dbg_usb_num_items(void);
extern char* dbg_usb_item(int selected_item, void *data, char *buffer, size_t buffer_len);

View file

@ -132,6 +132,7 @@ void usb_signal_transfer_completion(struct usb_transfer_completion_event_data* e
bool usb_driver_enabled(int driver);
bool usb_exclusive_storage(void); /* storage is available for usb */
#endif
int usb_release_exclusive_storage(void);
#ifdef USB_FIREWIRE_HANDLING
bool firewire_detect(void);

View file

@ -361,14 +361,9 @@ static void usb_thread(void)
break;
}
exclusive_storage_access = false;
#endif /* HAVE_USBSTACK */
num_acks_to_expect = usb_release_exclusive_storage();
/* Tell all threads that we are back in business */
num_acks_to_expect =
queue_broadcast(SYS_USB_DISCONNECTED, 0) - 1;
DEBUGF("USB extracted. Waiting for ack from %d threads...\n",
num_acks_to_expect);
break;
case SYS_USB_DISCONNECTED_ACK:
@ -657,6 +652,20 @@ bool usb_exclusive_storage(void)
}
#endif
int usb_release_exclusive_storage(void)
{
int num_acks_to_expect;
#ifdef HAVE_USBSTACK
exclusive_storage_access = false;
#endif /* HAVE_USBSTACK */
/* Tell all threads that we are back in business */
num_acks_to_expect =
queue_broadcast(SYS_USB_DISCONNECTED, 0) - 1;
DEBUGF("USB extracted. Waiting for ack from %d threads...\n",
num_acks_to_expect);
return num_acks_to_expect;
}
#ifdef HAVE_USB_POWER
bool usb_powered(void)
{

View file

@ -302,7 +302,6 @@ static bool check_disk_present(IF_MV_NONVOID(int volume))
#endif
}
#if 0
static void try_release_ata(void)
{
/* Check if there is a connected drive left. If not,
@ -317,10 +316,9 @@ static void try_release_ata(void)
}
if(canrelease) {
logf("scsi release ata");
usb_release_exclusive_ata();
usb_release_exclusive_storage();
}
}
#endif
#ifdef HAVE_HOTSWAP
void usb_storage_notify_hotswap(int volume,bool inserted)
@ -331,28 +329,14 @@ void usb_storage_notify_hotswap(int volume,bool inserted)
}
else {
ejected[volume] = true;
try_release_ata();
}
}
#endif
void usb_storage_reconnect(void)
{
int i;
if(usb_core_driver_enabled(USB_DRIVER_MASS_STORAGE)
&& usb_inserted()) {
for(i=0;i<NUM_VOLUMES;i++)
ejected[i] = !check_disk_present(IF_MV(i));
logf("%s", __func__);
}
}
/* called by usb_core_init() */
void usb_storage_init(void)
{
int i;
for(i=0;i<NUM_VOLUMES;i++) {
ejected[i] = !check_disk_present(IF_MV(i));
}
logf("usb_storage_init done");
}
@ -431,10 +415,10 @@ void usb_storage_init_connection(void)
#endif
usb_drv_recv(ep_out, tb.transfer_buffer, 1024);
int lun;
for(lun=0;lun<NUM_VOLUMES;lun++)
{
queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+0);
int i;
for(i=0;i<NUM_VOLUMES;i++) {
ejected[i] = !check_disk_present(IF_MV(i));
queue_broadcast(SYS_USB_LUN_LOCKED, (i<<16)+0);
}
}
@ -691,6 +675,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
#ifdef HAVE_HOTSWAP
if(storage_removable(lun) && !storage_present(lun)) {
ejected[lun] = true;
try_release_ata();
}
#endif
@ -893,6 +878,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
{
logf("scsi eject");
ejected[lun]=true;
try_release_ata();
}
}
}

View file

@ -35,7 +35,5 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req);
void usb_storage_notify_hotswap(int volume,bool inserted);
#endif
void usb_storage_reconnect(void);
#endif