summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-16 13:25:02 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-16 13:25:02 +0000
commit15d7077c3ad2b7e3bcacf61a04428784b11e418c (patch)
tree4912c6fa1155073289160e122a948905b4799f25 /firmware
parentf414fb1e22b33bd0f4d9692bcea3da337e6aff7a (diff)
downloadrockbox-15d7077c3ad2b7e3bcacf61a04428784b11e418c.tar.gz
rockbox-15d7077c3ad2b7e3bcacf61a04428784b11e418c.zip
Hotswap: Avoid mount race at startup and after returning from USB mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6479 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata_mmc.c52
-rw-r--r--firmware/export/ata_mmc.h3
-rw-r--r--firmware/usb.c6
3 files changed, 41 insertions, 20 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 5afb6ca8a1..aa333dba32 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -94,6 +94,7 @@ static struct mutex mmc_mutex;
static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
static const char mmc_thread_name[] = "mmc";
static struct event_queue mmc_queue;
+static bool mmc_monitor_enabled = false;
#endif
static bool initialized = false;
static bool new_mmc_circuit;
@@ -1033,6 +1034,11 @@ static void mmc_thread(void)
}
}
}
+
+void mmc_enable_monitoring(bool on)
+{
+ mmc_monitor_enabled = on;
+}
#endif /* #ifdef HAVE_HOTSWAP */
bool mmc_detect(void)
@@ -1050,6 +1056,9 @@ bool mmc_usb_active(int delayticks)
static void mmc_tick(void)
{
bool current_status;
+#ifndef HAVE_HOTSWAP
+ const bool mmc_monitor_enabled = true;
+#endif
if (new_mmc_circuit)
/* USB bridge activity is 0 on idle, ~527 on active */
@@ -1061,29 +1070,32 @@ static void mmc_tick(void)
last_usb_activity = current_tick;
usb_activity = current_status;
- current_status = mmc_detect();
- /* Only report when the status has changed */
- if (current_status != last_mmc_status)
- {
- last_mmc_status = current_status;
- countdown = 30;
- }
- else
+ if (mmc_monitor_enabled)
{
- /* Count down until it gets negative */
- if (countdown >= 0)
- countdown--;
-
- if (countdown == 0)
+ current_status = mmc_detect();
+ /* Only report when the status has changed */
+ if (current_status != last_mmc_status)
{
- if (current_status)
- {
- queue_broadcast(SYS_MMC_INSERTED, NULL);
- }
- else
+ last_mmc_status = current_status;
+ countdown = 30;
+ }
+ else
+ {
+ /* Count down until it gets negative */
+ if (countdown >= 0)
+ countdown--;
+
+ if (countdown == 0)
{
- queue_broadcast(SYS_MMC_EXTRACTED, NULL);
- card_info[1].initialized = false;
+ if (current_status)
+ {
+ queue_broadcast(SYS_MMC_INSERTED, NULL);
+ }
+ else
+ {
+ queue_broadcast(SYS_MMC_EXTRACTED, NULL);
+ card_info[1].initialized = false;
+ }
}
}
}
diff --git a/firmware/export/ata_mmc.h b/firmware/export/ata_mmc.h
index 8b5056bbd8..6f7fb2bdb5 100644
--- a/firmware/export/ata_mmc.h
+++ b/firmware/export/ata_mmc.h
@@ -45,5 +45,8 @@ unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
unsigned int size);
tCardInfo *mmc_card_info(int card_no);
bool mmc_usb_active(int delayticks);
+#ifdef HAVE_HOTSWAP
+void mmc_enable_monitoring(bool on);
+#endif
#endif
diff --git a/firmware/usb.c b/firmware/usb.c
index 6095bcd65e..4b76fe60be 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -194,7 +194,13 @@ static void usb_slave_mode(bool on)
panicf("ata: %d",rc);
}
+#if defined(HAVE_MMC) && defined(HAVE_HOTSWAP)
+ mmc_enable_monitoring(false);
rc = disk_mount_all();
+ mmc_enable_monitoring(true);
+#else
+ rc = disk_mount_all();
+#endif
if (rc <= 0) /* no partition */
panicf("mount: %d",rc);