1: STOR_UNIT_STATUS Usbh_Stor_GetUnitStatus(
PSTOR_UNIT pUnit)
2: {
3: API_REPORT_MILESTONE( USBSTOR_CHKPOINTS_API_GETUNITSTATUS );
4:
5:
6:
if( pStorClassDriver == NULL ) {
7: API_REPORT_SUMMARY( USBSTOR_LOG_SYS_SYSTEM_ERROR );
8:
return STOR_NOT_USE;
9: }
10:
11:
12: pUnit = Usbh_Stor_GetStorUnit((uhs_sbit32_t)pUnit);
13:
14:
15:
if( (pUnit == NULL) ||
16: (Usbh_Stor_Api_IsStorUnitObject(pUnit) == FALSE) ) {
17: API_REPORT_SUMMARY( USBSTOR_LOG_API_PARAM_ERROR );
18: Usbh_Stor_SetLastError( NULL,
USBSTOR_API_PARAM_ERROR );
19:
return STOR_NOT_USE;
20: }
21:
22:
23:
if( Usbh_Stor_ScsiCtrl_AttachStorUnit(pUnit) == FALSE ) {
24: Usbh_Stor_SetLastError( pUnit,
USBSTOR_API_UNIT_NOT_USE );
25:
return STOR_NOT_USE;
26: }
27:
28:
29:
switch( pUnit->nStorStat ) {
30:
case STOR_STAT_READY:
31:
32:
return STOR_READY;
33:
case STOR_STAT_NOT_READY:
34:
35: Usbh_Stor_SetLastError( pUnit,
USBSTOR_API_UNIT_NOT_READY );
36:
return STOR_NOT_READY;
37:
default:
38:
39: Usbh_Stor_SetLastError( pUnit,
USBSTOR_API_UNIT_NOT_USE );
40:
return STOR_NOT_USE;
41: }
42: }