From ee7cf6c63c67222dcf9af6f40098428c577ee775 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 26 Nov 2009 00:51:09 +0000 Subject: [PATCH] Remove unused card_detect(), and make card_detect_target() static inline in each sd driver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23757 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/hotswap.h | 2 -- firmware/export/sd.h | 2 -- firmware/target/arm/as3525/ata_sd_as3525.c | 19 ++++++------ firmware/target/arm/ata-sd-pp.c | 29 ++++++++++--------- firmware/target/arm/s3c2440/sd-s3c2440.c | 27 +++++++---------- firmware/target/arm/tcc780x/sd-tcc780x.c | 11 ++++--- .../mips/ingenic_jz47xx/ata-sd-jz4740.c | 2 +- 7 files changed, 42 insertions(+), 50 deletions(-) diff --git a/firmware/export/hotswap.h b/firmware/export/hotswap.h index 455dee6bcc..643048976b 100644 --- a/firmware/export/hotswap.h +++ b/firmware/export/hotswap.h @@ -53,7 +53,6 @@ typedef struct #if (CONFIG_STORAGE & STORAGE_SD) #include "sd.h" -#define card_detect card_detect_target #define card_get_info card_get_info_target tCardInfo *card_get_info_target(int card_no); void sd_parse_csd(tCardInfo *card); @@ -65,7 +64,6 @@ void sd_parse_csd(tCardInfo *card); #else /* STORAGE_MMC */ #include "ata_mmc.h" -#define card_detect mmc_detect #define card_get_info mmc_card_info tCardInfo *mmc_card_info(int card_no); #define card_touched mmc_touched diff --git a/firmware/export/sd.h b/firmware/export/sd.h index c12546562e..1c61364566 100644 --- a/firmware/export/sd.h +++ b/firmware/export/sd.h @@ -51,8 +51,6 @@ bool sd_present(IF_MV_NONVOID(int drive)); void card_enable_monitoring_target(bool on); #endif -bool card_detect_target(void); - long sd_last_disk_activity(void); #ifdef CONFIG_STORAGE_MULTI diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index fdb39f34c2..f13f2f868d 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -137,6 +137,16 @@ static inline void mci_delay(void) } while (--i); } + +static inline bool card_detect_target(void) +{ +#if defined(HAVE_MULTIDRIVE) + return !(GPIOA_PIN(2)); +#else + return false; +#endif +} + #ifdef HAVE_HOTSWAP static int sd1_oneshot_callback(struct timeout *tmo) { @@ -872,15 +882,6 @@ tCardInfo *card_get_info_target(int card_no) return &card_info[card_no]; } -bool card_detect_target(void) -{ -#if defined(HAVE_MULTIDRIVE) - return !(GPIOA_PIN(2)); -#else - return false; -#endif -} - #ifdef HAVE_HOTSWAP void card_enable_monitoring_target(bool on) { diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index f2efd02e9d..fafc5f20d9 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c @@ -340,6 +340,21 @@ static int sd_wait_for_state(unsigned int state, int id) } } + +static inline bool card_detect_target(void) +{ +#ifdef HAVE_HOTSWAP +#ifdef SANSA_E200 + return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */ +#elif defined SANSA_C200 + return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */ +#endif +#else + return false; +#endif +} + + static inline void copy_read_sectors_fast(unsigned char **buf) { /* Copy one chunk of 16 words using best method for start alignment */ @@ -1278,20 +1293,6 @@ tCardInfo *card_get_info_target(int card_no) { return &card_info[card_no]; } - -bool card_detect_target(void) -{ -#ifdef HAVE_HOTSWAP -#ifdef SANSA_E200 - return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */ -#elif defined SANSA_C200 - return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */ -#endif -#else - return false; -#endif -} - #ifdef HAVE_HOTSWAP static int sd1_oneshot_callback(struct timeout *tmo) { diff --git a/firmware/target/arm/s3c2440/sd-s3c2440.c b/firmware/target/arm/s3c2440/sd-s3c2440.c index 6213cbd003..8aa53d8891 100644 --- a/firmware/target/arm/s3c2440/sd-s3c2440.c +++ b/firmware/target/arm/s3c2440/sd-s3c2440.c @@ -494,6 +494,17 @@ static int sd_init_card(const int card_no) Generic functions *****************************************************************************/ +static inline bool card_detect_target(void) +{ + /* TODO - use interrupt on change? */ +#ifdef MINI2440 + return (GPGDAT & SD_CD) == 0; +#else +#error Unsupported target +#endif +} + + /*****************************************************************************/ #ifdef HAVE_HOTSWAP @@ -512,16 +523,6 @@ static int sd1_oneshot_callback(struct timeout *tmo) return 0; } -bool card_detect_target(void) -{ - /* TODO - use interrupt on change? */ -#ifdef MINI2440 - return (GPGDAT & SD_CD) == 0; -#else -#error Unsupported target -#endif -} - void card_enable_monitoring_target(bool on) { if (on) @@ -570,12 +571,6 @@ bool sd_present(IF_MD_NONVOID(int card_no)) /*****************************************************************************/ #else -bool card_detect_target(void) -{ - /* not applicable */ - return false; -} - bool sd_removable(IF_MD_NONVOID(int card_no)) { #ifndef HAVE_MULTIDRIVE diff --git a/firmware/target/arm/tcc780x/sd-tcc780x.c b/firmware/target/arm/tcc780x/sd-tcc780x.c index 222bb88a15..25876aa7ba 100644 --- a/firmware/target/arm/tcc780x/sd-tcc780x.c +++ b/firmware/target/arm/tcc780x/sd-tcc780x.c @@ -205,9 +205,13 @@ static void sd_card_mux(int card_no) #ifdef HAVE_HOTSWAP -bool card_detect_target(void) +static inline bool card_detect_target(void) { +#ifdef HAVE_HOTSWAP return (GPIOB & (1<<26)) == 0; /* low active */ +#else + return false; +#endif } void card_enable_monitoring_target(bool on) @@ -261,11 +265,6 @@ bool sd_present(IF_MD_NONVOID(int card_no)) #else -bool card_detect_target(void) -{ - return false; -} - bool sd_removable(IF_MD_NONVOID(int card_no)) { #ifndef HAVE_MULTIDRIVE diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index 544e0cf481..f3d67aec51 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c @@ -1200,7 +1200,7 @@ int sd_init(void) return -1; } -bool card_detect_target(void) +static inline bool card_detect_target(void) { return (jz_sd_chkcard() == 1); }