From 8cfbd3604fac14f629244e521ad24ffa9938c790 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 10 Dec 2008 08:57:10 +0000 Subject: Use cookies for thread identification instead of pointers directly which gives a buffer against wrongly identifying a thread when the slot is recycled (which has been nagging me for awhile). A slot gets 255 uses before it repeats. Everything gets incompatible so a full update is required. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19377 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'firmware/drivers/ata.c') diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 00a7c3e19a..e3fa3e8958 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -71,7 +71,7 @@ #endif #ifdef ATA_DRIVER_CLOSE -static struct thread_entry *ata_thread_p = NULL; +static unsigned int ata_thread_id = 0; #endif #if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64 @@ -94,7 +94,8 @@ static void ata_lock_init(struct ata_lock *l) static void ata_lock_lock(struct ata_lock *l) { - struct thread_entry * const current = thread_get_current(); + struct thread_entry * const current = + thread_id_entry(THREAD_ID_CURRENT); if (current == l->thread) { @@ -1350,7 +1351,7 @@ int ata_init(void) last_disk_activity = current_tick; #ifdef ATA_DRIVER_CLOSE - ata_thread_p = + ata_thread_id = #endif create_thread(ata_thread, ata_stack, sizeof(ata_stack), 0, ata_thread_name @@ -1370,15 +1371,15 @@ int ata_init(void) #ifdef ATA_DRIVER_CLOSE void ata_close(void) { - struct thread_entry *thread = ata_thread_p; + unsigned int thread_id = ata_thread_id; - if (thread == NULL) + if (thread_id == 0) return; - ata_thread_p = NULL; + ata_thread_id = 0; queue_post(&ata_queue, Q_CLOSE, 0); - thread_wait(thread); + thread_wait(thread_id); } #endif /* ATA_DRIVER_CLOSE */ -- cgit v1.2.3