Commit f3c365e4 authored by Andy Grover's avatar Andy Grover

ACPI: Eliminate use of acpi_gpl_gpe_number_info (Matthew Wilcox)

parent 5cb3ab55
......@@ -255,7 +255,7 @@ acpi_ev_gpe_initialize (void)
ACPI_HIDWORD (acpi_gbl_gpe_block_info[gpe_block].block_address->address),
ACPI_LODWORD (acpi_gbl_gpe_block_info[gpe_block].block_address->address)));
ACPI_REPORT_INFO (("GPE Block%d defined as GPE%d to GPE%d\n",
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE Block%d defined as GPE%d to GPE%d\n",
(s32) gpe_block,
(u32) acpi_gbl_gpe_block_info[gpe_block].block_base_number,
(u32) (acpi_gbl_gpe_block_info[gpe_block].block_base_number +
......@@ -307,7 +307,7 @@ acpi_ev_save_method_info (
void **return_value)
{
u32 gpe_number;
u32 gpe_number_index;
struct acpi_gpe_number_info *gpe_number_info;
char name[ACPI_NAME_SIZE + 1];
u8 type;
acpi_status status;
......@@ -357,19 +357,22 @@ acpi_ev_save_method_info (
/* Get GPE index and ensure that we have a valid GPE number */
gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
if (gpe_number_index == ACPI_GPE_INVALID) {
gpe_number_info = acpi_ev_get_gpe_number_info (gpe_number);
if (!gpe_number_info) {
/* Not valid, all we can do here is ignore it */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"GPE number associated with method is not valid %s\n",
name));
return (AE_OK);
}
/*
* Now we can add this information to the gpe_info block
* Now we can add this information to the gpe_number_info block
* for use during dispatch of this GPE.
*/
acpi_gbl_gpe_number_info [gpe_number_index].type = type;
acpi_gbl_gpe_number_info [gpe_number_index].method_node = (struct acpi_namespace_node *) obj_handle;
gpe_number_info->type = type;
gpe_number_info->method_node = (struct acpi_namespace_node *) obj_handle;
/*
* Enable the GPE (SCIs should be disabled at this point)
......@@ -532,7 +535,7 @@ acpi_ev_asynch_execute_gpe_method (
{
u32 gpe_number = (u32) ACPI_TO_INTEGER (context);
u32 gpe_number_index;
struct acpi_gpe_number_info gpe_info;
struct acpi_gpe_number_info gpe_number_info;
acpi_status status;
......@@ -553,26 +556,26 @@ acpi_ev_asynch_execute_gpe_method (
return_VOID;
}
gpe_info = acpi_gbl_gpe_number_info [gpe_number_index];
gpe_number_info = acpi_gbl_gpe_number_info [gpe_number_index];
status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_VOID;
}
if (gpe_info.method_node) {
if (gpe_number_info.method_node) {
/*
* Invoke the GPE Method (_Lxx, _Exx):
* (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.)
*/
status = acpi_ns_evaluate_by_handle (gpe_info.method_node, NULL, NULL);
status = acpi_ns_evaluate_by_handle (gpe_number_info.method_node, NULL, NULL);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2.2X]\n",
acpi_format_exception (status),
gpe_info.method_node->name.ascii, gpe_number));
gpe_number_info.method_node->name.ascii, gpe_number));
}
}
if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
if (gpe_number_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
/*
* GPE is level-triggered, we clear the GPE status bit after handling
* the event.
......@@ -609,31 +612,28 @@ u32
acpi_ev_gpe_dispatch (
u32 gpe_number)
{
u32 gpe_number_index;
struct acpi_gpe_number_info *gpe_info;
struct acpi_gpe_number_info *gpe_number_info;
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
if (gpe_number_index == ACPI_GPE_INVALID) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GPE[%X] is not a valid event\n", gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
}
/*
* We don't have to worry about mutex on gpe_info because we are
* We don't have to worry about mutex on gpe_number_info because we are
* executing at interrupt level.
*/
gpe_info = &acpi_gbl_gpe_number_info [gpe_number_index];
gpe_number_info = acpi_ev_get_gpe_number_info (gpe_number);
if (!gpe_number_info) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GPE[%X] is not a valid event\n", gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
}
/*
* If edge-triggered, clear the GPE status bit now. Note that
* level-triggered events are cleared after the GPE is serviced.
*/
if (gpe_info->type & ACPI_EVENT_EDGE_TRIGGERED) {
if (gpe_number_info->type & ACPI_EVENT_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_number);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to clear GPE[%2.2X]\n", gpe_number));
......@@ -648,12 +648,12 @@ acpi_ev_gpe_dispatch (
* If there is neither a handler nor a method, we disable the level to
* prevent further events from coming in here.
*/
if (gpe_info->handler) {
if (gpe_number_info->handler) {
/* Invoke the installed handler (at interrupt level) */
gpe_info->handler (gpe_info->context);
gpe_number_info->handler (gpe_number_info->context);
}
else if (gpe_info->method_node) {
else if (gpe_number_info->method_node) {
/*
* Disable GPE, so it doesn't keep firing before the method has a
* chance to run.
......@@ -692,7 +692,7 @@ acpi_ev_gpe_dispatch (
/*
* It is now safe to clear level-triggered evnets.
*/
if (gpe_info->type & ACPI_EVENT_LEVEL_TRIGGERED) {
if (gpe_number_info->type & ACPI_EVENT_LEVEL_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_number);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: Unable to clear GPE[%2.2X]\n", gpe_number));
......
......@@ -67,27 +67,53 @@ acpi_ev_is_notify_object (
/*******************************************************************************
*
* FUNCTION: acpi_ev_get_gpe_register_index
* FUNCTION: acpi_ev_get_gpe_register_info
*
* PARAMETERS: gpe_number - Raw GPE number
*
* RETURN: None.
* RETURN: Pointer to the info struct for this GPE register.
*
* DESCRIPTION: Returns the register index (index into the GPE register info
* table) associated with this GPE.
*
******************************************************************************/
u32
acpi_ev_get_gpe_register_index (
struct acpi_gpe_register_info *
acpi_ev_get_gpe_register_info (
u32 gpe_number)
{
if (gpe_number > acpi_gbl_gpe_number_max) {
return (ACPI_GPE_INVALID);
return (NULL);
}
return (&acpi_gbl_gpe_register_info [ACPI_DIV_8 (acpi_gbl_gpe_number_to_index[gpe_number].number_index)]);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_get_gpe_number_info
*
* PARAMETERS: gpe_number - Raw GPE number
*
* RETURN: None.
*
* DESCRIPTION: Returns the number index (index into the GPE number info table)
* associated with this GPE.
*
******************************************************************************/
struct acpi_gpe_number_info *
acpi_ev_get_gpe_number_info (
u32 gpe_number)
{
if (gpe_number > acpi_gbl_gpe_number_max) {
return (NULL);
}
return (ACPI_DIV_8 (acpi_gbl_gpe_number_to_index[gpe_number].number_index));
return (&acpi_gbl_gpe_number_info [acpi_gbl_gpe_number_to_index[gpe_number].number_index]);
}
......
......@@ -473,7 +473,7 @@ acpi_install_gpe_handler (
void *context)
{
acpi_status status;
u32 gpe_number_index;
struct acpi_gpe_number_info *gpe_number_info;
ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
......@@ -487,8 +487,8 @@ acpi_install_gpe_handler (
/* Ensure that we have a valid GPE number */
gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
if (gpe_number_index == ACPI_GPE_INVALID) {
gpe_number_info = acpi_ev_get_gpe_number_info (gpe_number);
if (!gpe_number_info) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
......@@ -499,16 +499,16 @@ acpi_install_gpe_handler (
/* Make sure that there isn't a handler there already */
if (acpi_gbl_gpe_number_info[gpe_number_index].handler) {
if (gpe_number_info->handler) {
status = AE_ALREADY_EXISTS;
goto cleanup;
}
/* Install the handler */
acpi_gbl_gpe_number_info[gpe_number_index].handler = handler;
acpi_gbl_gpe_number_info[gpe_number_index].context = context;
acpi_gbl_gpe_number_info[gpe_number_index].type = (u8) type;
gpe_number_info->handler = handler;
gpe_number_info->context = context;
gpe_number_info->type = (u8) type;
/* Clear the GPE (of stale events), the enable it */
......@@ -545,7 +545,7 @@ acpi_remove_gpe_handler (
acpi_gpe_handler handler)
{
acpi_status status;
u32 gpe_number_index;
struct acpi_gpe_number_info *gpe_number_info;
ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
......@@ -559,8 +559,8 @@ acpi_remove_gpe_handler (
/* Ensure that we have a valid GPE number */
gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
if (gpe_number_index == ACPI_GPE_INVALID) {
gpe_number_info = acpi_ev_get_gpe_number_info (gpe_number);
if (!gpe_number_info) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
......@@ -578,7 +578,7 @@ acpi_remove_gpe_handler (
/* Make sure that the installed handler is the same */
if (acpi_gbl_gpe_number_info[gpe_number_index].handler != handler) {
if (gpe_number_info->handler != handler) {
(void) acpi_hw_enable_gpe (gpe_number);
status = AE_BAD_PARAMETER;
goto cleanup;
......@@ -586,8 +586,8 @@ acpi_remove_gpe_handler (
/* Remove the handler */
acpi_gbl_gpe_number_info[gpe_number_index].handler = NULL;
acpi_gbl_gpe_number_info[gpe_number_index].context = NULL;
gpe_number_info->handler = NULL;
gpe_number_info->context = NULL;
cleanup:
......
......@@ -67,34 +67,34 @@ acpi_hw_enable_gpe (
u32 gpe_number)
{
u32 in_byte;
u32 register_index;
u8 bit_mask;
acpi_status status;
struct acpi_gpe_register_info *gpe_register_info;
ACPI_FUNCTION_ENTRY ();
/* Translate GPE number to index into global registers array. */
/* Get the info block for the entire GPE register */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
/* Get the register bitmask for this GPE */
bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/*
* Read the current value of the register, set the appropriate bit
* to enable the GPE, and write out the new register.
*/
status = acpi_hw_low_level_read (8, &in_byte,
&acpi_gbl_gpe_register_info[register_index].enable_address, 0);
&gpe_register_info->enable_address, 0);
if (ACPI_FAILURE (status)) {
return (status);
}
status = acpi_hw_low_level_write (8, (in_byte | bit_mask),
&acpi_gbl_gpe_register_info[register_index].enable_address, 0);
/* Write with the new GPE bit enabled */
status = acpi_hw_low_level_write (8, (in_byte | acpi_hw_get_gpe_bit_mask (gpe_number)),
&gpe_register_info->enable_address, 0);
return (status);
}
......@@ -117,25 +117,23 @@ void
acpi_hw_enable_gpe_for_wakeup (
u32 gpe_number)
{
u32 register_index;
u8 bit_mask;
struct acpi_gpe_register_info *gpe_register_info;
ACPI_FUNCTION_ENTRY ();
/* Translate GPE number to index into global registers array. */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
/* Get the register bitmask for this GPE */
/* Get the info block for the entire GPE register */
bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return;
}
/*
* Set the bit so we will not disable this when sleeping
*/
acpi_gbl_gpe_register_info[register_index].wake_enable |= bit_mask;
gpe_register_info->wake_enable |= acpi_hw_get_gpe_bit_mask (gpe_number);
}
......@@ -156,34 +154,34 @@ acpi_hw_disable_gpe (
u32 gpe_number)
{
u32 in_byte;
u32 register_index;
u8 bit_mask;
acpi_status status;
struct acpi_gpe_register_info *gpe_register_info;
ACPI_FUNCTION_ENTRY ();
/* Translate GPE number to index into global registers array. */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
/* Get the info block for the entire GPE register */
/* Get the register bitmask for this GPE */
bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/*
* Read the current value of the register, clear the appropriate bit,
* and write out the new register value to disable the GPE.
*/
status = acpi_hw_low_level_read (8, &in_byte,
&acpi_gbl_gpe_register_info[register_index].enable_address, 0);
&gpe_register_info->enable_address, 0);
if (ACPI_FAILURE (status)) {
return (status);
}
status = acpi_hw_low_level_write (8, (in_byte & ~bit_mask),
&acpi_gbl_gpe_register_info[register_index].enable_address, 0);
/* Write the byte with this GPE bit cleared */
status = acpi_hw_low_level_write (8, (in_byte & ~(acpi_hw_get_gpe_bit_mask (gpe_number))),
&gpe_register_info->enable_address, 0);
if (ACPI_FAILURE (status)) {
return (status);
}
......@@ -210,25 +208,23 @@ void
acpi_hw_disable_gpe_for_wakeup (
u32 gpe_number)
{
u32 register_index;
u8 bit_mask;
struct acpi_gpe_register_info *gpe_register_info;
ACPI_FUNCTION_ENTRY ();
/* Translate GPE number to index into global registers array. */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
/* Get the register bitmask for this GPE */
/* Get the info block for the entire GPE register */
bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return;
}
/*
* Clear the bit so we will disable this when sleeping
*/
acpi_gbl_gpe_register_info[register_index].wake_enable &= ~bit_mask;
gpe_register_info->wake_enable &= ~(acpi_hw_get_gpe_bit_mask (gpe_number));
}
......@@ -248,28 +244,26 @@ acpi_status
acpi_hw_clear_gpe (
u32 gpe_number)
{
u32 register_index;
u8 bit_mask;
acpi_status status;
struct acpi_gpe_register_info *gpe_register_info;
ACPI_FUNCTION_ENTRY ();
/* Translate GPE number to index into global registers array. */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
/* Get the register bitmask for this GPE */
/* Get the info block for the entire GPE register */
bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/*
* Write a one to the appropriate bit in the status register to
* clear this GPE.
*/
status = acpi_hw_low_level_write (8, bit_mask,
&acpi_gbl_gpe_register_info[register_index].status_address, 0);
status = acpi_hw_low_level_write (8, acpi_hw_get_gpe_bit_mask (gpe_number),
&gpe_register_info->status_address, 0);
return (status);
}
......@@ -292,11 +286,11 @@ acpi_hw_get_gpe_status (
u32 gpe_number,
acpi_event_status *event_status)
{
u32 in_byte = 0;
u32 register_index = 0;
u8 bit_mask = 0;
u32 in_byte;
u8 bit_mask;
struct acpi_gpe_register_info *gpe_register_info;
acpi_status status;
acpi_event_status local_event_status = 0;
ACPI_FUNCTION_ENTRY ();
......@@ -306,12 +300,12 @@ acpi_hw_get_gpe_status (
return (AE_BAD_PARAMETER);
}
(*event_status) = 0;
/* Get the info block for the entire GPE register */
/* Translate GPE number to index into global registers array. */
register_index = acpi_ev_get_gpe_register_index (gpe_number);
gpe_register_info = &acpi_gbl_gpe_register_info[register_index];
gpe_register_info = acpi_ev_get_gpe_register_info (gpe_number);
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/* Get the register bitmask for this GPE */
......@@ -325,13 +319,13 @@ acpi_hw_get_gpe_status (
}
if (bit_mask & in_byte) {
(*event_status) |= ACPI_EVENT_FLAG_ENABLED;
local_event_status |= ACPI_EVENT_FLAG_ENABLED;
}
/* GPE Enabled for wake? */
if (bit_mask & gpe_register_info->wake_enable) {
(*event_status) |= ACPI_EVENT_FLAG_WAKE_ENABLED;
local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED;
}
/* GPE active (set)? */
......@@ -342,8 +336,12 @@ acpi_hw_get_gpe_status (
}
if (bit_mask & in_byte) {
(*event_status) |= ACPI_EVENT_FLAG_SET;
local_event_status |= ACPI_EVENT_FLAG_SET;
}
/* Set return value */
(*event_status) = local_event_status;
return (AE_OK);
}
......@@ -378,7 +376,12 @@ acpi_hw_disable_non_wakeup_gpes (
for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
/* Get the info block for the entire GPE register */
gpe_register_info = &acpi_gbl_gpe_register_info[i];
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/*
* Read the enabled status of all GPEs. We
......@@ -430,7 +433,12 @@ acpi_hw_enable_non_wakeup_gpes (
for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
/* Get the info block for the entire GPE register */
gpe_register_info = &acpi_gbl_gpe_register_info[i];
if (!gpe_register_info) {
return (AE_BAD_PARAMETER);
}
/*
* We previously stored the enabled status of all GPEs.
......
......@@ -72,8 +72,12 @@ acpi_status
acpi_ev_init_global_lock_handler (
void);
u32
acpi_ev_get_gpe_register_index (
struct acpi_gpe_register_info *
acpi_ev_get_gpe_register_info (
u32 gpe_number);
struct acpi_gpe_number_info *
acpi_ev_get_gpe_number_info (
u32 gpe_number);
u32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment