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/export/ata.h | 6 +++--- firmware/export/fat.h | 8 ++++---- firmware/export/mmc.h | 6 +++--- firmware/export/mv.h | 29 +++++++++++++++-------------- firmware/export/nand.h | 6 +++--- firmware/export/ramdisk.h | 6 +++--- firmware/export/sd.h | 6 +++--- firmware/export/storage.h | 14 +++++++------- 8 files changed, 41 insertions(+), 40 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 41a2fd5c9f..0bcb144e63 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h @@ -39,8 +39,8 @@ bool ata_disk_is_active(void); int ata_soft_reset(void); int ata_init(void) STORAGE_INIT_ATTR; void ata_close(void); -int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int ata_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int ata_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); void ata_spin(void); #if (CONFIG_LED == LED_REAL) void ata_set_led_enabled(bool enabled); @@ -48,7 +48,7 @@ void ata_set_led_enabled(bool enabled); unsigned short* ata_get_identify(void); #ifdef STORAGE_GET_INFO -void ata_get_info(IF_MD2(int drive,) struct storage_info *info); +void ata_get_info(IF_MD(int drive,) struct storage_info *info); #endif #ifdef HAVE_HOTSWAP bool ata_removable(IF_MD_NONVOID(int drive)); diff --git a/firmware/export/fat.h b/firmware/export/fat.h index 15511076e2..a0d52acc35 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h @@ -101,16 +101,16 @@ extern void fat_unlock(void); extern void fat_init(void); extern int fat_get_bytes_per_sector(IF_MV_NONVOID(int volume)); -extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector); +extern int fat_mount(IF_MV(int volume,) IF_MD(int drive,) long startsector); extern int fat_unmount(int volume, bool flush); -extern void fat_size(IF_MV2(int volume,) /* public for info */ +extern void fat_size(IF_MV(int volume,) /* public for info */ unsigned long* size, unsigned long* free); extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */ extern int fat_create_dir(const char* name, struct fat_dir* newdir, struct fat_dir* dir); -extern int fat_open(IF_MV2(int volume,) +extern int fat_open(IF_MV(int volume,) long cluster, struct fat_file* ent, const struct fat_dir* dir); @@ -128,7 +128,7 @@ extern int fat_rename(struct fat_file* file, const unsigned char* newname, long size, int attr); -extern int fat_opendir(IF_MV2(int volume,) +extern int fat_opendir(IF_MV(int volume,) struct fat_dir *ent, unsigned long startcluster, const struct fat_dir *parent_dir); extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry); diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h index 8d20f81236..0d27e20a64 100644 --- a/firmware/export/mmc.h +++ b/firmware/export/mmc.h @@ -36,13 +36,13 @@ bool mmc_disk_is_active(void); int mmc_soft_reset(void); int mmc_init(void) STORAGE_INIT_ATTR; void mmc_close(void); -int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int mmc_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int mmc_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); void mmc_spin(void); int mmc_spinup_time(void); #ifdef STORAGE_GET_INFO -void mmc_get_info(IF_MD2(int drive,) struct storage_info *info); +void mmc_get_info(IF_MD(int drive,) struct storage_info *info); #endif #ifdef HAVE_HOTSWAP bool mmc_removable(IF_MD_NONVOID(int drive)); diff --git a/firmware/export/mv.h b/firmware/export/mv.h index b1d16a7267..b1c8a83008 100644 --- a/firmware/export/mv.h +++ b/firmware/export/mv.h @@ -27,27 +27,28 @@ /* FixMe: These macros are a bit nasty and perhaps misplaced here. We'll get rid of them once decided on how to proceed with multivolume. */ -/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */ +/* Drives are things like a disk, a card, a flash chip. They can have volumes + on them */ #ifdef HAVE_MULTIDRIVE -#define IF_MD(x) x /* optional drive parameter */ -#define IF_MD2(x,y) x,y /* same, for a list of arguments */ -#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */ +#define IF_MD(x...) x /* valist contents or empty */ +#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */ +#define IF_MD_DRV(d) d /* drive argument or '0' */ #else /* empty definitions if no multi-drive */ -#define IF_MD(x) -#define IF_MD2(x,y) -#define IF_MD_NONVOID(x) void +#define IF_MD(x...) +#define IF_MD_NONVOID(x...) void +#define IF_MD_DRV(d) 0 #endif /* Volumes mean things that have filesystems on them, like partitions */ #ifdef HAVE_MULTIVOLUME -#define IF_MV(x) x /* optional volume parameter */ -#define IF_MV2(x,y) x,y /* same, for a list of arguments */ -#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ +#define IF_MV(x...) x /* valist contents or empty */ +#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */ +#define IF_MV_VOL(v) v /* volume argument or '0' */ #else /* empty definitions if no multi-volume */ -#define IF_MV(x) -#define IF_MV2(x,y) -#define IF_MV_NONVOID(x) void +#define IF_MV(x...) +#define IF_MV_NONVOID(x...) void +#define IF_MV_VOL(v) 0 #endif -#endif +#endif /* __MV_H__ */ diff --git a/firmware/export/nand.h b/firmware/export/nand.h index 58751ab298..fe25c9b407 100644 --- a/firmware/export/nand.h +++ b/firmware/export/nand.h @@ -36,8 +36,8 @@ bool nand_disk_is_active(void); int nand_soft_reset(void); int nand_init(void) STORAGE_INIT_ATTR; void nand_close(void); -int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); #ifdef HAVE_STORAGE_FLUSH int nand_flush(void); #endif @@ -45,7 +45,7 @@ void nand_spin(void); int nand_spinup_time(void); /* ticks */ #ifdef STORAGE_GET_INFO -void nand_get_info(IF_MD2(int drive,) struct storage_info *info); +void nand_get_info(IF_MD(int drive,) struct storage_info *info); #endif long nand_last_disk_activity(void); diff --git a/firmware/export/ramdisk.h b/firmware/export/ramdisk.h index c478c78882..d79ac50836 100644 --- a/firmware/export/ramdisk.h +++ b/firmware/export/ramdisk.h @@ -35,14 +35,14 @@ bool ramdisk_disk_is_active(void); int ramdisk_soft_reset(void); int ramdisk_init(void) STORAGE_INIT_ATTR; void ramdisk_close(void); -int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int ramdisk_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int ramdisk_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); void ramdisk_spin(void); void ramdisk_sleepnow(void); int ramdisk_spinup_time(void); #ifdef STORAGE_GET_INFO -void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info); +void ramdisk_get_info(IF_MD(int drive,) struct storage_info *info); #endif long ramdisk_last_disk_activity(void); diff --git a/firmware/export/sd.h b/firmware/export/sd.h index 1c3c429508..a5942dde1e 100644 --- a/firmware/export/sd.h +++ b/firmware/export/sd.h @@ -42,13 +42,13 @@ bool sd_disk_is_active(void); int sd_soft_reset(void); int sd_init(void) STORAGE_INIT_ATTR; void sd_close(void); -int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); void sd_spin(void); int sd_spinup_time(void); /* ticks */ #ifdef STORAGE_GET_INFO -void sd_get_info(IF_MD2(int drive,) struct storage_info *info); +void sd_get_info(IF_MD(int drive,) struct storage_info *info); #endif #ifdef HAVE_HOTSWAP bool sd_removable(IF_MV_NONVOID(int drive)); diff --git a/firmware/export/storage.h b/firmware/export/storage.h index 6c875bc847..1793e385df 100644 --- a/firmware/export/storage.h +++ b/firmware/export/storage.h @@ -95,7 +95,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; } #define storage_get_identify() ata_get_identify() #ifdef STORAGE_GET_INFO - #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info) + #define storage_get_info(drive, info) ata_get_info(IF_MD(drive,) info) #endif #ifdef HAVE_HOTSWAP #define storage_removable(drive) ata_removable(IF_MD(drive)) @@ -121,7 +121,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; } #define storage_get_identify() sd_get_identify() #ifdef STORAGE_GET_INFO - #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info) + #define storage_get_info(drive, info) sd_get_info(IF_MD(drive,) info) #endif #ifdef HAVE_HOTSWAP #define storage_removable(drive) sd_removable(IF_MD(drive)) @@ -146,7 +146,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; } #define storage_get_identify() mmc_get_identify() #ifdef STORAGE_GET_INFO - #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info) + #define storage_get_info(drive, info) mmc_get_info(IF_MD(drive,) info) #endif #ifdef HAVE_HOTSWAP #define storage_removable(drive) mmc_removable(IF_MD(drive)) @@ -171,7 +171,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; } #define storage_get_identify() nand_get_identify() #ifdef STORAGE_GET_INFO - #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info) + #define storage_get_info(drive, info) nand_get_info(IF_MD(drive,) info) #endif #ifdef HAVE_HOTSWAP #define storage_removable(drive) nand_removable(IF_MD(drive)) @@ -196,7 +196,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; } #define storage_get_identify() ramdisk_get_identify() #ifdef STORAGE_GET_INFO - #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info) + #define storage_get_info(drive, info) ramdisk_get_info(IF_MD(drive,) info) #endif #ifdef HAVE_HOTSWAP #define storage_removable(drive) ramdisk_removable(IF_MD(drive)) @@ -231,6 +231,6 @@ bool storage_present(int drive); #endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/ -int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); -int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); +int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf); +int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf); #endif -- cgit v1.2.3