EmbeddedPkg/MmcDxe: Fix coding style

Make the coding style more compliant with the EDK2 coding convention.



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11727 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-06-03 09:10:26 +00:00
parent b9d5fe03e6
commit e8e95df41d
2 changed files with 693 additions and 661 deletions

View File

@ -52,7 +52,7 @@ InitializeMmcHostPool (
VOID VOID
) )
{ {
InitializeListHead (&mMmcHostPool); InitializeListHead (&mMmcHostPool);
} }
/** /**
@ -63,7 +63,7 @@ InsertMmcHost (
IN MMC_HOST_INSTANCE *MmcHostInstance IN MMC_HOST_INSTANCE *MmcHostInstance
) )
{ {
InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link)); InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));
} }
/* /*
@ -74,101 +74,101 @@ RemoveMmcHost (
IN MMC_HOST_INSTANCE *MmcHostInstance IN MMC_HOST_INSTANCE *MmcHostInstance
) )
{ {
RemoveEntryList (&(MmcHostInstance->Link)); RemoveEntryList (&(MmcHostInstance->Link));
} }
MMC_HOST_INSTANCE* CreateMmcHostInstance( MMC_HOST_INSTANCE* CreateMmcHostInstance (
IN EFI_MMC_HOST_PROTOCOL* MmcHost IN EFI_MMC_HOST_PROTOCOL* MmcHost
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
MMC_HOST_INSTANCE* MmcHostInstance; MMC_HOST_INSTANCE* MmcHostInstance;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode; EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE)); MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));
if (MmcHostInstance == NULL) { if (MmcHostInstance == NULL) {
return NULL; return NULL;
} }
MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE; MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;
MmcHostInstance->State = MmcHwInitializationState; MmcHostInstance->State = MmcHwInitializationState;
MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
if (MmcHostInstance->BlockIo.Media == NULL) {
goto FREE_INSTANCE;
}
MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION; MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
MmcHostInstance->BlockIo.Reset = MmcReset; if (MmcHostInstance->BlockIo.Media == NULL) {
MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks; goto FREE_INSTANCE;
MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks; }
MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;
MmcHostInstance->MmcHost = MmcHost; MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
MmcHostInstance->BlockIo.Reset = MmcReset;
MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;
MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;
MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;
// Create DevicePath for the new MMC Host MmcHostInstance->MmcHost = MmcHost;
Status = MmcHost->BuildDevicePath(&NewDevicePathNode);
if (EFI_ERROR (Status)) {
goto FREE_MEDIA;
}
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH); // Create DevicePath for the new MMC Host
if (DevicePath == NULL) { Status = MmcHost->BuildDevicePath(&NewDevicePathNode);
goto FREE_MEDIA; if (EFI_ERROR (Status)) {
} goto FREE_MEDIA;
}
SetDevicePathEndNode (DevicePath);
MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);
// Publish BlockIO protocol interface DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
Status = gBS->InstallMultipleProtocolInterfaces ( if (DevicePath == NULL) {
&MmcHostInstance->MmcHandle, goto FREE_MEDIA;
&gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo), }
&gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
NULL
);
if (EFI_ERROR(Status)) {
goto FREE_DEVICE_PATH;
}
return MmcHostInstance; SetDevicePathEndNode (DevicePath);
MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);
// Publish BlockIO protocol interface
Status = gBS->InstallMultipleProtocolInterfaces (
&MmcHostInstance->MmcHandle,
&gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),
&gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
NULL
);
if (EFI_ERROR(Status)) {
goto FREE_DEVICE_PATH;
}
return MmcHostInstance;
FREE_DEVICE_PATH: FREE_DEVICE_PATH:
FreePool(DevicePath); FreePool(DevicePath);
FREE_MEDIA: FREE_MEDIA:
FreePool(MmcHostInstance->BlockIo.Media); FreePool(MmcHostInstance->BlockIo.Media);
FREE_INSTANCE: FREE_INSTANCE:
FreePool(MmcHostInstance); FreePool(MmcHostInstance);
return NULL; return NULL;
} }
EFI_STATUS DestroyMmcHostInstance( EFI_STATUS DestroyMmcHostInstance (
IN MMC_HOST_INSTANCE* MmcHostInstance IN MMC_HOST_INSTANCE* MmcHostInstance
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
// Uninstall Protocol Interfaces // Uninstall Protocol Interfaces
Status = gBS->UninstallMultipleProtocolInterfaces( Status = gBS->UninstallMultipleProtocolInterfaces (
MmcHostInstance->MmcHandle, MmcHostInstance->MmcHandle,
&gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo), &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),
&gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath, &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// Free Memory allocated for the instance
if (MmcHostInstance->BlockIo.Media) {
FreePool(MmcHostInstance->BlockIo.Media);
}
FreePool (MmcHostInstance);
return Status; // Free Memory allocated for the instance
if (MmcHostInstance->BlockIo.Media) {
FreePool(MmcHostInstance->BlockIo.Media);
}
FreePool (MmcHostInstance);
return Status;
} }
/** /**
@ -182,62 +182,62 @@ MmcDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
//EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; //EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_MMC_HOST_PROTOCOL *MmcHost; EFI_MMC_HOST_PROTOCOL *MmcHost;
EFI_DEV_PATH_PTR Node; EFI_DEV_PATH_PTR Node;
//
// Check RemainingDevicePath validation
//
if (RemainingDevicePath != NULL) {
// //
// Check RemainingDevicePath validation // Check if RemainingDevicePath is the End of Device Path Node,
// if yes, go on checking other conditions
// //
if (RemainingDevicePath != NULL) { if (!IsDevicePathEnd (RemainingDevicePath)) {
// //
// Check if RemainingDevicePath is the End of Device Path Node, // If RemainingDevicePath isn't the End of Device Path Node,
// if yes, go on checking other conditions // check its validation
// //
if (!IsDevicePathEnd (RemainingDevicePath)) { Node.DevPath = RemainingDevicePath;
// if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
// If RemainingDevicePath isn't the End of Device Path Node, Node.DevPath->SubType != HW_VENDOR_DP ||
// check its validation DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {
// return EFI_UNSUPPORTED;
Node.DevPath = RemainingDevicePath; }
if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
Node.DevPath->SubType != HW_VENDOR_DP ||
DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {
return EFI_UNSUPPORTED;
}
}
} }
}
// //
// Check if Mmc Host protocol is installed by platform // Check if Mmc Host protocol is installed by platform
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Controller, Controller,
&gEfiMmcHostProtocolGuid, &gEfiMmcHostProtocolGuid,
(VOID **) &MmcHost, (VOID **) &MmcHost,
This->DriverBindingHandle, This->DriverBindingHandle,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
//
// Close the Mmc Host used to perform the supported test
//
gBS->CloseProtocol (
Controller,
&gEfiMmcHostProtocolGuid,
This->DriverBindingHandle,
Controller
);
return EFI_SUCCESS; return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
//
// Close the Mmc Host used to perform the supported test
//
gBS->CloseProtocol (
Controller,
&gEfiMmcHostProtocolGuid,
This->DriverBindingHandle,
Controller
);
return EFI_SUCCESS;
} }
/** /**
@ -251,48 +251,48 @@ MmcDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
MMC_HOST_INSTANCE *MmcHostInstance; MMC_HOST_INSTANCE *MmcHostInstance;
EFI_MMC_HOST_PROTOCOL *MmcHost; EFI_MMC_HOST_PROTOCOL *MmcHost;
//
// Check RemainingDevicePath validation
//
if (RemainingDevicePath != NULL) {
// //
// Check RemainingDevicePath validation // Check if RemainingDevicePath is the End of Device Path Node,
// if yes, return EFI_SUCCESS
// //
if (RemainingDevicePath != NULL) { if (IsDevicePathEnd (RemainingDevicePath)) {
// return EFI_SUCCESS;
// Check if RemainingDevicePath is the End of Device Path Node,
// if yes, return EFI_SUCCESS
//
if (IsDevicePathEnd (RemainingDevicePath)) {
return EFI_SUCCESS;
}
} }
}
// //
// Get the Mmc Host protocol // Get the Mmc Host protocol
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Controller, Controller,
&gEfiMmcHostProtocolGuid, &gEfiMmcHostProtocolGuid,
(VOID **) &MmcHost, (VOID **) &MmcHost,
This->DriverBindingHandle, This->DriverBindingHandle,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS; return EFI_SUCCESS;
}
return Status;
} }
return Status;
}
MmcHostInstance = CreateMmcHostInstance(MmcHost); MmcHostInstance = CreateMmcHostInstance(MmcHost);
if (MmcHostInstance != NULL) { if (MmcHostInstance != NULL) {
// Add the handle to the pool // Add the handle to the pool
InsertMmcHost (MmcHostInstance); InsertMmcHost (MmcHostInstance);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -307,33 +307,33 @@ MmcDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer IN EFI_HANDLE *ChildHandleBuffer
) )
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
LIST_ENTRY *CurrentLink; LIST_ENTRY *CurrentLink;
MMC_HOST_INSTANCE *MmcHostInstance; MMC_HOST_INSTANCE *MmcHostInstance;
MMC_TRACE("MmcDriverBindingStop()"); MMC_TRACE("MmcDriverBindingStop()");
// For each MMC instance // For each MMC instance
CurrentLink = mMmcHostPool.ForwardLink; CurrentLink = mMmcHostPool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) { while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink); MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
ASSERT(MmcHostInstance != NULL); ASSERT(MmcHostInstance != NULL);
// Close gEfiMmcHostProtocolGuid // Close gEfiMmcHostProtocolGuid
Status = gBS->CloseProtocol ( Status = gBS->CloseProtocol (
Controller, Controller,
&gEfiMmcHostProtocolGuid,(VOID **) &MmcHostInstance->MmcHost, &gEfiMmcHostProtocolGuid,(VOID **) &MmcHostInstance->MmcHost,
This->DriverBindingHandle This->DriverBindingHandle
); );
// Remove MMC Host Instance from the pool // Remove MMC Host Instance from the pool
RemoveMmcHost (MmcHostInstance); RemoveMmcHost (MmcHostInstance);
// Destroy MmcHostInstance // Destroy MmcHostInstance
DestroyMmcHostInstance (MmcHostInstance); DestroyMmcHostInstance (MmcHostInstance);
} }
return Status; return Status;
} }
EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
@ -355,33 +355,33 @@ MmcDxeInitialize (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
// //
// Initializes MMC Host pool // Initializes MMC Host pool
// //
InitializeMmcHostPool (); InitializeMmcHostPool ();
// //
// Install driver model protocol(s). // Install driver model protocol(s).
// //
Status = EfiLibInstallDriverBindingComponentName2 ( Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle, ImageHandle,
SystemTable, SystemTable,
&gMmcDriverBinding, &gMmcDriverBinding,
ImageHandle, ImageHandle,
&gMmcComponentName, &gMmcComponentName,
&gMmcComponentName2 &gMmcComponentName2
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// Install driver diagnostics // Install driver diagnostics
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle, &ImageHandle,
&gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2, &gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

File diff suppressed because it is too large Load Diff