summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/I2c/I2cDxe
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/I2c/I2cDxe')
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c437
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c27
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.h174
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c215
4 files changed, 435 insertions, 418 deletions
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
index fa58632..eafd3bc 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
@@ -12,7 +12,7 @@
//
// EFI_DRIVER_BINDING_PROTOCOL instance
//
-EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding = {
I2cBusDriverSupported,
I2cBusDriverStart,
I2cBusDriverStop,
@@ -24,7 +24,7 @@ EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding = {
//
// Template for I2C Bus Child Device.
//
-I2C_DEVICE_CONTEXT gI2cDeviceContextTemplate = {
+I2C_DEVICE_CONTEXT gI2cDeviceContextTemplate = {
I2C_DEVICE_SIGNATURE,
NULL,
{ // I2cIo Protocol
@@ -42,13 +42,13 @@ I2C_DEVICE_CONTEXT gI2cDeviceContextTemplate = {
//
// Template for controller device path node.
//
-CONTROLLER_DEVICE_PATH gControllerDevicePathTemplate = {
+CONTROLLER_DEVICE_PATH gControllerDevicePathTemplate = {
{
HARDWARE_DEVICE_PATH,
HW_CONTROLLER_DP,
{
- (UINT8) (sizeof (CONTROLLER_DEVICE_PATH)),
- (UINT8) ((sizeof (CONTROLLER_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (CONTROLLER_DEVICE_PATH)),
+ (UINT8)((sizeof (CONTROLLER_DEVICE_PATH)) >> 8)
}
},
0
@@ -57,39 +57,40 @@ CONTROLLER_DEVICE_PATH gControllerDevicePathTemplate = {
//
// Template for vendor device path node.
//
-VENDOR_DEVICE_PATH gVendorDevicePathTemplate = {
+VENDOR_DEVICE_PATH gVendorDevicePathTemplate = {
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
- { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }}
+ { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
+ }
};
//
// Driver name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cBusDriverNameTable[] = {
- { "eng;en", (CHAR16 *) L"I2C Bus Driver" },
- { NULL , NULL }
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cBusDriverNameTable[] = {
+ { "eng;en", (CHAR16 *)L"I2C Bus Driver" },
+ { NULL, NULL }
};
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName = {
- (EFI_COMPONENT_NAME_GET_DRIVER_NAME) I2cBusComponentNameGetDriverName,
- (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) I2cBusComponentNameGetControllerName,
+ (EFI_COMPONENT_NAME_GET_DRIVER_NAME)I2cBusComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)I2cBusComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2 = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2 = {
I2cBusComponentNameGetDriverName,
I2cBusComponentNameGetControllerName,
"en"
@@ -138,8 +139,8 @@ EFI_STATUS
EFIAPI
I2cBusComponentNameGetDriverName (
IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -222,11 +223,11 @@ I2cBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
I2cBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
@@ -254,16 +255,16 @@ CheckRemainingDevicePath (
IN UINT32 RemainingControllerNumber
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *SystemDevicePath;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- UINTN EntryCount;
- UINTN Index;
- BOOLEAN SystemHasControllerNode;
- UINT32 SystemControllerNumber;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *SystemDevicePath;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ UINTN EntryCount;
+ UINTN Index;
+ BOOLEAN SystemHasControllerNode;
+ UINT32 SystemControllerNumber;
SystemHasControllerNode = FALSE;
- SystemControllerNumber = 0;
+ SystemControllerNumber = 0;
Status = gBS->OpenProtocolInformation (
Controller,
@@ -280,7 +281,7 @@ CheckRemainingDevicePath (
Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &SystemDevicePath,
+ (VOID **)&SystemDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -291,7 +292,8 @@ CheckRemainingDevicePath (
//
while (!IsDevicePathEnd (SystemDevicePath)) {
if ((DevicePathType (SystemDevicePath) == HARDWARE_DEVICE_PATH) &&
- (DevicePathSubType (SystemDevicePath) == HW_VENDOR_DP)) {
+ (DevicePathSubType (SystemDevicePath) == HW_VENDOR_DP))
+ {
//
// Check if vendor device path is same between system device path and remaining device path
//
@@ -301,31 +303,37 @@ CheckRemainingDevicePath (
//
SystemDevicePath = NextDevicePathNode (SystemDevicePath);
if ((DevicePathType (SystemDevicePath) == HARDWARE_DEVICE_PATH) &&
- (DevicePathSubType (SystemDevicePath) == HW_CONTROLLER_DP)) {
+ (DevicePathSubType (SystemDevicePath) == HW_CONTROLLER_DP))
+ {
SystemHasControllerNode = TRUE;
- SystemControllerNumber = ((CONTROLLER_DEVICE_PATH *) SystemDevicePath)->ControllerNumber;
+ SystemControllerNumber = ((CONTROLLER_DEVICE_PATH *)SystemDevicePath)->ControllerNumber;
} else {
SystemHasControllerNode = FALSE;
- SystemControllerNumber = 0;
+ SystemControllerNumber = 0;
}
+
if (((SystemHasControllerNode) && (!RemainingHasControllerNode) && (SystemControllerNumber == 0)) ||
((!SystemHasControllerNode) && (RemainingHasControllerNode) && (RemainingControllerNumber == 0)) ||
((SystemHasControllerNode) && (RemainingHasControllerNode) && (SystemControllerNumber == RemainingControllerNumber)) ||
- ((!SystemHasControllerNode) && (!RemainingHasControllerNode))) {
- DEBUG ((DEBUG_ERROR, "This I2C device has been already started.\n"));
- Status = EFI_UNSUPPORTED;
- break;
+ ((!SystemHasControllerNode) && (!RemainingHasControllerNode)))
+ {
+ DEBUG ((DEBUG_ERROR, "This I2C device has been already started.\n"));
+ Status = EFI_UNSUPPORTED;
+ break;
}
}
}
+
SystemDevicePath = NextDevicePathNode (SystemDevicePath);
}
+
if (EFI_ERROR (Status)) {
break;
}
}
}
}
+
FreePool (OpenInfoBuffer);
return Status;
}
@@ -380,16 +388,16 @@ I2cBusDriverSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
- EFI_I2C_HOST_PROTOCOL *I2cHost;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- BOOLEAN RemainingHasControllerNode;
- UINT32 RemainingControllerNumber;
+ EFI_STATUS Status;
+ EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
+ EFI_I2C_HOST_PROTOCOL *I2cHost;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ BOOLEAN RemainingHasControllerNode;
+ UINT32 RemainingControllerNumber;
RemainingHasControllerNode = FALSE;
- RemainingControllerNumber = 0;
+ RemainingControllerNumber = 0;
//
// Determine if the I2c Enumerate Protocol is available
@@ -397,7 +405,7 @@ I2cBusDriverSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
- (VOID **) &I2cEnumerate,
+ (VOID **)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -408,17 +416,17 @@ I2cBusDriverSupported (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiI2cEnumerateProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cEnumerateProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -430,11 +438,11 @@ I2cBusDriverSupported (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
@@ -442,20 +450,23 @@ I2cBusDriverSupported (
// Check if the first node of RemainingDevicePath is a hardware vendor device path
//
if ((DevicePathType (RemainingDevicePath) != HARDWARE_DEVICE_PATH) ||
- (DevicePathSubType (RemainingDevicePath) != HW_VENDOR_DP)) {
+ (DevicePathSubType (RemainingDevicePath) != HW_VENDOR_DP))
+ {
return EFI_UNSUPPORTED;
}
+
//
// Check if the second node of RemainingDevicePath is a controller node
//
DevPathNode = NextDevicePathNode (RemainingDevicePath);
if (!IsDevicePathEnd (DevPathNode)) {
if ((DevicePathType (DevPathNode) != HARDWARE_DEVICE_PATH) ||
- (DevicePathSubType (DevPathNode) != HW_CONTROLLER_DP)) {
+ (DevicePathSubType (DevPathNode) != HW_CONTROLLER_DP))
+ {
return EFI_UNSUPPORTED;
} else {
RemainingHasControllerNode = TRUE;
- RemainingControllerNumber = ((CONTROLLER_DEVICE_PATH *) DevPathNode)->ControllerNumber;
+ RemainingControllerNumber = ((CONTROLLER_DEVICE_PATH *)DevPathNode)->ControllerNumber;
}
}
}
@@ -466,7 +477,7 @@ I2cBusDriverSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cHostProtocolGuid,
- (VOID **) &I2cHost,
+ (VOID **)&I2cHost,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -474,17 +485,17 @@ I2cBusDriverSupported (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiI2cHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cHostProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
-
if (Status == EFI_ALREADY_STARTED) {
if ((RemainingDevicePath == NULL) ||
- ((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath))) {
+ ((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath)))
+ {
//
// If RemainingDevicePath is NULL or is the End of Device Path Node, return EFI_SUCCESS.
//
@@ -549,16 +560,16 @@ I2cBusDriverStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
- EFI_I2C_HOST_PROTOCOL *I2cHost;
- I2C_BUS_CONTEXT *I2cBusContext;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
+ EFI_I2C_HOST_PROTOCOL *I2cHost;
+ I2C_BUS_CONTEXT *I2cBusContext;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- I2cBusContext = NULL;
- ParentDevicePath = NULL;
- I2cEnumerate = NULL;
- I2cHost = NULL;
+ I2cBusContext = NULL;
+ ParentDevicePath = NULL;
+ I2cEnumerate = NULL;
+ I2cHost = NULL;
//
// Determine if the I2C controller is available
@@ -566,7 +577,7 @@ I2cBusDriverStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cHostProtocolGuid,
- (VOID**)&I2cHost,
+ (VOID **)&I2cHost,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -580,7 +591,7 @@ I2cBusDriverStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &I2cBusContext,
+ (VOID **)&I2cBusContext,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -597,7 +608,7 @@ I2cBusDriverStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
- (VOID**)&I2cEnumerate,
+ (VOID **)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -608,13 +619,13 @@ I2cBusDriverStart (
}
Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&ParentDevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
DEBUG ((DEBUG_ERROR, "I2cBus: open device path error, Status = %r\n", Status));
goto Error;
@@ -661,7 +672,7 @@ I2cBusDriverStart (
//
// Parent controller used to create children
//
- I2cBusContext->Controller = Controller;
+ I2cBusContext->Controller = Controller;
//
// Parent controller device path used to create children device path
//
@@ -693,29 +704,29 @@ Error:
DEBUG ((DEBUG_ERROR, "I2cBus: Start() function failed, Status = %r\n", Status));
if (ParentDevicePath != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
if (I2cHost != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiI2cHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cHostProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
if (I2cEnumerate != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiI2cEnumerateProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cEnumerateProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
if (I2cBusContext != NULL) {
@@ -735,7 +746,6 @@ Error:
return Status;
}
-
/**
Stops a device controller or a bus controller.
@@ -771,60 +781,60 @@ I2cBusDriverStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- I2C_BUS_CONTEXT *I2cBusContext;
- EFI_STATUS Status;
- BOOLEAN AllChildrenStopped;
- UINTN Index;
+ I2C_BUS_CONTEXT *I2cBusContext;
+ EFI_STATUS Status;
+ BOOLEAN AllChildrenStopped;
+ UINTN Index;
if (NumberOfChildren == 0) {
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
gBS->CloseProtocol (
- Controller,
- &gEfiI2cHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cHostProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
gBS->CloseProtocol (
- Controller,
- &gEfiI2cEnumerateProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cEnumerateProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &I2cBusContext,
+ (VOID **)&I2cBusContext,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiCallerIdGuid,
- I2cBusContext,
- NULL
- );
+ Controller,
+ &gEfiCallerIdGuid,
+ I2cBusContext,
+ NULL
+ );
//
// No more child now, free bus context data.
//
FreePool (I2cBusContext);
}
+
return Status;
}
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
-
Status = UnRegisterI2cDevice (This, Controller, ChildHandleBuffer[Index]);
if (EFI_ERROR (Status)) {
AllChildrenStopped = FALSE;
@@ -834,6 +844,7 @@ I2cBusDriverStop (
if (!AllChildrenStopped) {
return EFI_DEVICE_ERROR;
}
+
return EFI_SUCCESS;
}
@@ -853,22 +864,22 @@ I2cBusDriverStop (
**/
EFI_STATUS
RegisterI2cDevice (
- IN I2C_BUS_CONTEXT *I2cBusContext,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN I2C_BUS_CONTEXT *I2cBusContext,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- I2C_DEVICE_CONTEXT *I2cDeviceContext;
- EFI_STATUS Status;
- CONST EFI_I2C_DEVICE *Device;
- CONST EFI_I2C_DEVICE *TempDevice;
- UINT32 RemainingPathDeviceIndex;
- EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- BOOLEAN BuildControllerNode;
- UINTN Count;
-
- Status = EFI_SUCCESS;
- BuildControllerNode = TRUE;
+ I2C_DEVICE_CONTEXT *I2cDeviceContext;
+ EFI_STATUS Status;
+ CONST EFI_I2C_DEVICE *Device;
+ CONST EFI_I2C_DEVICE *TempDevice;
+ UINT32 RemainingPathDeviceIndex;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ BOOLEAN BuildControllerNode;
+ UINTN Count;
+
+ Status = EFI_SUCCESS;
+ BuildControllerNode = TRUE;
//
// Default DeviceIndex
@@ -884,12 +895,13 @@ RegisterI2cDevice (
//
DevPathNode = NextDevicePathNode (RemainingDevicePath);
if ((DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH) &&
- (DevicePathSubType(DevPathNode) == HW_CONTROLLER_DP)) {
+ (DevicePathSubType (DevPathNode) == HW_CONTROLLER_DP))
+ {
//
// RemainingDevicePath != NULL and RemainingDevicePath contains Controller Node,
// add Controller Node to Device Path on child handle.
//
- RemainingPathDeviceIndex = ((CONTROLLER_DEVICE_PATH *) DevPathNode)->ControllerNumber;
+ RemainingPathDeviceIndex = ((CONTROLLER_DEVICE_PATH *)DevPathNode)->ControllerNumber;
} else {
//
// RemainingDevicePath != NULL and RemainingDevicePath does not contain Controller Node,
@@ -908,12 +920,13 @@ RegisterI2cDevice (
// Get the next I2C device
//
Status = I2cBusContext->I2cEnumerate->Enumerate (I2cBusContext->I2cEnumerate, &Device);
- if (EFI_ERROR (Status) || Device == NULL) {
+ if (EFI_ERROR (Status) || (Device == NULL)) {
if (RemainingDevicePath != NULL) {
Status = EFI_NOT_FOUND;
} else {
Status = EFI_SUCCESS;
}
+
break;
}
@@ -937,14 +950,16 @@ RegisterI2cDevice (
// Get the next I2C device
//
Status = I2cBusContext->I2cEnumerate->Enumerate (I2cBusContext->I2cEnumerate, &TempDevice);
- if (EFI_ERROR (Status) || TempDevice == NULL) {
+ if (EFI_ERROR (Status) || (TempDevice == NULL)) {
Status = EFI_SUCCESS;
break;
}
+
if (CompareGuid (Device->DeviceGuid, TempDevice->DeviceGuid)) {
Count++;
}
}
+
if (Count == 1) {
//
// RemainingDevicePath == NULL and only DeviceIndex 0 is present on the I2C bus,
@@ -958,7 +973,8 @@ RegisterI2cDevice (
// Find I2C device reported in Remaining Device Path
//
if ((!CompareGuid (&((VENDOR_DEVICE_PATH *)RemainingDevicePath)->Guid, Device->DeviceGuid)) ||
- (RemainingPathDeviceIndex != Device->DeviceIndex)) {
+ (RemainingPathDeviceIndex != Device->DeviceIndex))
+ {
continue;
}
}
@@ -976,11 +992,11 @@ RegisterI2cDevice (
//
// Initialize the specific device context
//
- I2cDeviceContext->I2cBusContext = I2cBusContext;
- I2cDeviceContext->I2cDevice = Device;
- I2cDeviceContext->I2cIo.DeviceGuid = Device->DeviceGuid;
- I2cDeviceContext->I2cIo.DeviceIndex = Device->DeviceIndex;
- I2cDeviceContext->I2cIo.HardwareRevision = Device->HardwareRevision;
+ I2cDeviceContext->I2cBusContext = I2cBusContext;
+ I2cDeviceContext->I2cDevice = Device;
+ I2cDeviceContext->I2cIo.DeviceGuid = Device->DeviceGuid;
+ I2cDeviceContext->I2cIo.DeviceIndex = Device->DeviceIndex;
+ I2cDeviceContext->I2cIo.HardwareRevision = Device->HardwareRevision;
I2cDeviceContext->I2cIo.I2cControllerCapabilities = I2cBusContext->I2cHost->I2cControllerCapabilities;
//
@@ -996,12 +1012,13 @@ RegisterI2cDevice (
// Install the protocol
//
Status = gBS->InstallMultipleProtocolInterfaces (
- &I2cDeviceContext->Handle,
- &gEfiI2cIoProtocolGuid,
- &I2cDeviceContext->I2cIo,
- &gEfiDevicePathProtocolGuid,
- I2cDeviceContext->DevicePath,
- NULL );
+ &I2cDeviceContext->Handle,
+ &gEfiI2cIoProtocolGuid,
+ &I2cDeviceContext->I2cIo,
+ &gEfiDevicePathProtocolGuid,
+ I2cDeviceContext->DevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
//
// Free resources for this I2C device
@@ -1016,7 +1033,7 @@ RegisterI2cDevice (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cHostProtocolGuid,
- (VOID **) &I2cBusContext->I2cHost,
+ (VOID **)&I2cBusContext->I2cHost,
I2cBusContext->DriverBindingHandle,
I2cDeviceContext->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1048,7 +1065,6 @@ RegisterI2cDevice (
return Status;
}
-
/**
Queue an I2C transaction for execution on the I2C device.
@@ -1130,11 +1146,11 @@ I2cBusQueueRequest (
OUT EFI_STATUS *I2cStatus OPTIONAL
)
{
- CONST EFI_I2C_DEVICE *I2cDevice;
- I2C_BUS_CONTEXT *I2cBusContext;
- CONST EFI_I2C_HOST_PROTOCOL *I2cHost;
- I2C_DEVICE_CONTEXT *I2cDeviceContext;
- EFI_STATUS Status;
+ CONST EFI_I2C_DEVICE *I2cDevice;
+ I2C_BUS_CONTEXT *I2cBusContext;
+ CONST EFI_I2C_HOST_PROTOCOL *I2cHost;
+ I2C_DEVICE_CONTEXT *I2cDeviceContext;
+ EFI_STATUS Status;
if (RequestPacket == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1161,7 +1177,7 @@ I2cBusQueueRequest (
Status = I2cHost->QueueRequest (
I2cHost,
I2cDevice->I2cBusConfiguration,
- I2cDevice->SlaveAddressArray [SlaveAddressIndex],
+ I2cDevice->SlaveAddressArray[SlaveAddressIndex],
Event,
RequestPacket,
I2cStatus
@@ -1180,7 +1196,7 @@ I2cBusQueueRequest (
**/
VOID
ReleaseI2cDeviceContext (
- IN I2C_DEVICE_CONTEXT *I2cDeviceContext
+ IN I2C_DEVICE_CONTEXT *I2cDeviceContext
)
{
if (I2cDeviceContext == NULL) {
@@ -1210,22 +1226,22 @@ ReleaseI2cDeviceContext (
**/
EFI_STATUS
UnRegisterI2cDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Handle
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- I2C_DEVICE_CONTEXT *I2cDeviceContext;
- EFI_I2C_IO_PROTOCOL *I2cIo;
- EFI_I2C_HOST_PROTOCOL *I2cHost;
+ EFI_STATUS Status;
+ I2C_DEVICE_CONTEXT *I2cDeviceContext;
+ EFI_I2C_IO_PROTOCOL *I2cIo;
+ EFI_I2C_HOST_PROTOCOL *I2cHost;
I2cIo = NULL;
Status = gBS->OpenProtocol (
Handle,
&gEfiI2cIoProtocolGuid,
- (VOID **) &I2cIo,
+ (VOID **)&I2cIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1267,13 +1283,13 @@ UnRegisterI2cDevice (
// Keep parent and child relationship
//
gBS->OpenProtocol (
- Controller,
- &gEfiI2cHostProtocolGuid,
- (VOID **) &I2cHost,
- This->DriverBindingHandle,
- Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
+ Controller,
+ &gEfiI2cHostProtocolGuid,
+ (VOID **)&I2cHost,
+ This->DriverBindingHandle,
+ Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
return Status;
}
@@ -1299,8 +1315,8 @@ UnRegisterI2cDevice (
**/
EFI_STATUS
I2cBusDevicePathAppend (
- IN I2C_DEVICE_CONTEXT *I2cDeviceContext,
- IN BOOLEAN BuildControllerNode
+ IN I2C_DEVICE_CONTEXT *I2cDeviceContext,
+ IN BOOLEAN BuildControllerNode
)
{
EFI_DEVICE_PATH_PROTOCOL *PreviousDevicePath;
@@ -1311,10 +1327,10 @@ I2cBusDevicePathAppend (
// Build vendor device path
//
CopyMem (&gVendorDevicePathTemplate.Guid, I2cDeviceContext->I2cDevice->DeviceGuid, sizeof (EFI_GUID));
- I2cDeviceContext->DevicePath = AppendDevicePathNode (
- I2cDeviceContext->I2cBusContext->ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &gVendorDevicePathTemplate
- );
+ I2cDeviceContext->DevicePath = AppendDevicePathNode (
+ I2cDeviceContext->I2cBusContext->ParentDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gVendorDevicePathTemplate
+ );
ASSERT (I2cDeviceContext->DevicePath != NULL);
if (I2cDeviceContext->DevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -1324,12 +1340,12 @@ I2cBusDevicePathAppend (
//
// Build the final I2C device path with controller node
//
- PreviousDevicePath = I2cDeviceContext->DevicePath;
+ PreviousDevicePath = I2cDeviceContext->DevicePath;
gControllerDevicePathTemplate.ControllerNumber = I2cDeviceContext->I2cDevice->DeviceIndex;
- I2cDeviceContext->DevicePath = AppendDevicePathNode (
- I2cDeviceContext->DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &gControllerDevicePathTemplate
- );
+ I2cDeviceContext->DevicePath = AppendDevicePathNode (
+ I2cDeviceContext->DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gControllerDevicePathTemplate
+ );
gBS->FreePool (PreviousDevicePath);
ASSERT (I2cDeviceContext->DevicePath != NULL);
if (I2cDeviceContext->DevicePath == NULL) {
@@ -1353,12 +1369,12 @@ I2cBusDevicePathAppend (
**/
EFI_STATUS
EFIAPI
-InitializeI2cBus(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeI2cBus (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -1373,7 +1389,6 @@ InitializeI2cBus(
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
@@ -1392,15 +1407,15 @@ InitializeI2cBus(
EFI_STATUS
EFIAPI
I2cBusUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE *DeviceHandleBuffer;
- UINTN DeviceHandleCount;
- UINTN Index;
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ EFI_STATUS Status;
+ EFI_HANDLE *DeviceHandleBuffer;
+ UINTN DeviceHandleCount;
+ UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all I2C Controller handles in the handle database.
@@ -1455,7 +1470,7 @@ I2cBusUnload (
Status = gBS->HandleProtocol (
gI2cBusDriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
@@ -1468,7 +1483,7 @@ I2cBusUnload (
Status = gBS->HandleProtocol (
gI2cBusDriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c
index bb5d839..0c733f0 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c
@@ -20,21 +20,21 @@
**/
EFI_STATUS
EFIAPI
-InitializeI2c(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeI2c (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
//
- Status = InitializeI2cHost ( ImageHandle, SystemTable );
- if ( !EFI_ERROR ( Status ))
- {
- Status = InitializeI2cBus ( ImageHandle, SystemTable );
+ Status = InitializeI2cHost (ImageHandle, SystemTable);
+ if ( !EFI_ERROR (Status)) {
+ Status = InitializeI2cBus (ImageHandle, SystemTable);
}
+
return Status;
}
@@ -53,17 +53,18 @@ InitializeI2c(
EFI_STATUS
EFIAPI
I2cUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Disconnect the drivers
//
- Status = I2cBusUnload ( ImageHandle );
- if ( !EFI_ERROR ( Status )) {
- Status = I2cHostUnload ( ImageHandle );
+ Status = I2cBusUnload (ImageHandle);
+ if ( !EFI_ERROR (Status)) {
+ Status = I2cHostUnload (ImageHandle);
}
+
return Status;
}
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.h b/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.h
index 49f1e9b..c684fa4 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.h
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.h
@@ -30,24 +30,24 @@
#include <Protocol/I2cBusConfigurationManagement.h>
#include <Protocol/LoadedImage.h>
-#define I2C_DEVICE_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'D')
-#define I2C_HOST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'H')
-#define I2C_REQUEST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'R')
+#define I2C_DEVICE_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'D')
+#define I2C_HOST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'H')
+#define I2C_REQUEST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'R')
//
// Synchronize access to the list of requests
//
-#define TPL_I2C_SYNC TPL_NOTIFY
+#define TPL_I2C_SYNC TPL_NOTIFY
//
// I2C bus context
//
typedef struct {
- EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
- EFI_I2C_HOST_PROTOCOL *I2cHost;
- EFI_HANDLE Controller;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_HANDLE DriverBindingHandle;
+ EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
+ EFI_I2C_HOST_PROTOCOL *I2cHost;
+ EFI_HANDLE Controller;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_HANDLE DriverBindingHandle;
} I2C_BUS_CONTEXT;
//
@@ -57,36 +57,36 @@ typedef struct {
//
// Structure identification
//
- UINT32 Signature;
+ UINT32 Signature;
//
// I2c device handle
//
- EFI_HANDLE Handle;
+ EFI_HANDLE Handle;
//
// Upper level API to support the I2C device I/O
//
- EFI_I2C_IO_PROTOCOL I2cIo;
+ EFI_I2C_IO_PROTOCOL I2cIo;
//
// Device path for this device
//
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Platform specific data for this device
//
- CONST EFI_I2C_DEVICE *I2cDevice;
+ CONST EFI_I2C_DEVICE *I2cDevice;
//
// Context for the common I/O support including the
// lower level API to the host controller.
//
- I2C_BUS_CONTEXT *I2cBusContext;
+ I2C_BUS_CONTEXT *I2cBusContext;
} I2C_DEVICE_CONTEXT;
-#define I2C_DEVICE_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)
+#define I2C_DEVICE_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)
//
// I2C Request
@@ -95,41 +95,41 @@ typedef struct {
//
// Signature
//
- UINT32 Signature;
+ UINT32 Signature;
//
// Next request in the pending request list
//
- LIST_ENTRY Link;
+ LIST_ENTRY Link;
//
// I2C bus configuration for the operation
//
- UINTN I2cBusConfiguration;
+ UINTN I2cBusConfiguration;
//
// I2C slave address for the operation
//
- UINTN SlaveAddress;
+ UINTN SlaveAddress;
//
// Event to set for asynchronous operations, NULL for
// synchronous operations
//
- EFI_EVENT Event;
+ EFI_EVENT Event;
//
// I2C operation description
//
- EFI_I2C_REQUEST_PACKET *RequestPacket;
+ EFI_I2C_REQUEST_PACKET *RequestPacket;
//
// Optional buffer to receive the I2C operation completion status
//
- EFI_STATUS *Status;
+ EFI_STATUS *Status;
} I2C_REQUEST;
-#define I2C_REQUEST_FROM_ENTRY(a) CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);
+#define I2C_REQUEST_FROM_ENTRY(a) CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);
//
// I2C host context
@@ -138,66 +138,66 @@ typedef struct {
//
// Structure identification
//
- UINTN Signature;
+ UINTN Signature;
//
// Current I2C bus configuration
//
- UINTN I2cBusConfiguration;
+ UINTN I2cBusConfiguration;
//
// I2C bus configuration management event
//
- EFI_EVENT I2cBusConfigurationEvent;
+ EFI_EVENT I2cBusConfigurationEvent;
//
// I2C operation completion event
//
- EFI_EVENT I2cEvent;
+ EFI_EVENT I2cEvent;
//
// I2C operation and I2C bus configuration management status
//
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// I2C bus configuration management operation pending
//
- BOOLEAN I2cBusConfigurationManagementPending;
+ BOOLEAN I2cBusConfigurationManagementPending;
//
// I2C request list maintained by I2C Host
//
- LIST_ENTRY RequestList;
+ LIST_ENTRY RequestList;
//
// Upper level API
//
- EFI_I2C_HOST_PROTOCOL I2cHost;
+ EFI_I2C_HOST_PROTOCOL I2cHost;
//
// I2C bus configuration management protocol
//
- EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
+ EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
//
// Lower level API for I2C master (controller)
//
- EFI_I2C_MASTER_PROTOCOL *I2cMaster;
+ EFI_I2C_MASTER_PROTOCOL *I2cMaster;
} I2C_HOST_CONTEXT;
-#define I2C_HOST_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)
+#define I2C_HOST_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)
//
// Global Variables
//
-extern EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2;
-extern EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2;
-extern EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding;
/**
Start the I2C driver
@@ -217,7 +217,7 @@ extern EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding;
EFI_STATUS
RegisterI2cDevice (
IN I2C_BUS_CONTEXT *I2cBus,
- IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
@@ -237,9 +237,9 @@ RegisterI2cDevice (
**/
EFI_STATUS
UnRegisterI2cDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Handle
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Handle
);
/**
@@ -256,8 +256,8 @@ UnRegisterI2cDevice (
**/
EFI_STATUS
I2cBusDevicePathAppend (
- IN I2C_DEVICE_CONTEXT *I2cDeviceContext,
- IN BOOLEAN BuildControllerNode
+ IN I2C_DEVICE_CONTEXT *I2cDeviceContext,
+ IN BOOLEAN BuildControllerNode
);
/**
@@ -514,9 +514,9 @@ I2cBusDriverStop (
EFI_STATUS
EFIAPI
I2cBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
);
/**
@@ -590,11 +590,11 @@ I2cBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
I2cBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
/**
@@ -610,9 +610,9 @@ I2cBusComponentNameGetControllerName (
**/
EFI_STATUS
EFIAPI
-InitializeI2cBus(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeI2cBus (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -630,7 +630,7 @@ InitializeI2cBus(
EFI_STATUS
EFIAPI
I2cBusUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
);
/**
@@ -643,7 +643,7 @@ I2cBusUnload (
**/
VOID
ReleaseI2cDeviceContext (
- IN I2C_DEVICE_CONTEXT *I2cDeviceContext
+ IN I2C_DEVICE_CONTEXT *I2cDeviceContext
);
/**
@@ -657,8 +657,8 @@ ReleaseI2cDeviceContext (
**/
EFI_STATUS
I2cHostRequestComplete (
- I2C_HOST_CONTEXT *I2cHost,
- EFI_STATUS Status
+ I2C_HOST_CONTEXT *I2cHost,
+ EFI_STATUS Status
);
/**
@@ -688,7 +688,7 @@ I2cHostRequestComplete (
**/
EFI_STATUS
I2cHostRequestEnable (
- I2C_HOST_CONTEXT *I2cHost
+ I2C_HOST_CONTEXT *I2cHost
);
/**
@@ -779,9 +779,9 @@ I2cHostDriverSupported (
EFI_STATUS
EFIAPI
I2cHostDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -813,10 +813,10 @@ I2cHostDriverStart (
EFI_STATUS
EFIAPI
I2cHostDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
/**
@@ -861,9 +861,9 @@ I2cHostDriverStop (
EFI_STATUS
EFIAPI
I2cHostComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
);
/**
@@ -937,11 +937,11 @@ I2cHostComponentNameGetDriverName (
EFI_STATUS
EFIAPI
I2cHostComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
/**
@@ -956,8 +956,8 @@ I2cHostComponentNameGetControllerName (
VOID
EFIAPI
I2cHostRequestCompleteEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -972,8 +972,8 @@ I2cHostRequestCompleteEvent (
VOID
EFIAPI
I2cHostI2cBusConfigurationAvailable (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -1065,9 +1065,9 @@ I2cHostQueueRequest (
**/
EFI_STATUS
EFIAPI
-InitializeI2cHost(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeI2cHost (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -1085,7 +1085,7 @@ InitializeI2cHost(
EFI_STATUS
EFIAPI
I2cHostUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
);
-#endif // __I2C_DXE_H__
+#endif // __I2C_DXE_H__
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
index 8dec43b..a4b3302 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
@@ -10,7 +10,7 @@
#include "I2cDxe.h"
-EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding = {
I2cHostDriverSupported,
I2cHostDriverStart,
I2cHostDriverStop,
@@ -22,24 +22,24 @@ EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding = {
//
// Driver name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cHostDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cHostDriverNameTable[] = {
{ "eng;en", L"I2c Host Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName = {
- (EFI_COMPONENT_NAME_GET_DRIVER_NAME) I2cHostComponentNameGetDriverName,
- (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) I2cHostComponentNameGetControllerName,
+ (EFI_COMPONENT_NAME_GET_DRIVER_NAME)I2cHostComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)I2cHostComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2 = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2 = {
I2cHostComponentNameGetDriverName,
I2cHostComponentNameGetControllerName,
"en"
@@ -88,8 +88,8 @@ EFI_STATUS
EFIAPI
I2cHostComponentNameGetDriverName (
IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -172,11 +172,11 @@ I2cHostComponentNameGetDriverName (
EFI_STATUS
EFIAPI
I2cHostComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
@@ -232,9 +232,9 @@ I2cHostDriverSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_I2C_MASTER_PROTOCOL *I2cMaster;
- EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
- EFI_STATUS Status;
+ EFI_I2C_MASTER_PROTOCOL *I2cMaster;
+ EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
+ EFI_STATUS Status;
//
// Locate I2C Bus Configuration Management Protocol
@@ -255,11 +255,11 @@ I2cHostDriverSupported (
// Close the protocol because we don't use it here
//
gBS->CloseProtocol (
- Controller,
- &gEfiI2cBusConfigurationManagementProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cBusConfigurationManagementProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
//
// Locate I2C Master Protocol
@@ -317,15 +317,15 @@ I2cHostDriverSupported (
EFI_STATUS
EFIAPI
I2cHostDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_I2C_MASTER_PROTOCOL *I2cMaster;
- EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
- I2C_HOST_CONTEXT *I2cHostContext;
+ EFI_STATUS Status;
+ EFI_I2C_MASTER_PROTOCOL *I2cMaster;
+ EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
+ I2C_HOST_CONTEXT *I2cHostContext;
I2cMaster = NULL;
I2cHostContext = NULL;
@@ -379,8 +379,8 @@ I2cHostDriverStart (
I2cHostContext->Signature = I2C_HOST_SIGNATURE;
I2cHostContext->I2cMaster = I2cMaster;
I2cHostContext->I2cBusConfigurationManagement = I2cBusConfigurationManagement;
- I2cHostContext->I2cBusConfiguration = (UINTN) -1;
- InitializeListHead(&I2cHostContext->RequestList);
+ I2cHostContext->I2cBusConfiguration = (UINTN)-1;
+ InitializeListHead (&I2cHostContext->RequestList);
//
// Reset the controller
@@ -441,11 +441,11 @@ Exit:
DEBUG ((DEBUG_ERROR, "I2cHost: Start() function failed, Status = %r\n", Status));
if (I2cBusConfigurationManagement != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiI2cBusConfigurationManagementProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiI2cBusConfigurationManagementProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
if ((I2cHostContext != NULL) && (I2cHostContext->I2cEvent != NULL)) {
@@ -501,16 +501,16 @@ Exit:
EFI_STATUS
EFIAPI
I2cHostDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- I2C_HOST_CONTEXT *I2cHostContext;
- EFI_I2C_HOST_PROTOCOL *I2cHost;
- EFI_TPL TplPrevious;
+ EFI_STATUS Status;
+ I2C_HOST_CONTEXT *I2cHostContext;
+ EFI_I2C_HOST_PROTOCOL *I2cHost;
+ EFI_TPL TplPrevious;
TplPrevious = EfiGetCurrentTpl ();
if (TplPrevious > TPL_I2C_SYNC) {
@@ -521,7 +521,7 @@ I2cHostDriverStop (
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cHostProtocolGuid,
- (VOID **) &I2cHost,
+ (VOID **)&I2cHost,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -542,9 +542,9 @@ I2cHostDriverStop (
// If there is pending request or pending bus configuration, do not stop
//
Status = EFI_DEVICE_ERROR;
- if (( !I2cHostContext->I2cBusConfigurationManagementPending )
- && IsListEmpty (&I2cHostContext->RequestList)) {
-
+ if ( (!I2cHostContext->I2cBusConfigurationManagementPending)
+ && IsListEmpty (&I2cHostContext->RequestList))
+ {
//
// Remove the I2C host protocol
//
@@ -602,16 +602,16 @@ I2cHostDriverStop (
VOID
EFIAPI
I2cHostI2cBusConfigurationAvailable (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- I2C_HOST_CONTEXT *I2cHostContext;
- EFI_I2C_MASTER_PROTOCOL *I2cMaster;
- I2C_REQUEST *I2cRequest;
- LIST_ENTRY *EntryHeader;
- LIST_ENTRY *Entry;
- EFI_STATUS Status;
+ I2C_HOST_CONTEXT *I2cHostContext;
+ EFI_I2C_MASTER_PROTOCOL *I2cMaster;
+ I2C_REQUEST *I2cRequest;
+ LIST_ENTRY *EntryHeader;
+ LIST_ENTRY *Entry;
+ EFI_STATUS Status;
//
// Mark this I2C bus configuration management operation as complete
@@ -637,7 +637,7 @@ I2cHostI2cBusConfigurationAvailable (
// Unknown I2C bus configuration
// Force next operation to enable the I2C bus configuration
//
- I2cHostContext->I2cBusConfiguration = (UINTN) -1;
+ I2cHostContext->I2cBusConfiguration = (UINTN)-1;
//
// Do not continue current I2C request
@@ -649,8 +649,8 @@ I2cHostI2cBusConfigurationAvailable (
// Get the first request in the link with FIFO order
//
EntryHeader = &I2cHostContext->RequestList;
- Entry = GetFirstNode (EntryHeader);
- I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
+ Entry = GetFirstNode (EntryHeader);
+ I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
//
// Update the I2C bus configuration of the current I2C request
@@ -669,7 +669,7 @@ I2cHostI2cBusConfigurationAvailable (
);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "I2cHostI2cBusConfigurationAvailable: Error starting I2C operation, %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "I2cHostI2cBusConfigurationAvailable: Error starting I2C operation, %r\n", Status));
}
}
@@ -686,20 +686,20 @@ I2cHostI2cBusConfigurationAvailable (
**/
EFI_STATUS
I2cHostRequestComplete (
- I2C_HOST_CONTEXT *I2cHostContext,
- EFI_STATUS Status
+ I2C_HOST_CONTEXT *I2cHostContext,
+ EFI_STATUS Status
)
{
- I2C_REQUEST *I2cRequest;
- LIST_ENTRY *EntryHeader;
- LIST_ENTRY *Entry;
+ I2C_REQUEST *I2cRequest;
+ LIST_ENTRY *EntryHeader;
+ LIST_ENTRY *Entry;
//
// Remove the current I2C request from the list
//
EntryHeader = &I2cHostContext->RequestList;
- Entry = GetFirstNode (EntryHeader);
- I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
+ Entry = GetFirstNode (EntryHeader);
+ I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
//
// Save the status for QueueRequest
@@ -725,7 +725,7 @@ I2cHostRequestComplete (
//
// If there is more I2C request, start next one
//
- if(!IsListEmpty (EntryHeader)) {
+ if (!IsListEmpty (EntryHeader)) {
I2cHostRequestEnable (I2cHostContext);
}
@@ -744,11 +744,11 @@ I2cHostRequestComplete (
VOID
EFIAPI
I2cHostRequestCompleteEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- I2C_HOST_CONTEXT *I2cHostContext;
+ I2C_HOST_CONTEXT *I2cHostContext;
//
// Handle the completion event
@@ -784,16 +784,16 @@ I2cHostRequestCompleteEvent (
**/
EFI_STATUS
I2cHostRequestEnable (
- I2C_HOST_CONTEXT *I2cHostContext
+ I2C_HOST_CONTEXT *I2cHostContext
)
{
- UINTN I2cBusConfiguration;
- CONST EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
- I2C_REQUEST *I2cRequest;
- EFI_STATUS Status;
- EFI_TPL TplPrevious;
- LIST_ENTRY *EntryHeader;
- LIST_ENTRY *Entry;
+ UINTN I2cBusConfiguration;
+ CONST EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
+ I2C_REQUEST *I2cRequest;
+ EFI_STATUS Status;
+ EFI_TPL TplPrevious;
+ LIST_ENTRY *EntryHeader;
+ LIST_ENTRY *Entry;
//
// Assume pending request
@@ -807,7 +807,7 @@ I2cHostRequestEnable (
//
EntryHeader = &I2cHostContext->RequestList;
Entry = GetFirstNode (EntryHeader);
- I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
+ I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
I2cBusConfiguration = I2cRequest->I2cBusConfiguration;
@@ -820,16 +820,16 @@ I2cHostRequestEnable (
// Update bus configuration for this device's requesting bus configuration
//
Status = I2cBusConfigurationManagement->EnableI2cBusConfiguration (
- I2cBusConfigurationManagement,
- I2cBusConfiguration,
- I2cHostContext->I2cBusConfigurationEvent,
- &I2cHostContext->Status
- );
+ I2cBusConfigurationManagement,
+ I2cBusConfiguration,
+ I2cHostContext->I2cBusConfigurationEvent,
+ &I2cHostContext->Status
+ );
} else {
//
// I2C bus configuration is same, no need change configuration and start I2c transaction directly
//
- TplPrevious = gBS->RaiseTPL ( TPL_I2C_SYNC );
+ TplPrevious = gBS->RaiseTPL (TPL_I2C_SYNC);
//
// Same I2C bus configuration
@@ -840,8 +840,9 @@ I2cHostRequestEnable (
//
// Release the thread synchronization
//
- gBS->RestoreTPL ( TplPrevious );
+ gBS->RestoreTPL (TplPrevious);
}
+
return Status;
}
@@ -965,12 +966,12 @@ I2cHostQueueRequest (
// For synchronous transaction, register an event used to wait for finishing synchronous transaction
//
Status = gBS->CreateEvent (
- 0,
- TPL_I2C_SYNC,
- NULL,
- NULL,
- &SyncEvent
- );
+ 0,
+ TPL_I2C_SYNC,
+ NULL,
+ NULL,
+ &SyncEvent
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1007,7 +1008,7 @@ I2cHostQueueRequest (
//
// Copy request packet into private buffer, as RequestPacket may be freed during asynchronous transaction
//
- RequestPacketSize = sizeof (UINTN) + RequestPacket->OperationCount * sizeof (EFI_I2C_OPERATION);
+ RequestPacketSize = sizeof (UINTN) + RequestPacket->OperationCount * sizeof (EFI_I2C_OPERATION);
I2cRequest->RequestPacket = AllocateZeroPool (RequestPacketSize);
ASSERT (I2cRequest->RequestPacket != NULL);
CopyMem (I2cRequest->RequestPacket, RequestPacket, RequestPacketSize);
@@ -1015,7 +1016,7 @@ I2cHostQueueRequest (
//
// Synchronize with the other threads
//
- gBS->RaiseTPL ( TPL_I2C_SYNC );
+ gBS->RaiseTPL (TPL_I2C_SYNC);
FirstRequest = IsListEmpty (&I2cHostContext->RequestList);
@@ -1085,12 +1086,12 @@ I2cHostQueueRequest (
**/
EFI_STATUS
EFIAPI
-InitializeI2cHost(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeI2cHost (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -1122,15 +1123,15 @@ InitializeI2cHost(
EFI_STATUS
EFIAPI
I2cHostUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE *DeviceHandleBuffer;
- UINTN DeviceHandleCount;
- UINTN Index;
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ EFI_STATUS Status;
+ EFI_HANDLE *DeviceHandleBuffer;
+ UINTN DeviceHandleCount;
+ UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all I2C Controller handles in the handle database.
@@ -1185,7 +1186,7 @@ I2cHostUnload (
Status = gBS->HandleProtocol (
gI2cHostDriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
@@ -1198,7 +1199,7 @@ I2cHostUnload (
Status = gBS->HandleProtocol (
gI2cHostDriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (