From a56f1ca1ed63b93eb61fd5319f47347b3eb1e364 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sat, 17 Aug 2013 12:18:22 -0400 Subject: Cleanup MV/MD macros a little. When using variadic macros there's no need for IF_MD2/IF_MV2 to deal with function parameters. IF_MD/IF_MV are enough. Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0 if not. Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb --- firmware/common/dir_uncached.c | 4 ++-- firmware/common/dircache.c | 10 +++++----- firmware/common/disk.c | 8 ++++---- firmware/common/file.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'firmware/common') diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c index 14c8522822..b850a514e7 100644 --- a/firmware/common/dir_uncached.c +++ b/firmware/common/dir_uncached.c @@ -95,7 +95,7 @@ DIR_UNCACHED* opendir_uncached(const char* name) strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */ #endif - if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) { + if ( fat_opendir(IF_MV(volume,) &pdir->fatdir, 0, NULL) < 0 ) { DEBUGF("Failed opening root dir\n"); pdir->busy = false; return NULL; @@ -122,7 +122,7 @@ DIR_UNCACHED* opendir_uncached(const char* name) * as the parent directory and the resulting one (this is safe, * in doubt, check fat_open(dir) code) which will allow this kind of * (ugly) things */ - if ( fat_opendir(IF_MV2(volume,) + if ( fat_opendir(IF_MV(volume,) &pdir->fatdir, entry.firstcluster, &pdir->fatdir) < 0 ) { diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 21ae71fd5d..b53fc4d7a6 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -303,7 +303,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce sab.dir->entrycount = 0; sab.dir->file.firstcluster = 0; /* open directory */ - int rc = fat_opendir(IF_MV2(sab.volume,) sab.dir, startcluster, sab.dir); + int rc = fat_opendir(IF_MV(sab.volume,) sab.dir, startcluster, sab.dir); if(rc < 0) { logf("fat_opendir failed: %d", rc); @@ -381,7 +381,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce /* used during the generation */ static struct fat_dir sab_fat_dir; -static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce) +static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce) { memset(ce, 0, sizeof(struct dircache_entry)); @@ -493,7 +493,7 @@ static int sab_process_dir(struct dircache_entry *ce) return 0; } -static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce) +static int dircache_scan_and_build(IF_MV(int volume,) struct dircache_entry *ce) { #ifdef HAVE_MULTIVOLUME (void) volume; @@ -786,9 +786,9 @@ static int dircache_do_rebuild(void) #endif cpu_boost(true); #ifdef HAVE_MULTIVOLUME - if (dircache_scan_and_build(IF_MV2(i,) append_position) < 0) + if (dircache_scan_and_build(IF_MV(i,) append_position) < 0) #else - if (dircache_scan_and_build(IF_MV2(0,) root_entry) < 0) + if (dircache_scan_and_build(IF_MV(0,) root_entry) < 0) #endif /* HAVE_MULTIVOLUME */ { logf("dircache_scan_and_build failed"); diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 1a7ddd9eb4..fb6daee174 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -90,7 +90,7 @@ struct partinfo* disk_init(IF_MD_NONVOID(int drive)) #endif unsigned char* sector = fat_get_sector_buffer(); - storage_read_sectors(IF_MD2(drive,) 0,1, sector); + storage_read_sectors(IF_MD(drive,) 0,1, sector); /* check that the boot sector is initialized */ if ( (sector[510] != 0x55) || (sector[511] != 0xaa)) { @@ -210,7 +210,7 @@ int disk_mount(int drive) for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) { - if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start * j)) + if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) { pinfo[i].start *= j; pinfo[i].size *= j; @@ -222,7 +222,7 @@ int disk_mount(int drive) } } #else - if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start)) + if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) { mounted++; vol_drive[volume] = drive; /* remember the drive for this volume */ @@ -234,7 +234,7 @@ int disk_mount(int drive) if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */ { /* try "superfloppy" mode */ DEBUGF("No partition found, trying to mount sector 0.\n"); - if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0)) + if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) { #ifdef MAX_LOG_SECTOR_SIZE disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume))/SECTOR_SIZE; diff --git a/firmware/common/file.c b/firmware/common/file.c index cfebd0622f..920eada84e 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -121,7 +121,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache) } long startcluster = _dircache_get_entry_startcluster(ce); - fat_open(IF_MV2(volume,) + fat_open(IF_MV(volume,) startcluster, &(file->fatfile), NULL); @@ -167,7 +167,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache) /* scan dir for name */ while ((entry = readdir_uncached(dir))) { if ( !strcasecmp(name, entry->d_name) ) { - fat_open(IF_MV2(dir->fatdir.file.volume,) + fat_open(IF_MV(dir->fatdir.file.volume,) entry->startcluster, &(file->fatfile), &(dir->fatdir)); -- cgit v1.2.3