summaryrefslogtreecommitdiff
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-03-12 10:03:52 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-03-12 10:03:52 +0000
commit06a5299aff38ba25c7742ae6293c588e38445f8b (patch)
tree5f8c3121882ba9c8d6317d1ce7fb5a07d3a99f5c /firmware/drivers/fat.c
parent2f5a37de5c45333453169ffe0b90e0f380d1cd50 (diff)
downloadrockbox-06a5299aff38ba25c7742ae6293c588e38445f8b.tar.gz
rockbox-06a5299aff38ba25c7742ae6293c588e38445f8b.zip
Do some crackdown on kernel object reinitialization after they could be in use and use before initialization. For c200/e200: Be sure fat cache and ata locks are acquired in the proper order during hot swapping. Delay hotswap monitoring until after initial file mounting (address 2nd kobj concern + possible call of fat driver before init).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16636 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 9dd27cf72a..f3374fc4c4 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -172,6 +172,7 @@ struct bpb
172}; 172};
173 173
174static struct bpb fat_bpbs[NUM_VOLUMES]; /* mounted partition info */ 174static struct bpb fat_bpbs[NUM_VOLUMES]; /* mounted partition info */
175static bool initialized = false;
175 176
176static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)); 177static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb));
177static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb)); 178static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb));
@@ -202,6 +203,18 @@ static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE];
202static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; 203static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE];
203static struct mutex cache_mutex NOCACHEBSS_ATTR; 204static struct mutex cache_mutex NOCACHEBSS_ATTR;
204 205
206#ifdef HAVE_HOTSWAP
207void fat_lock(void)
208{
209 mutex_lock(&cache_mutex);
210}
211
212void fat_unlock(void)
213{
214 mutex_unlock(&cache_mutex);
215}
216#endif
217
205static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster) 218static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster)
206{ 219{
207#ifndef HAVE_MULTIVOLUME 220#ifndef HAVE_MULTIVOLUME
@@ -240,7 +253,11 @@ void fat_init(void)
240{ 253{
241 unsigned int i; 254 unsigned int i;
242 255
243 mutex_init(&cache_mutex); 256 if (!initialized)
257 {
258 initialized = true;
259 mutex_init(&cache_mutex);
260 }
244 261
245 /* mark the FAT cache as unused */ 262 /* mark the FAT cache as unused */
246 for(i = 0;i < FAT_CACHE_SIZE;i++) 263 for(i = 0;i < FAT_CACHE_SIZE;i++)