ACPI / ACPICA: Use helper function for computing GPE masks
In quite a few places ACPICA needs to compute a GPE enable mask with only one bit, corresponding to a given GPE, set. Currently, that computation is always open coded which leads to unnecessary code duplication. Fix this by introducing a helper function for computing one-bit GPE enable masks and using it where appropriate. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
a997ab3328
commit
e4e9a73599
|
@ -90,6 +90,9 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
|
||||||
/*
|
/*
|
||||||
* hwgpe - GPE support
|
* hwgpe - GPE support
|
||||||
*/
|
*/
|
||||||
|
u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
|
||||||
|
struct acpi_gpe_register_info *gpe_register_info);
|
||||||
|
|
||||||
acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
|
acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
|
||||||
|
|
||||||
acpi_status
|
acpi_status
|
||||||
|
|
|
@ -69,7 +69,7 @@ acpi_status
|
||||||
acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
|
acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
|
||||||
{
|
{
|
||||||
struct acpi_gpe_register_info *gpe_register_info;
|
struct acpi_gpe_register_info *gpe_register_info;
|
||||||
u8 register_bit;
|
u32 register_bit;
|
||||||
|
|
||||||
ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks);
|
ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks);
|
||||||
|
|
||||||
|
@ -78,9 +78,8 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
|
||||||
return_ACPI_STATUS(AE_NOT_EXIST);
|
return_ACPI_STATUS(AE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
register_bit = (u8)
|
register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
|
||||||
(1 <<
|
gpe_register_info);
|
||||||
(gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
|
|
||||||
|
|
||||||
/* Clear the wake/run bits up front */
|
/* Clear the wake/run bits up front */
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,27 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
|
||||||
struct acpi_gpe_block_info *gpe_block,
|
struct acpi_gpe_block_info *gpe_block,
|
||||||
void *context);
|
void *context);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: acpi_hw_gpe_register_bit
|
||||||
|
*
|
||||||
|
* PARAMETERS: gpe_event_info - Info block for the GPE
|
||||||
|
* gpe_register_info - Info block for the GPE register
|
||||||
|
*
|
||||||
|
* RETURN: Status
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Compute GPE enable mask with one bit corresponding to the given
|
||||||
|
* GPE set.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
|
||||||
|
struct acpi_gpe_register_info *gpe_register_info)
|
||||||
|
{
|
||||||
|
return (u32)1 << (gpe_event_info->gpe_number -
|
||||||
|
gpe_register_info->base_gpe_number);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* FUNCTION: acpi_hw_low_disable_gpe
|
* FUNCTION: acpi_hw_low_disable_gpe
|
||||||
|
@ -72,6 +93,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
|
||||||
struct acpi_gpe_register_info *gpe_register_info;
|
struct acpi_gpe_register_info *gpe_register_info;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
u32 enable_mask;
|
u32 enable_mask;
|
||||||
|
u32 register_bit;
|
||||||
|
|
||||||
/* Get the info block for the entire GPE register */
|
/* Get the info block for the entire GPE register */
|
||||||
|
|
||||||
|
@ -89,9 +111,9 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
|
||||||
|
|
||||||
/* Clear just the bit that corresponds to this GPE */
|
/* Clear just the bit that corresponds to this GPE */
|
||||||
|
|
||||||
ACPI_CLEAR_BIT(enable_mask, ((u32)1 <<
|
register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
|
||||||
(gpe_event_info->gpe_number -
|
gpe_register_info);
|
||||||
gpe_register_info->base_gpe_number)));
|
ACPI_CLEAR_BIT(enable_mask, register_bit);
|
||||||
|
|
||||||
/* Write the updated enable mask */
|
/* Write the updated enable mask */
|
||||||
|
|
||||||
|
@ -150,21 +172,28 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
|
||||||
|
|
||||||
acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
|
acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
|
||||||
{
|
{
|
||||||
|
struct acpi_gpe_register_info *gpe_register_info;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
u8 register_bit;
|
u32 register_bit;
|
||||||
|
|
||||||
ACPI_FUNCTION_ENTRY();
|
ACPI_FUNCTION_ENTRY();
|
||||||
|
|
||||||
register_bit = (u8)(1 <<
|
/* Get the info block for the entire GPE register */
|
||||||
(gpe_event_info->gpe_number -
|
|
||||||
gpe_event_info->register_info->base_gpe_number));
|
gpe_register_info = gpe_event_info->register_info;
|
||||||
|
if (!gpe_register_info) {
|
||||||
|
return (AE_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
|
||||||
|
gpe_register_info);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a one to the appropriate bit in the status register to
|
* Write a one to the appropriate bit in the status register to
|
||||||
* clear this GPE.
|
* clear this GPE.
|
||||||
*/
|
*/
|
||||||
status = acpi_hw_write(register_bit,
|
status = acpi_hw_write(register_bit,
|
||||||
&gpe_event_info->register_info->status_address);
|
&gpe_register_info->status_address);
|
||||||
|
|
||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +216,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
|
||||||
acpi_event_status * event_status)
|
acpi_event_status * event_status)
|
||||||
{
|
{
|
||||||
u32 in_byte;
|
u32 in_byte;
|
||||||
u8 register_bit;
|
u32 register_bit;
|
||||||
struct acpi_gpe_register_info *gpe_register_info;
|
struct acpi_gpe_register_info *gpe_register_info;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
acpi_event_status local_event_status = 0;
|
acpi_event_status local_event_status = 0;
|
||||||
|
@ -204,9 +233,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
|
||||||
|
|
||||||
/* Get the register bitmask for this GPE */
|
/* Get the register bitmask for this GPE */
|
||||||
|
|
||||||
register_bit = (u8)(1 <<
|
register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
|
||||||
(gpe_event_info->gpe_number -
|
gpe_register_info);
|
||||||
gpe_event_info->register_info->base_gpe_number));
|
|
||||||
|
|
||||||
/* GPE currently enabled? (enabled for runtime?) */
|
/* GPE currently enabled? (enabled for runtime?) */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue