From afedfcf44ed004ddd73e613798fae16d9ebc7443 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 28 Feb 2009 15:16:54 +0000 Subject: Leave "usb mode" when all LUNs are ejected again git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20139 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 12 ------------ firmware/export/usb.h | 1 + firmware/usb.c | 21 +++++++++++++++------ firmware/usbstack/usb_storage.c | 30 ++++++++---------------------- firmware/usbstack/usb_storage.h | 2 -- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index e669a6a123..b944ff3aa1 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -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); diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 90713594a5..ecbec3a914 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -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); diff --git a/firmware/usb.c b/firmware/usb.c index 2ac56a9c15..fa7eef40d2 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -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) { diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index e769216a8d..ed9efd67c3 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -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