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) #if defined(HAVE_USBSTACK)
#include "usb_core.h" #include "usb_core.h"
#endif #endif
#ifdef USB_STORAGE
#include "usbstack/usb_storage.h"
#endif
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/* SPECIAL DEBUG STUFF */ /* SPECIAL DEBUG STUFF */
@ -2584,15 +2581,6 @@ static bool logf_usb_serial(void)
} }
#endif #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 #if CONFIG_USBOTG == USBOTG_ISP1583
extern int dbg_usb_num_items(void); extern int dbg_usb_num_items(void);
extern char* dbg_usb_item(int selected_item, void *data, char *buffer, size_t buffer_len); 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_driver_enabled(int driver);
bool usb_exclusive_storage(void); /* storage is available for usb */ bool usb_exclusive_storage(void); /* storage is available for usb */
#endif #endif
int usb_release_exclusive_storage(void);
#ifdef USB_FIREWIRE_HANDLING #ifdef USB_FIREWIRE_HANDLING
bool firewire_detect(void); bool firewire_detect(void);

View file

@ -361,14 +361,9 @@ static void usb_thread(void)
break; break;
} }
exclusive_storage_access = false;
#endif /* HAVE_USBSTACK */ #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; break;
case SYS_USB_DISCONNECTED_ACK: case SYS_USB_DISCONNECTED_ACK:
@ -657,6 +652,20 @@ bool usb_exclusive_storage(void)
} }
#endif #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 #ifdef HAVE_USB_POWER
bool usb_powered(void) bool usb_powered(void)
{ {

View file

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