diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2010-06-08 04:48:26 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-06-11 18:54:54 -0400 |
commit | e4e9a735991c80fb0fc1bd4a13a93681c3c17ce0 (patch) | |
tree | dbe98206d9fe79c744e354ab2f4f6dd2473406ed /drivers/acpi/acpica | |
parent | a997ab332832519c2e292db13f509e4360495a5a (diff) |
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>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/achware.h | 3 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpe.c | 7 | ||||
-rw-r--r-- | drivers/acpi/acpica/hwgpe.c | 52 |
3 files changed, 46 insertions, 16 deletions
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h index 5900f135dc6d..c46277d179f0 100644 --- a/drivers/acpi/acpica/achware.h +++ b/drivers/acpi/acpica/achware.h | |||
@@ -90,6 +90,9 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width); | |||
90 | /* | 90 | /* |
91 | * hwgpe - GPE support | 91 | * hwgpe - GPE support |
92 | */ | 92 | */ |
93 | u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, | ||
94 | struct acpi_gpe_register_info *gpe_register_info); | ||
95 | |||
93 | acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); | 96 | acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); |
94 | 97 | ||
95 | acpi_status | 98 | acpi_status |
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index deb26f4c6623..57eeb3bde41e 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -69,7 +69,7 @@ acpi_status | |||
69 | acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) | 69 | acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) |
70 | { | 70 | { |
71 | struct acpi_gpe_register_info *gpe_register_info; | 71 | struct acpi_gpe_register_info *gpe_register_info; |
72 | u8 register_bit; | 72 | u32 register_bit; |
73 | 73 | ||
74 | ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks); | 74 | ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks); |
75 | 75 | ||
@@ -78,9 +78,8 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) | |||
78 | return_ACPI_STATUS(AE_NOT_EXIST); | 78 | return_ACPI_STATUS(AE_NOT_EXIST); |
79 | } | 79 | } |
80 | 80 | ||
81 | register_bit = (u8) | 81 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
82 | (1 << | 82 | gpe_register_info); |
83 | (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); | ||
84 | 83 | ||
85 | /* Clear the wake/run bits up front */ | 84 | /* Clear the wake/run bits up front */ |
86 | 85 | ||
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index bd72319a38f0..d989b8e786cc 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c | |||
@@ -57,6 +57,27 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
57 | 57 | ||
58 | /****************************************************************************** | 58 | /****************************************************************************** |
59 | * | 59 | * |
60 | * FUNCTION: acpi_hw_gpe_register_bit | ||
61 | * | ||
62 | * PARAMETERS: gpe_event_info - Info block for the GPE | ||
63 | * gpe_register_info - Info block for the GPE register | ||
64 | * | ||
65 | * RETURN: Status | ||
66 | * | ||
67 | * DESCRIPTION: Compute GPE enable mask with one bit corresponding to the given | ||
68 | * GPE set. | ||
69 | * | ||
70 | ******************************************************************************/ | ||
71 | |||
72 | u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, | ||
73 | struct acpi_gpe_register_info *gpe_register_info) | ||
74 | { | ||
75 | return (u32)1 << (gpe_event_info->gpe_number - | ||
76 | gpe_register_info->base_gpe_number); | ||
77 | } | ||
78 | |||
79 | /****************************************************************************** | ||
80 | * | ||
60 | * FUNCTION: acpi_hw_low_disable_gpe | 81 | * FUNCTION: acpi_hw_low_disable_gpe |
61 | * | 82 | * |
62 | * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled | 83 | * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled |
@@ -72,6 +93,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
72 | struct acpi_gpe_register_info *gpe_register_info; | 93 | struct acpi_gpe_register_info *gpe_register_info; |
73 | acpi_status status; | 94 | acpi_status status; |
74 | u32 enable_mask; | 95 | u32 enable_mask; |
96 | u32 register_bit; | ||
75 | 97 | ||
76 | /* Get the info block for the entire GPE register */ | 98 | /* Get the info block for the entire GPE register */ |
77 | 99 | ||
@@ -89,9 +111,9 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
89 | 111 | ||
90 | /* Clear just the bit that corresponds to this GPE */ | 112 | /* Clear just the bit that corresponds to this GPE */ |
91 | 113 | ||
92 | ACPI_CLEAR_BIT(enable_mask, ((u32)1 << | 114 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
93 | (gpe_event_info->gpe_number - | 115 | gpe_register_info); |
94 | gpe_register_info->base_gpe_number))); | 116 | ACPI_CLEAR_BIT(enable_mask, register_bit); |
95 | 117 | ||
96 | /* Write the updated enable mask */ | 118 | /* Write the updated enable mask */ |
97 | 119 | ||
@@ -150,21 +172,28 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info) | |||
150 | 172 | ||
151 | acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) | 173 | acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) |
152 | { | 174 | { |
175 | struct acpi_gpe_register_info *gpe_register_info; | ||
153 | acpi_status status; | 176 | acpi_status status; |
154 | u8 register_bit; | 177 | u32 register_bit; |
155 | 178 | ||
156 | ACPI_FUNCTION_ENTRY(); | 179 | ACPI_FUNCTION_ENTRY(); |
157 | 180 | ||
158 | register_bit = (u8)(1 << | 181 | /* Get the info block for the entire GPE register */ |
159 | (gpe_event_info->gpe_number - | 182 | |
160 | gpe_event_info->register_info->base_gpe_number)); | 183 | gpe_register_info = gpe_event_info->register_info; |
184 | if (!gpe_register_info) { | ||
185 | return (AE_NOT_EXIST); | ||
186 | } | ||
187 | |||
188 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, | ||
189 | gpe_register_info); | ||
161 | 190 | ||
162 | /* | 191 | /* |
163 | * Write a one to the appropriate bit in the status register to | 192 | * Write a one to the appropriate bit in the status register to |
164 | * clear this GPE. | 193 | * clear this GPE. |
165 | */ | 194 | */ |
166 | status = acpi_hw_write(register_bit, | 195 | status = acpi_hw_write(register_bit, |
167 | &gpe_event_info->register_info->status_address); | 196 | &gpe_register_info->status_address); |
168 | 197 | ||
169 | return (status); | 198 | return (status); |
170 | } | 199 | } |
@@ -187,7 +216,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | |||
187 | acpi_event_status * event_status) | 216 | acpi_event_status * event_status) |
188 | { | 217 | { |
189 | u32 in_byte; | 218 | u32 in_byte; |
190 | u8 register_bit; | 219 | u32 register_bit; |
191 | struct acpi_gpe_register_info *gpe_register_info; | 220 | struct acpi_gpe_register_info *gpe_register_info; |
192 | acpi_status status; | 221 | acpi_status status; |
193 | acpi_event_status local_event_status = 0; | 222 | acpi_event_status local_event_status = 0; |
@@ -204,9 +233,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | |||
204 | 233 | ||
205 | /* Get the register bitmask for this GPE */ | 234 | /* Get the register bitmask for this GPE */ |
206 | 235 | ||
207 | register_bit = (u8)(1 << | 236 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
208 | (gpe_event_info->gpe_number - | 237 | gpe_register_info); |
209 | gpe_event_info->register_info->base_gpe_number)); | ||
210 | 238 | ||
211 | /* GPE currently enabled? (enabled for runtime?) */ | 239 | /* GPE currently enabled? (enabled for runtime?) */ |
212 | 240 | ||