Skip to content

Commit

Permalink
Remove some code duplication from AcpiEvAddressSpaceDispatch
Browse files Browse the repository at this point in the history
The handling of the SpaceId == ACPI_ADR_SPACE_GSBUS and
SpaceId == ACPI_ADR_SPACE_GPIO cases is almost identical,
fold the 2 cases into 1 to remove some code duplication.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede committed Jan 6, 2021
1 parent c9e0116 commit 383f50f
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions source/components/events/evregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ AcpiEvAddressSpaceDispatch (
* the previous Connection)
* 2) BitWidth is the actual bit length of the field (number of pins)
*/
if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) &&
if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO) &&
Context &&
FieldObj)
{
Expand All @@ -420,27 +421,12 @@ AcpiEvAddressSpaceDispatch (
Context->Connection = FieldObj->Field.ResourceBuffer;
Context->Length = FieldObj->Field.ResourceLength;
Context->AccessLength = FieldObj->Field.AccessLength;
}
if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO) &&
Context &&
FieldObj)
{

Status = AcpiOsAcquireMutex (ContextMutex, ACPI_WAIT_FOREVER);
if (ACPI_FAILURE (Status))
if (RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)
{
goto ReEnterInterpreter;
Address = FieldObj->Field.PinNumberIndex;
BitWidth = FieldObj->Field.BitLength;
}

ContextLocked = TRUE;

/* Get the Connection (ResourceTemplate) buffer */

Context->Connection = FieldObj->Field.ResourceBuffer;
Context->Length = FieldObj->Field.ResourceLength;
Context->AccessLength = FieldObj->Field.AccessLength;
Address = FieldObj->Field.PinNumberIndex;
BitWidth = FieldObj->Field.BitLength;
}

/* Call the handler */
Expand Down

0 comments on commit 383f50f

Please sign in to comment.