From: Kees Jongenburger Date: Wed, 10 Oct 2012 13:26:03 +0000 (+0200) Subject: mmc:Indenting and code cleanup. X-Git-Tag: v3.2.1~280 X-Git-Url: http://zhaoyanbai.com/repos/%24relpath%24tabs.css?a=commitdiff_plain;h=3fab01cdb238d5ffe1a17e4ac26f52236c585180;p=minix.git mmc:Indenting and code cleanup. Change-Id: Ia1156c6b5e4dbc6c8af37d61b118258053f347ce --- diff --git a/drivers/mmc/mmcblk.c b/drivers/mmc/mmcblk.c index f9ad1bc28..829566beb 100644 --- a/drivers/mmc/mmcblk.c +++ b/drivers/mmc/mmcblk.c @@ -612,7 +612,7 @@ get_slot(dev_t minor) /* we are talking about the first disk and that is all we * support */ return &host.slot[0]; - } else if ( IS_MINIX_SUB_PARTITION_MINOR(minor) + } else if (IS_MINIX_SUB_PARTITION_MINOR(minor) && (((minor - MINOR_d0p0s0) / SUB_PER_DRIVE) == 0)) { /* a minor from the first disk */ return &host.slot[0]; diff --git a/drivers/mmc/mmchost.h b/drivers/mmc/mmchost.h index b4827fa53..081fad2d5 100644 --- a/drivers/mmc/mmchost.h +++ b/drivers/mmc/mmchost.h @@ -37,17 +37,16 @@ struct mmc_host; #define SD_MODE_CARD_IDENTIFICATION 1 #define SD_MODE_DATA_TRANSFER_MODE 2 - struct sd_card_regs { - uint32_t cid[4]; /* Card Identification */ - uint32_t rca; /* Relative card address */ - uint32_t dsr; /* Driver stage register */ - uint32_t csd[4]; /* Card specific data */ - uint32_t scr[2]; /* SD configuration */ - uint32_t ocr; /* Operation conditions */ - uint32_t ssr[5]; /* SD Status */ - uint32_t csr; /* Card status */ + uint32_t cid[4]; /* Card Identification */ + uint32_t rca; /* Relative card address */ + uint32_t dsr; /* Driver stage register */ + uint32_t csd[4]; /* Card specific data */ + uint32_t scr[2]; /* SD configuration */ + uint32_t ocr; /* Operation conditions */ + uint32_t ssr[5]; /* SD Status */ + uint32_t csr; /* Card status */ }; /* struct representing an mmc command */ @@ -63,7 +62,7 @@ struct mmc_command #define NO_RESPONSE (0<<0) uint32_t resp[4]; - unsigned char* data; + unsigned char *data; uint32_t data_len; }; @@ -108,7 +107,7 @@ struct mmc_host /* MMC host configuration */ int (*host_init) (struct mmc_host * host); /* Set log level */ - void(*set_log_level) (int level); + void (*set_log_level) (int level); /* Host controller reset */ int (*host_reset) (struct mmc_host * host); /* Card detection (binary yes/no) */ diff --git a/drivers/mmc/mmchost_mmchs.c b/drivers/mmc/mmchost_mmchs.c index 93b5f3ba9..0445c2184 100644 --- a/drivers/mmc/mmchost_mmchs.c +++ b/drivers/mmc/mmchost_mmchs.c @@ -25,6 +25,15 @@ /* omap /hardware related */ #include "omap_mmc.h" +/* + * Define a structure to be used for logging + */ +static struct mmclog log = { + .name = "mmc_host_mmchs", + .log_level = LEVEL_INFO, + .log_func = default_log +}; + #define REG(x)(*((volatile uint32_t *)(x))) #define BIT(x)(0x1 << x) @@ -89,7 +98,8 @@ mmchs_init(uint32_t instance) base_address = (unsigned long) base_address - 0x100; - /* Soft reset of the controller. This section is documented in the TRM */ + /* Soft reset of the controller. This section is documented in the TRM + */ /* Write 1 to sysconfig[0] to trigger a reset */ set32(base_address + MMCHS_SD_SYSCONFIG, MMCHS_SD_SYSCONFIG_SOFTRESET, @@ -154,7 +164,7 @@ mmchs_init(uint32_t instance) set32(base_address + MMCHS_SD_HCTL, MMCHS_SD_HCTL_SDBP, MMCHS_SD_HCTL_SDBP_ON); - /* TODO: Add padconf stuff here as documented in the TRM*/ + /* TODO: Add padconf stuff here as documented in the TRM */ while ((read32(base_address + MMCHS_SD_HCTL) & MMCHS_SD_HCTL_SDBP) != MMCHS_SD_HCTL_SDBP_ON) { @@ -210,7 +220,8 @@ mmchs_init(uint32_t instance) while ((read32(base_address + MMCHS_SD_STAT) & MMCHS_SD_STAT_CC) != MMCHS_SD_STAT_CC_RAISED) { if (read32(base_address + MMCHS_SD_STAT) & 0x8000) { - printf("%s, error stat %x\n", __FUNCTION__, + mmc_log_warn(&log, "%s, error stat %x\n", + __FUNCTION__, read32(base_address + MMCHS_SD_STAT)); return 1; } @@ -240,7 +251,7 @@ mmchs_send_cmd(uint32_t command, uint32_t arg) /* Read current interrupt status and fail it an interrupt is already * asserted */ if ((read32(base_address + MMCHS_SD_STAT) & 0xffffu)) { - printf("%s, interrupt already raised stat %08x\n", + mmc_log_warn(&log, "%s, interrupt already raised stat %08x\n", __FUNCTION__, read32(base_address + MMCHS_SD_STAT)); write32(base_address + MMCHS_SD_STAT, MMCHS_SD_IE_CC_ENABLE_CLEAR); @@ -258,7 +269,7 @@ mmchs_send_cmd(uint32_t command, uint32_t arg) } if (read32(base_address + MMCHS_SD_STAT) & 0x8000) { - printf("%s, error stat %08x\n", __FUNCTION__, + mmc_log_warn(&log, "%s, error stat %08x\n", __FUNCTION__, read32(base_address + MMCHS_SD_STAT)); set32(base_address + MMCHS_SD_STAT, MMCHS_SD_STAT_ERROR_MASK, 0xffffffffu); @@ -362,8 +373,8 @@ card_identification() if (!(command.resp[0] == (MMCHS_SD_ARG_CMD8_VHS | MMCHS_SD_ARG_CMD8_CHECK_PATTERN))) { - printf("%s, check pattern check failed %08x\n", __FUNCTION__, - command.resp[0]); + mmc_log_warn(&log, "%s, check pattern check failed %08x\n", + __FUNCTION__, command.resp[0]); return 1; } return 0; @@ -480,12 +491,12 @@ card_csd(struct sd_card_regs *card) card->csd[3] = command.resp[3]; if (SD_CSD_CSDVER(card->csd) != SD_CSD_CSDVER_2_0) { - printf("Version 2.0 of CSD register expected\n"); + mmc_log_warn(&log, "Version 2.0 of CSD register expected\n"); return 1; } /* sanity check */ - // printf("size = %llu bytes\n", (long long + // mmc_log_warn(&log,"size = %llu bytes\n", (long long // unsigned)SD_CSD_V2_CAPACITY( card->csd) * 512); return 0; } @@ -622,15 +633,6 @@ write_single_block(struct sd_card_regs *card, return 0; } -/* - * Define a structure to be used for logging - */ -static struct mmclog log = { - .name = "mmc_host_mmchs", - .log_level = LEVEL_INFO, - .log_func = default_log -}; - int mmchs_host_init(struct mmc_host *host) { @@ -681,38 +683,40 @@ mmchs_card_initialize(struct sd_slot *slot) card->slot = slot; if (card_goto_idle_state()) { - printf("Failed to go idle state\n"); + mmc_log_warn(&log, "Failed to go idle state\n"); return NULL; } if (card_identification()) { - printf("Failed to do card_identification\n"); + mmc_log_warn(&log, "Failed to do card_identification\n"); return NULL; } if (card_query_voltage_and_type(&slot->card.regs)) { - printf("Failed to do card_query_voltage_and_type\n"); + mmc_log_warn(&log, + "Failed to do card_query_voltage_and_type\n"); return NULL; } if (card_identify(&slot->card.regs)) { - printf("Failed to identify card\n"); + mmc_log_warn(&log, "Failed to identify card\n"); return NULL; } /* We have now initialized the hardware identified the card */ if (card_csd(&slot->card.regs)) { - printf("failed to read csd (card specific data)\n"); + mmc_log_warn(&log, + "failed to read csd (card specific data)\n"); return NULL; } if (select_card(&slot->card.regs)) { - printf("Failed to select card\n"); + mmc_log_warn(&log, "Failed to select card\n"); return NULL; } if (SD_CSD_READ_BL_LEN(slot->card.regs.csd) != 0x09) { /* for CSD version 2.0 the value is fixed to 0x09 and means a * block size of 512 */ - printf("Block size expect to be 512\n"); + mmc_log_warn(&log, "Block size expect to be 512\n"); return NULL; }