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/hwgpe.c | |
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/hwgpe.c')
-rw-r--r-- | drivers/acpi/acpica/hwgpe.c | 52 |
1 files changed, 40 insertions, 12 deletions
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 | ||