summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/ata.c28
-rw-r--r--firmware/drivers/button.c7
2 files changed, 35 insertions, 0 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 2dca17512e..87dacc3ed0 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -59,6 +59,7 @@
59#define CMD_SECURITY_FREEZE_LOCK 0xF5 59#define CMD_SECURITY_FREEZE_LOCK 0xF5
60 60
61#define Q_SLEEP 0 61#define Q_SLEEP 0
62#define Q_CLOSE 1
62 63
63#define READ_TIMEOUT 5*HZ 64#define READ_TIMEOUT 5*HZ
64 65
@@ -66,6 +67,10 @@
66#define ATA_POWER_OFF_TIMEOUT 2*HZ 67#define ATA_POWER_OFF_TIMEOUT 2*HZ
67#endif 68#endif
68 69
70#ifdef ATA_DRIVER_CLOSE
71static struct thread_entry *ata_thread_p = NULL;
72#endif
73
69#if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64 74#if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64
70/* Hack - what's the deal with 5g? */ 75/* Hack - what's the deal with 5g? */
71struct ata_lock 76struct ata_lock
@@ -941,6 +946,11 @@ static void ata_thread(void)
941 call_ata_idle_notifys(false); 946 call_ata_idle_notifys(false);
942 last_disk_activity = current_tick - sleep_timeout + (HZ/2); 947 last_disk_activity = current_tick - sleep_timeout + (HZ/2);
943 break; 948 break;
949
950#ifdef ATA_DRIVER_CLOSE
951 case Q_CLOSE:
952 return;
953#endif
944 } 954 }
945 } 955 }
946} 956}
@@ -1307,6 +1317,9 @@ int ata_init(void)
1307 mutex_lock(&ata_mtx); /* Balance unlock below */ 1317 mutex_lock(&ata_mtx); /* Balance unlock below */
1308 1318
1309 last_disk_activity = current_tick; 1319 last_disk_activity = current_tick;
1320#ifdef ATA_DRIVER_CLOSE
1321 ata_thread_p =
1322#endif
1310 create_thread(ata_thread, ata_stack, 1323 create_thread(ata_thread, ata_stack,
1311 sizeof(ata_stack), 0, ata_thread_name 1324 sizeof(ata_stack), 0, ata_thread_name
1312 IF_PRIO(, PRIORITY_USER_INTERFACE) 1325 IF_PRIO(, PRIORITY_USER_INTERFACE)
@@ -1322,6 +1335,21 @@ int ata_init(void)
1322 return rc; 1335 return rc;
1323} 1336}
1324 1337
1338#ifdef ATA_DRIVER_CLOSE
1339void ata_close(void)
1340{
1341 struct thread_entry *thread = ata_thread_p;
1342
1343 if (thread == NULL)
1344 return;
1345
1346 ata_thread_p = NULL;
1347
1348 queue_post(&ata_queue, Q_CLOSE, 0);
1349 thread_wait(thread);
1350}
1351#endif /* ATA_DRIVER_CLOSE */
1352
1325#if (CONFIG_LED == LED_REAL) 1353#if (CONFIG_LED == LED_REAL)
1326void ata_set_led_enabled(bool enabled) 1354void ata_set_led_enabled(bool enabled)
1327{ 1355{
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 90ff800c88..74c5a97167 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -410,6 +410,13 @@ void button_init(void)
410 tick_add_task(button_tick); 410 tick_add_task(button_tick);
411} 411}
412 412
413#ifdef BUTTON_DRIVER_CLOSE
414void button_close(void)
415{
416 tick_remove_task(button_tick);
417}
418#endif /* BUTTON_DRIVER_CLOSE */
419
413#ifdef HAVE_LCD_BITMAP /* only bitmap displays can be flipped */ 420#ifdef HAVE_LCD_BITMAP /* only bitmap displays can be flipped */
414/* 421/*
415 * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder) 422 * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder)