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:
parent
9e2c12eb74
commit
d5307c5e08
|
@ -227,8 +227,8 @@ typedef struct {
|
|||
* procedures (temporal storage for EXT_CSD, etc.).
|
||||
* @note Buffer must be word aligned and big enough to store 512 bytes.
|
||||
* @note It is mandatory for MMC bigger than 2GB.
|
||||
* @note Memory can be freed after @p sdcConnect function call. Do not
|
||||
* forge to set this pointer to @p NULL after freeing.
|
||||
* @note Memory can be freed after @p sdcConnect return. Do not
|
||||
* forget to set this pointer to @p NULL after freeing.
|
||||
*/
|
||||
uint8_t *scratchpad;
|
||||
} SDCConfig;
|
||||
|
|
|
@ -308,6 +308,10 @@ static bool sdc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk) {
|
|||
|
||||
*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))
|
||||
return HAL_FAILED;
|
||||
|
||||
|
@ -623,8 +627,9 @@ bool sdcConnect(SDCDriver *sdcp) {
|
|||
goto failed;
|
||||
sdc_lld_set_data_clk(sdcp, clk);
|
||||
|
||||
/* Reads extended CSD if needed.*/
|
||||
if (SDC_MODE_CARDTYPE_MMC == (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) &&
|
||||
/* Reads extended CSD if needed and possible.*/
|
||||
if (NULL != scratchpad &&
|
||||
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))
|
||||
goto failed;
|
||||
|
|
Loading…
Reference in New Issue