SDC. Safety improvements in capacity detection code.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/sdc_dev2@4104 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
barthess 2012-04-16 20:14:08 +00:00
parent 671cb8ab9d
commit 469211b330
1 changed files with 4 additions and 0 deletions

View File

@ -340,6 +340,10 @@ bool_t sdcConnect(SDCDriver *sdcp) {
a = _sdc_get_slice(sdcp->csd, SDC_CSD_20_C_SIZE_SLICE); a = _sdc_get_slice(sdcp->csd, SDC_CSD_20_C_SIZE_SLICE);
sdcp->capacity = 1024 * (a + 1); sdcp->capacity = 1024 * (a + 1);
break; break;
default:
/* Reserved value detected. */
sdcp->capacity = 0;
break;
} }
if (sdcp->capacity == 0) if (sdcp->capacity == 0)
goto failed; goto failed;