Error handling for CMD9

pull/7774/head
Deepika 2017-07-11 08:31:30 -05:00
parent cdbbea6c52
commit 21e6f47aa4
1 changed files with 5 additions and 2 deletions

View File

@ -344,6 +344,11 @@ int SDBlockDevice::init()
} }
debug_if(SD_DBG, "init card = %d\n", _is_initialized); debug_if(SD_DBG, "init card = %d\n", _is_initialized);
_sectors = _sd_sectors(); _sectors = _sd_sectors();
// CMD9 failed
if (0 == _sectors) {
_lock.unlock();
return BD_ERROR_DEVICE_ERROR;
}
// Set block length to 512 (CMD16) // Set block length to 512 (CMD16)
if (_cmd(CMD16_SET_BLOCKLEN, _block_size) != 0) { if (_cmd(CMD16_SET_BLOCKLEN, _block_size) != 0) {
@ -358,12 +363,10 @@ int SDBlockDevice::init()
_lock.unlock(); _lock.unlock();
return err; return err;
} }
_lock.unlock(); _lock.unlock();
return BD_ERROR_OK; return BD_ERROR_OK;
} }
int SDBlockDevice::deinit() int SDBlockDevice::deinit()
{ {
return 0; return 0;