aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/nsconvert.c
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2013-03-08 04:23:24 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-03-11 19:45:05 -0400
commit96b44cc684b315dbcf77191809df011067f2e206 (patch)
tree1d0059c72652cf50408d2baa04281ef8e38b20d3 /drivers/acpi/acpica/nsconvert.c
parent76a6225bf0b64572251a8c27d33e84afac6af713 (diff)
ACPICA: Return object repair: Add string-to-unicode conversion
Used for the _STR and _MLS predefined names. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/nsconvert.c')
-rw-r--r--drivers/acpi/acpica/nsconvert.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c
index fcb7dfb494cd..84f66994256f 100644
--- a/drivers/acpi/acpica/nsconvert.c
+++ b/drivers/acpi/acpica/nsconvert.c
@@ -300,3 +300,67 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
300 *return_object = new_object; 300 *return_object = new_object;
301 return (AE_OK); 301 return (AE_OK);
302} 302}
303
304/*******************************************************************************
305 *
306 * FUNCTION: acpi_ns_convert_to_unicode
307 *
308 * PARAMETERS: original_object - ASCII String Object to be converted
309 * return_object - Where the new converted object is returned
310 *
311 * RETURN: Status. AE_OK if conversion was successful.
312 *
313 * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer.
314 *
315 ******************************************************************************/
316
317acpi_status
318acpi_ns_convert_to_unicode(union acpi_operand_object *original_object,
319 union acpi_operand_object **return_object)
320{
321 union acpi_operand_object *new_object;
322 char *ascii_string;
323 u16 *unicode_buffer;
324 u32 unicode_length;
325 u32 i;
326
327 if (!original_object) {
328 return (AE_OK);
329 }
330
331 /* If a Buffer was returned, it must be at least two bytes long */
332
333 if (original_object->common.type == ACPI_TYPE_BUFFER) {
334 if (original_object->buffer.length < 2) {
335 return (AE_AML_OPERAND_VALUE);
336 }
337
338 *return_object = NULL;
339 return (AE_OK);
340 }
341
342 /*
343 * The original object is an ASCII string. Convert this string to
344 * a unicode buffer.
345 */
346 ascii_string = original_object->string.pointer;
347 unicode_length = (original_object->string.length * 2) + 2;
348
349 /* Create a new buffer object for the Unicode data */
350
351 new_object = acpi_ut_create_buffer_object(unicode_length);
352 if (!new_object) {
353 return (AE_NO_MEMORY);
354 }
355
356 unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer);
357
358 /* Convert ASCII to Unicode */
359
360 for (i = 0; i < original_object->string.length; i++) {
361 unicode_buffer[i] = (u16)ascii_string[i];
362 }
363
364 *return_object = new_object;
365 return (AE_OK);
366}