diff options
Diffstat (limited to 'drivers/acpi/executer/exstorob.c')
-rw-r--r-- | drivers/acpi/executer/exstorob.c | 86 |
1 files changed, 36 insertions, 50 deletions
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index 12d1527669c8..c4ff654a6697 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c | |||
@@ -42,14 +42,11 @@ | |||
42 | * POSSIBILITY OF SUCH DAMAGES. | 42 | * POSSIBILITY OF SUCH DAMAGES. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | |||
46 | #include <acpi/acpi.h> | 45 | #include <acpi/acpi.h> |
47 | #include <acpi/acinterp.h> | 46 | #include <acpi/acinterp.h> |
48 | 47 | ||
49 | |||
50 | #define _COMPONENT ACPI_EXECUTER | 48 | #define _COMPONENT ACPI_EXECUTER |
51 | ACPI_MODULE_NAME ("exstorob") | 49 | ACPI_MODULE_NAME("exstorob") |
52 | |||
53 | 50 | ||
54 | /******************************************************************************* | 51 | /******************************************************************************* |
55 | * | 52 | * |
@@ -63,18 +60,14 @@ | |||
63 | * DESCRIPTION: Copy a buffer object to another buffer object. | 60 | * DESCRIPTION: Copy a buffer object to another buffer object. |
64 | * | 61 | * |
65 | ******************************************************************************/ | 62 | ******************************************************************************/ |
66 | |||
67 | acpi_status | 63 | acpi_status |
68 | acpi_ex_store_buffer_to_buffer ( | 64 | acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, |
69 | union acpi_operand_object *source_desc, | 65 | union acpi_operand_object *target_desc) |
70 | union acpi_operand_object *target_desc) | ||
71 | { | 66 | { |
72 | u32 length; | 67 | u32 length; |
73 | u8 *buffer; | 68 | u8 *buffer; |
74 | |||
75 | |||
76 | ACPI_FUNCTION_TRACE_PTR ("ex_store_buffer_to_buffer", source_desc); | ||
77 | 69 | ||
70 | ACPI_FUNCTION_TRACE_PTR("ex_store_buffer_to_buffer", source_desc); | ||
78 | 71 | ||
79 | /* We know that source_desc is a buffer by now */ | 72 | /* We know that source_desc is a buffer by now */ |
80 | 73 | ||
@@ -86,10 +79,10 @@ acpi_ex_store_buffer_to_buffer ( | |||
86 | * allocate a new buffer of the proper length | 79 | * allocate a new buffer of the proper length |
87 | */ | 80 | */ |
88 | if ((target_desc->buffer.length == 0) || | 81 | if ((target_desc->buffer.length == 0) || |
89 | (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { | 82 | (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { |
90 | target_desc->buffer.pointer = ACPI_MEM_ALLOCATE (length); | 83 | target_desc->buffer.pointer = ACPI_MEM_ALLOCATE(length); |
91 | if (!target_desc->buffer.pointer) { | 84 | if (!target_desc->buffer.pointer) { |
92 | return_ACPI_STATUS (AE_NO_MEMORY); | 85 | return_ACPI_STATUS(AE_NO_MEMORY); |
93 | } | 86 | } |
94 | 87 | ||
95 | target_desc->buffer.length = length; | 88 | target_desc->buffer.length = length; |
@@ -100,8 +93,9 @@ acpi_ex_store_buffer_to_buffer ( | |||
100 | if (length <= target_desc->buffer.length) { | 93 | if (length <= target_desc->buffer.length) { |
101 | /* Clear existing buffer and copy in the new one */ | 94 | /* Clear existing buffer and copy in the new one */ |
102 | 95 | ||
103 | ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length); | 96 | ACPI_MEMSET(target_desc->buffer.pointer, 0, |
104 | ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length); | 97 | target_desc->buffer.length); |
98 | ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length); | ||
105 | 99 | ||
106 | #ifdef ACPI_OBSOLETE_BEHAVIOR | 100 | #ifdef ACPI_OBSOLETE_BEHAVIOR |
107 | /* | 101 | /* |
@@ -124,26 +118,24 @@ acpi_ex_store_buffer_to_buffer ( | |||
124 | target_desc->buffer.length = length; | 118 | target_desc->buffer.length = length; |
125 | } | 119 | } |
126 | #endif | 120 | #endif |
127 | } | 121 | } else { |
128 | else { | ||
129 | /* Truncate the source, copy only what will fit */ | 122 | /* Truncate the source, copy only what will fit */ |
130 | 123 | ||
131 | ACPI_MEMCPY (target_desc->buffer.pointer, buffer, | 124 | ACPI_MEMCPY(target_desc->buffer.pointer, buffer, |
132 | target_desc->buffer.length); | 125 | target_desc->buffer.length); |
133 | 126 | ||
134 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, | 127 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
135 | "Truncating source buffer from %X to %X\n", | 128 | "Truncating source buffer from %X to %X\n", |
136 | length, target_desc->buffer.length)); | 129 | length, target_desc->buffer.length)); |
137 | } | 130 | } |
138 | 131 | ||
139 | /* Copy flags */ | 132 | /* Copy flags */ |
140 | 133 | ||
141 | target_desc->buffer.flags = source_desc->buffer.flags; | 134 | target_desc->buffer.flags = source_desc->buffer.flags; |
142 | target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; | 135 | target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; |
143 | return_ACPI_STATUS (AE_OK); | 136 | return_ACPI_STATUS(AE_OK); |
144 | } | 137 | } |
145 | 138 | ||
146 | |||
147 | /******************************************************************************* | 139 | /******************************************************************************* |
148 | * | 140 | * |
149 | * FUNCTION: acpi_ex_store_string_to_string | 141 | * FUNCTION: acpi_ex_store_string_to_string |
@@ -158,16 +150,13 @@ acpi_ex_store_buffer_to_buffer ( | |||
158 | ******************************************************************************/ | 150 | ******************************************************************************/ |
159 | 151 | ||
160 | acpi_status | 152 | acpi_status |
161 | acpi_ex_store_string_to_string ( | 153 | acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, |
162 | union acpi_operand_object *source_desc, | 154 | union acpi_operand_object *target_desc) |
163 | union acpi_operand_object *target_desc) | ||
164 | { | 155 | { |
165 | u32 length; | 156 | u32 length; |
166 | u8 *buffer; | 157 | u8 *buffer; |
167 | |||
168 | |||
169 | ACPI_FUNCTION_TRACE_PTR ("ex_store_string_to_string", source_desc); | ||
170 | 158 | ||
159 | ACPI_FUNCTION_TRACE_PTR("ex_store_string_to_string", source_desc); | ||
171 | 160 | ||
172 | /* We know that source_desc is a string by now */ | 161 | /* We know that source_desc is a string by now */ |
173 | 162 | ||
@@ -179,41 +168,38 @@ acpi_ex_store_string_to_string ( | |||
179 | * pointer is not a static pointer (part of an ACPI table) | 168 | * pointer is not a static pointer (part of an ACPI table) |
180 | */ | 169 | */ |
181 | if ((length < target_desc->string.length) && | 170 | if ((length < target_desc->string.length) && |
182 | (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | 171 | (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { |
183 | /* | 172 | /* |
184 | * String will fit in existing non-static buffer. | 173 | * String will fit in existing non-static buffer. |
185 | * Clear old string and copy in the new one | 174 | * Clear old string and copy in the new one |
186 | */ | 175 | */ |
187 | ACPI_MEMSET (target_desc->string.pointer, 0, | 176 | ACPI_MEMSET(target_desc->string.pointer, 0, |
188 | (acpi_size) target_desc->string.length + 1); | 177 | (acpi_size) target_desc->string.length + 1); |
189 | ACPI_MEMCPY (target_desc->string.pointer, buffer, length); | 178 | ACPI_MEMCPY(target_desc->string.pointer, buffer, length); |
190 | } | 179 | } else { |
191 | else { | ||
192 | /* | 180 | /* |
193 | * Free the current buffer, then allocate a new buffer | 181 | * Free the current buffer, then allocate a new buffer |
194 | * large enough to hold the value | 182 | * large enough to hold the value |
195 | */ | 183 | */ |
196 | if (target_desc->string.pointer && | 184 | if (target_desc->string.pointer && |
197 | (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | 185 | (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { |
198 | /* Only free if not a pointer into the DSDT */ | 186 | /* Only free if not a pointer into the DSDT */ |
199 | 187 | ||
200 | ACPI_MEM_FREE (target_desc->string.pointer); | 188 | ACPI_MEM_FREE(target_desc->string.pointer); |
201 | } | 189 | } |
202 | 190 | ||
203 | target_desc->string.pointer = ACPI_MEM_CALLOCATE ( | 191 | target_desc->string.pointer = ACPI_MEM_CALLOCATE((acpi_size) |
204 | (acpi_size) length + 1); | 192 | length + 1); |
205 | if (!target_desc->string.pointer) { | 193 | if (!target_desc->string.pointer) { |
206 | return_ACPI_STATUS (AE_NO_MEMORY); | 194 | return_ACPI_STATUS(AE_NO_MEMORY); |
207 | } | 195 | } |
208 | 196 | ||
209 | target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; | 197 | target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; |
210 | ACPI_MEMCPY (target_desc->string.pointer, buffer, length); | 198 | ACPI_MEMCPY(target_desc->string.pointer, buffer, length); |
211 | } | 199 | } |
212 | 200 | ||
213 | /* Set the new target length */ | 201 | /* Set the new target length */ |
214 | 202 | ||
215 | target_desc->string.length = length; | 203 | target_desc->string.length = length; |
216 | return_ACPI_STATUS (AE_OK); | 204 | return_ACPI_STATUS(AE_OK); |
217 | } | 205 | } |
218 | |||
219 | |||