SDIO. Added forgotten NULL pointer checks.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7695 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Uladzimir Pylinski 2015-02-19 17:16:15 +00:00
parent 9e2c12eb74
commit d5307c5e08
2 changed files with 10 additions and 5 deletions

View File

@ -227,8 +227,8 @@ typedef struct {
* procedures (temporal storage for EXT_CSD, etc.). * procedures (temporal storage for EXT_CSD, etc.).
* @note Buffer must be word aligned and big enough to store 512 bytes. * @note Buffer must be word aligned and big enough to store 512 bytes.
* @note It is mandatory for MMC bigger than 2GB. * @note It is mandatory for MMC bigger than 2GB.
* @note Memory can be freed after @p sdcConnect function call. Do not * @note Memory can be freed after @p sdcConnect return. Do not
* forge to set this pointer to @p NULL after freeing. * forget to set this pointer to @p NULL after freeing.
*/ */
uint8_t *scratchpad; uint8_t *scratchpad;
} SDCConfig; } SDCConfig;

View File

@ -308,6 +308,10 @@ static bool sdc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk) {
*clk = SDC_CLK_25MHz; /* safe default */ *clk = SDC_CLK_25MHz; /* safe default */
/* Use safe default when there is no space for data.*/
if (NULL == scratchpad)
return HAL_SUCCESS;
if (sdc_lld_read_special(sdcp, scratchpad, 64, MMCSD_CMD_SWITCH, cmdarg)) if (sdc_lld_read_special(sdcp, scratchpad, 64, MMCSD_CMD_SWITCH, cmdarg))
return HAL_FAILED; return HAL_FAILED;
@ -623,9 +627,10 @@ bool sdcConnect(SDCDriver *sdcp) {
goto failed; goto failed;
sdc_lld_set_data_clk(sdcp, clk); sdc_lld_set_data_clk(sdcp, clk);
/* Reads extended CSD if needed.*/ /* Reads extended CSD if needed and possible.*/
if (SDC_MODE_CARDTYPE_MMC == (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) && if (NULL != scratchpad &&
mmcsdGetSlice(sdcp->csd, MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE) > 1) { SDC_MODE_CARDTYPE_MMC == (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) &&
mmcsdGetSlice(sdcp->csd, MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE) > 1) {
if(sdc_lld_read_special(sdcp, scratchpad, 512, MMCSD_CMD_SEND_EXT_CSD, 0)) if(sdc_lld_read_special(sdcp, scratchpad, 512, MMCSD_CMD_SEND_EXT_CSD, 0))
goto failed; goto failed;
} }