diff options
Diffstat (limited to 'drivers/acpi/resources/rsutils.c')
-rw-r--r-- | drivers/acpi/resources/rsutils.c | 88 |
1 files changed, 21 insertions, 67 deletions
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 7613033f5dcf..a1eac0f1df54 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c | |||
@@ -65,6 +65,8 @@ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list) | |||
65 | acpi_native_uint i; | 65 | acpi_native_uint i; |
66 | u8 bit_count; | 66 | u8 bit_count; |
67 | 67 | ||
68 | ACPI_FUNCTION_ENTRY(); | ||
69 | |||
68 | /* Decode the mask bits */ | 70 | /* Decode the mask bits */ |
69 | 71 | ||
70 | for (i = 0, bit_count = 0; mask; i++) { | 72 | for (i = 0, bit_count = 0; mask; i++) { |
@@ -97,6 +99,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) | |||
97 | acpi_native_uint i; | 99 | acpi_native_uint i; |
98 | u16 mask; | 100 | u16 mask; |
99 | 101 | ||
102 | ACPI_FUNCTION_ENTRY(); | ||
103 | |||
100 | /* Encode the list into a single bitmask */ | 104 | /* Encode the list into a single bitmask */ |
101 | 105 | ||
102 | for (i = 0, mask = 0; i < count; i++) { | 106 | for (i = 0, mask = 0; i < count; i++) { |
@@ -128,6 +132,8 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) | |||
128 | { | 132 | { |
129 | acpi_native_uint i; | 133 | acpi_native_uint i; |
130 | 134 | ||
135 | ACPI_FUNCTION_ENTRY(); | ||
136 | |||
131 | /* One move per item */ | 137 | /* One move per item */ |
132 | 138 | ||
133 | for (i = 0; i < item_count; i++) { | 139 | for (i = 0; i < item_count; i++) { |
@@ -168,53 +174,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) | |||
168 | 174 | ||
169 | /******************************************************************************* | 175 | /******************************************************************************* |
170 | * | 176 | * |
171 | * FUNCTION: acpi_rs_get_resource_info | ||
172 | * | ||
173 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
174 | * | ||
175 | * RETURN: Pointer to the resource conversion handler | ||
176 | * | ||
177 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
178 | * a resource descriptor. | ||
179 | * | ||
180 | ******************************************************************************/ | ||
181 | |||
182 | struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) | ||
183 | { | ||
184 | struct acpi_resource_info *size_info; | ||
185 | |||
186 | ACPI_FUNCTION_ENTRY(); | ||
187 | |||
188 | /* Determine if this is a small or large resource */ | ||
189 | |||
190 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
191 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
192 | |||
193 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { | ||
194 | return (NULL); | ||
195 | } | ||
196 | |||
197 | size_info = &acpi_gbl_lg_resource_info[(resource_type & | ||
198 | ACPI_RESOURCE_NAME_LARGE_MASK)]; | ||
199 | } else { | ||
200 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
201 | |||
202 | size_info = &acpi_gbl_sm_resource_info[((resource_type & | ||
203 | ACPI_RESOURCE_NAME_SMALL_MASK) | ||
204 | >> 3)]; | ||
205 | } | ||
206 | |||
207 | /* Zero entry indicates an invalid resource type */ | ||
208 | |||
209 | if (!size_info->minimum_internal_struct_length) { | ||
210 | return (NULL); | ||
211 | } | ||
212 | |||
213 | return (size_info); | ||
214 | } | ||
215 | |||
216 | /******************************************************************************* | ||
217 | * | ||
218 | * FUNCTION: acpi_rs_set_resource_length | 177 | * FUNCTION: acpi_rs_set_resource_length |
219 | * | 178 | * |
220 | * PARAMETERS: total_length - Length of the AML descriptor, including | 179 | * PARAMETERS: total_length - Length of the AML descriptor, including |
@@ -238,25 +197,20 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length, | |||
238 | 197 | ||
239 | ACPI_FUNCTION_ENTRY(); | 198 | ACPI_FUNCTION_ENTRY(); |
240 | 199 | ||
241 | /* Determine if this is a small or large resource */ | 200 | /* Length is the total descriptor length minus the header length */ |
242 | 201 | ||
243 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | 202 | resource_length = (acpi_rs_length) |
244 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | 203 | (total_length - acpi_ut_get_resource_header_length(aml)); |
245 | 204 | ||
246 | resource_length = (acpi_rs_length) | 205 | /* Length is stored differently for large and small descriptors */ |
247 | (total_length - sizeof(struct aml_resource_large_header)); | ||
248 | 206 | ||
249 | /* Insert length into the Large descriptor length field */ | 207 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
208 | /* Large descriptor -- bytes 1-2 contain the 16-bit length */ | ||
250 | 209 | ||
251 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, | 210 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, |
252 | &resource_length); | 211 | &resource_length); |
253 | } else { | 212 | } else { |
254 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | 213 | /* Small descriptor -- bits 2:0 of byte 0 contain the length */ |
255 | |||
256 | resource_length = (acpi_rs_length) | ||
257 | (total_length - sizeof(struct aml_resource_small_header)); | ||
258 | |||
259 | /* Insert length into the descriptor type byte */ | ||
260 | 214 | ||
261 | aml->small_header.descriptor_type = (u8) | 215 | aml->small_header.descriptor_type = (u8) |
262 | 216 | ||
@@ -292,7 +246,7 @@ acpi_rs_set_resource_header(u8 descriptor_type, | |||
292 | { | 246 | { |
293 | ACPI_FUNCTION_ENTRY(); | 247 | ACPI_FUNCTION_ENTRY(); |
294 | 248 | ||
295 | /* Set the Descriptor Type */ | 249 | /* Set the Resource Type */ |
296 | 250 | ||
297 | aml->small_header.descriptor_type = descriptor_type; | 251 | aml->small_header.descriptor_type = descriptor_type; |
298 | 252 | ||
@@ -409,14 +363,14 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, | |||
409 | (char *)&aml_resource_source[1]); | 363 | (char *)&aml_resource_source[1]); |
410 | 364 | ||
411 | return ((acpi_rs_length) total_length); | 365 | return ((acpi_rs_length) total_length); |
412 | } else { | ||
413 | /* resource_source is not present */ | ||
414 | |||
415 | resource_source->index = 0; | ||
416 | resource_source->string_length = 0; | ||
417 | resource_source->string_ptr = NULL; | ||
418 | return (0); | ||
419 | } | 366 | } |
367 | |||
368 | /* resource_source is not present */ | ||
369 | |||
370 | resource_source->index = 0; | ||
371 | resource_source->string_length = 0; | ||
372 | resource_source->string_ptr = NULL; | ||
373 | return (0); | ||
420 | } | 374 | } |
421 | 375 | ||
422 | /******************************************************************************* | 376 | /******************************************************************************* |