===================================================================
@@ -168,6 +168,33 @@ acpi_status acpi_ev_disable_gpe(struct a
return_ACPI_STATUS(status);
}
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ev_get_info
+ *
+ * PARAMETERS: gpe_block - GPE block to search
+ * gpe_number - Raw GPE number
+ *
+ * RETURN: A GPE event_info struct if found. NULL if not found
+ *
+ ******************************************************************************/
+
+static struct acpi_gpe_event_info *acpi_ev_get_info(
+ struct acpi_gpe_block_info *gpe_block,
+ u32 gpe_number)
+{
+ u32 gpe_index, gpe_count;
+
+ if (!gpe_block || gpe_number < gpe_block->block_base_number)
+ return (NULL);
+
+ gpe_index = gpe_number - gpe_block->block_base_number;
+ gpe_count = gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH;
+ return gpe_index < gpe_count ?
+ (&gpe_block->event_info[gpe_index]) : (NULL);
+}
+
/*******************************************************************************
*
* FUNCTION: acpi_ev_get_gpe_event_info
@@ -189,7 +216,7 @@ struct acpi_gpe_event_info *acpi_ev_get_
u32 gpe_number)
{
union acpi_operand_object *obj_desc;
- struct acpi_gpe_block_info *gpe_block;
+ struct acpi_gpe_event_info *gpe_info;
u32 i;
ACPI_FUNCTION_ENTRY();
@@ -201,18 +228,10 @@ struct acpi_gpe_event_info *acpi_ev_get_
/* Examine GPE Block 0 and 1 (These blocks are permanent) */
for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
- gpe_block = acpi_gbl_gpe_fadt_blocks[i];
- if (gpe_block) {
- if ((gpe_number >= gpe_block->block_base_number)
- && (gpe_number <
- gpe_block->block_base_number +
- (gpe_block->register_count * 8))) {
- return (&gpe_block->
- event_info[gpe_number -
- gpe_block->
- block_base_number]);
- }
- }
+ gpe_info = acpi_ev_get_info(acpi_gbl_gpe_fadt_blocks[i],
+ gpe_number);
+ if (gpe_info)
+ return (gpe_info);
}
/* The gpe_number was not in the range of either FADT GPE block */
@@ -228,16 +247,7 @@ struct acpi_gpe_event_info *acpi_ev_get_
return (NULL);
}
- gpe_block = obj_desc->device.gpe_block;
-
- if ((gpe_number >= gpe_block->block_base_number) &&
- (gpe_number <
- gpe_block->block_base_number + (gpe_block->register_count * 8))) {
- return (&gpe_block->
- event_info[gpe_number - gpe_block->block_base_number]);
- }
-
- return (NULL);
+ return acpi_ev_get_info(obj_desc->device.gpe_block, gpe_number);
}
/*******************************************************************************