summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c12
-rw-r--r--firmware/export/usb.h1
-rw-r--r--firmware/usb.c21
-rw-r--r--firmware/usbstack/usb_storage.c30
-rw-r--r--firmware/usbstack/usb_storage.h2
5 files changed, 24 insertions, 42 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index e669a6a..b944ff3 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 9071359..ecbec3a 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 2ac56a9..fa7eef4 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 e769216..ed9efd6 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<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();
}
}
}
diff --git a/firmware/usbstack/usb_storage.h b/firmware/usbstack/usb_storage.h
index 8344419..c76cb89 100644
--- a/firmware/usbstack/usb_storage.h
+++ b/firmware/usbstack/usb_storage.h
@@ -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