1: uhs_sbit32_t Usbh_Stor_Mount(
PSTOR_UNIT pUnit,
PUSER_DRV pDrv)
2: {
3: uhs_ubit8_t i;
4:
5: API_REPORT_MILESTONE( USBSTOR_CHKPOINTS_API_MOUNT );
6:
7:
8:
if( pStorClassDriver == NULL ) {
9: API_REPORT_SUMMARY( USBSTOR_LOG_SYS_SYSTEM_ERROR );
10:
return USBSTOR_SYS_SYSTEM_ERROR;
11: }
12:
13:
14: pUnit = Usbh_Stor_GetStorUnit((uhs_sbit32_t)pUnit);
15:
16:
17:
if( (pUnit == NULL) || (pDrv == NULL) ||
18: (Usbh_Stor_Api_IsStorUnitObject(pUnit) == FALSE) ) {
19: API_REPORT_SUMMARY( USBSTOR_LOG_API_PARAM_ERROR );
20:
return Usbh_Stor_SetLastError( NULL,
USBSTOR_API_PARAM_ERROR );
21: }
22:
23:
24:
if( pUnit->nStorStat != STOR_STAT_READY ) {
25:
26: API_REPORT_SUMMARY( USBSTOR_LOG_API_PARAM_ERROR );
27:
return Usbh_Stor_SetLastError( pUnit,
USBSTOR_API_PARAM_ERROR );
28: }
29:
30:
31:
for( i = 0; i < (uhs_ubit8_t) numof(stDriveTable); i++ ) {
32:
if( stDriveTable[i].pStorUnit == pUnit ) {
33:
34:
if( stDriveTable[i].pUserDrv == NULL ) {
35: stDriveTable[i].pUserDrv = pDrv;
36:
return USBSTOR_SUCCESS;
37: }
else {
38:
39: API_REPORT_SUMMARY( USBSTOR_LOG_API_MOUNTED_UNIT );
40:
return Usbh_Stor_SetLastError( pUnit,
USBSTOR_API_MOUNTED_UNIT );
41: }
42: }
43: }
44:
45:
46: API_REPORT_SUMMARY( USBSTOR_LOG_API_PARAM_ERROR );
47:
return Usbh_Stor_SetLastError( NULL,
USBSTOR_API_PARAM_ERROR );
48: }