195857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
215b8dd53SBob Moore /******************************************************************************
315b8dd53SBob Moore *
4f65358e5SSuravee Suthikulpanit * Module Name: utids - support for device Ids - HID, UID, CID, SUB, CLS
515b8dd53SBob Moore *
6*612c2932SBob Moore * Copyright (C) 2000 - 2023, Intel Corp.
715b8dd53SBob Moore *
895857638SErik Schmauss *****************************************************************************/
915b8dd53SBob Moore
1015b8dd53SBob Moore #include <acpi/acpi.h>
1115b8dd53SBob Moore #include "accommon.h"
1215b8dd53SBob Moore #include "acinterp.h"
1315b8dd53SBob Moore
1415b8dd53SBob Moore #define _COMPONENT ACPI_UTILITIES
1515b8dd53SBob Moore ACPI_MODULE_NAME("utids")
1615b8dd53SBob Moore
1715b8dd53SBob Moore /*******************************************************************************
1815b8dd53SBob Moore *
1915b8dd53SBob Moore * FUNCTION: acpi_ut_execute_HID
2015b8dd53SBob Moore *
2115b8dd53SBob Moore * PARAMETERS: device_node - Node for the device
2215b8dd53SBob Moore * return_id - Where the string HID is returned
2315b8dd53SBob Moore *
2415b8dd53SBob Moore * RETURN: Status
2515b8dd53SBob Moore *
2615b8dd53SBob Moore * DESCRIPTION: Executes the _HID control method that returns the hardware
2715b8dd53SBob Moore * ID of the device. The HID is either an 32-bit encoded EISAID
2815b8dd53SBob Moore * Integer or a String. A string is always returned. An EISAID
2915b8dd53SBob Moore * is converted to a string.
3015b8dd53SBob Moore *
3115b8dd53SBob Moore * NOTE: Internal function, no parameter validation
3215b8dd53SBob Moore *
3315b8dd53SBob Moore ******************************************************************************/
3415b8dd53SBob Moore acpi_status
acpi_ut_execute_HID(struct acpi_namespace_node * device_node,struct acpi_pnp_device_id ** return_id)3515b8dd53SBob Moore acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
3678e25fefSLv Zheng struct acpi_pnp_device_id **return_id)
3715b8dd53SBob Moore {
3815b8dd53SBob Moore union acpi_operand_object *obj_desc;
3978e25fefSLv Zheng struct acpi_pnp_device_id *hid;
4015b8dd53SBob Moore u32 length;
4115b8dd53SBob Moore acpi_status status;
4215b8dd53SBob Moore
4315b8dd53SBob Moore ACPI_FUNCTION_TRACE(ut_execute_HID);
4415b8dd53SBob Moore
4515b8dd53SBob Moore status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
4615b8dd53SBob Moore ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
4715b8dd53SBob Moore &obj_desc);
4815b8dd53SBob Moore if (ACPI_FAILURE(status)) {
4915b8dd53SBob Moore return_ACPI_STATUS(status);
5015b8dd53SBob Moore }
5115b8dd53SBob Moore
5215b8dd53SBob Moore /* Get the size of the String to be returned, includes null terminator */
5315b8dd53SBob Moore
5415b8dd53SBob Moore if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
5515b8dd53SBob Moore length = ACPI_EISAID_STRING_SIZE;
5615b8dd53SBob Moore } else {
5715b8dd53SBob Moore length = obj_desc->string.length + 1;
5815b8dd53SBob Moore }
5915b8dd53SBob Moore
6015b8dd53SBob Moore /* Allocate a buffer for the HID */
6115b8dd53SBob Moore
6215b8dd53SBob Moore hid =
6378e25fefSLv Zheng ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
6415b8dd53SBob Moore (acpi_size)length);
6515b8dd53SBob Moore if (!hid) {
6615b8dd53SBob Moore status = AE_NO_MEMORY;
6715b8dd53SBob Moore goto cleanup;
6815b8dd53SBob Moore }
6915b8dd53SBob Moore
7078e25fefSLv Zheng /* Area for the string starts after PNP_DEVICE_ID struct */
7115b8dd53SBob Moore
7278e25fefSLv Zheng hid->string =
7378e25fefSLv Zheng ACPI_ADD_PTR(char, hid, sizeof(struct acpi_pnp_device_id));
7415b8dd53SBob Moore
7515b8dd53SBob Moore /* Convert EISAID to a string or simply copy existing string */
7615b8dd53SBob Moore
7715b8dd53SBob Moore if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
7815b8dd53SBob Moore acpi_ex_eisa_id_to_string(hid->string, obj_desc->integer.value);
7915b8dd53SBob Moore } else {
804fa4616eSBob Moore strcpy(hid->string, obj_desc->string.pointer);
8115b8dd53SBob Moore }
8215b8dd53SBob Moore
8315b8dd53SBob Moore hid->length = length;
8415b8dd53SBob Moore *return_id = hid;
8515b8dd53SBob Moore
8615b8dd53SBob Moore cleanup:
8715b8dd53SBob Moore
8815b8dd53SBob Moore /* On exit, we must delete the return object */
8915b8dd53SBob Moore
9015b8dd53SBob Moore acpi_ut_remove_reference(obj_desc);
9115b8dd53SBob Moore return_ACPI_STATUS(status);
9215b8dd53SBob Moore }
9315b8dd53SBob Moore
9415b8dd53SBob Moore /*******************************************************************************
9515b8dd53SBob Moore *
9615b8dd53SBob Moore * FUNCTION: acpi_ut_execute_UID
9715b8dd53SBob Moore *
9815b8dd53SBob Moore * PARAMETERS: device_node - Node for the device
9915b8dd53SBob Moore * return_id - Where the string UID is returned
10015b8dd53SBob Moore *
10115b8dd53SBob Moore * RETURN: Status
10215b8dd53SBob Moore *
10315b8dd53SBob Moore * DESCRIPTION: Executes the _UID control method that returns the unique
10415b8dd53SBob Moore * ID of the device. The UID is either a 64-bit Integer (NOT an
10515b8dd53SBob Moore * EISAID) or a string. Always returns a string. A 64-bit integer
10615b8dd53SBob Moore * is converted to a decimal string.
10715b8dd53SBob Moore *
10815b8dd53SBob Moore * NOTE: Internal function, no parameter validation
10915b8dd53SBob Moore *
11015b8dd53SBob Moore ******************************************************************************/
11115b8dd53SBob Moore
11215b8dd53SBob Moore acpi_status
acpi_ut_execute_UID(struct acpi_namespace_node * device_node,struct acpi_pnp_device_id ** return_id)11315b8dd53SBob Moore acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
11478e25fefSLv Zheng struct acpi_pnp_device_id **return_id)
11515b8dd53SBob Moore {
11615b8dd53SBob Moore union acpi_operand_object *obj_desc;
11778e25fefSLv Zheng struct acpi_pnp_device_id *uid;
11815b8dd53SBob Moore u32 length;
11915b8dd53SBob Moore acpi_status status;
12015b8dd53SBob Moore
12115b8dd53SBob Moore ACPI_FUNCTION_TRACE(ut_execute_UID);
12215b8dd53SBob Moore
12315b8dd53SBob Moore status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
12415b8dd53SBob Moore ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
12515b8dd53SBob Moore &obj_desc);
12615b8dd53SBob Moore if (ACPI_FAILURE(status)) {
12715b8dd53SBob Moore return_ACPI_STATUS(status);
12815b8dd53SBob Moore }
12915b8dd53SBob Moore
13015b8dd53SBob Moore /* Get the size of the String to be returned, includes null terminator */
13115b8dd53SBob Moore
13215b8dd53SBob Moore if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
13315b8dd53SBob Moore length = ACPI_MAX64_DECIMAL_DIGITS + 1;
13415b8dd53SBob Moore } else {
13515b8dd53SBob Moore length = obj_desc->string.length + 1;
13615b8dd53SBob Moore }
13715b8dd53SBob Moore
13815b8dd53SBob Moore /* Allocate a buffer for the UID */
13915b8dd53SBob Moore
14015b8dd53SBob Moore uid =
14178e25fefSLv Zheng ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
14215b8dd53SBob Moore (acpi_size)length);
14315b8dd53SBob Moore if (!uid) {
14415b8dd53SBob Moore status = AE_NO_MEMORY;
14515b8dd53SBob Moore goto cleanup;
14615b8dd53SBob Moore }
14715b8dd53SBob Moore
14878e25fefSLv Zheng /* Area for the string starts after PNP_DEVICE_ID struct */
14915b8dd53SBob Moore
15078e25fefSLv Zheng uid->string =
15178e25fefSLv Zheng ACPI_ADD_PTR(char, uid, sizeof(struct acpi_pnp_device_id));
15215b8dd53SBob Moore
15315b8dd53SBob Moore /* Convert an Integer to string, or just copy an existing string */
15415b8dd53SBob Moore
15515b8dd53SBob Moore if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
15615b8dd53SBob Moore acpi_ex_integer_to_string(uid->string, obj_desc->integer.value);
15715b8dd53SBob Moore } else {
1584fa4616eSBob Moore strcpy(uid->string, obj_desc->string.pointer);
15915b8dd53SBob Moore }
16015b8dd53SBob Moore
16115b8dd53SBob Moore uid->length = length;
16215b8dd53SBob Moore *return_id = uid;
16315b8dd53SBob Moore
16415b8dd53SBob Moore cleanup:
16515b8dd53SBob Moore
16615b8dd53SBob Moore /* On exit, we must delete the return object */
16715b8dd53SBob Moore
16815b8dd53SBob Moore acpi_ut_remove_reference(obj_desc);
16915b8dd53SBob Moore return_ACPI_STATUS(status);
17015b8dd53SBob Moore }
17115b8dd53SBob Moore
17215b8dd53SBob Moore /*******************************************************************************
17315b8dd53SBob Moore *
17415b8dd53SBob Moore * FUNCTION: acpi_ut_execute_CID
17515b8dd53SBob Moore *
17615b8dd53SBob Moore * PARAMETERS: device_node - Node for the device
17715b8dd53SBob Moore * return_cid_list - Where the CID list is returned
17815b8dd53SBob Moore *
17915b8dd53SBob Moore * RETURN: Status, list of CID strings
18015b8dd53SBob Moore *
18115b8dd53SBob Moore * DESCRIPTION: Executes the _CID control method that returns one or more
18215b8dd53SBob Moore * compatible hardware IDs for the device.
18315b8dd53SBob Moore *
18415b8dd53SBob Moore * NOTE: Internal function, no parameter validation
18515b8dd53SBob Moore *
18615b8dd53SBob Moore * A _CID method can return either a single compatible ID or a package of
18715b8dd53SBob Moore * compatible IDs. Each compatible ID can be one of the following:
18815b8dd53SBob Moore * 1) Integer (32 bit compressed EISA ID) or
18915b8dd53SBob Moore * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
19015b8dd53SBob Moore *
19115b8dd53SBob Moore * The Integer CIDs are converted to string format by this function.
19215b8dd53SBob Moore *
19315b8dd53SBob Moore ******************************************************************************/
19415b8dd53SBob Moore
19515b8dd53SBob Moore acpi_status
acpi_ut_execute_CID(struct acpi_namespace_node * device_node,struct acpi_pnp_device_id_list ** return_cid_list)19615b8dd53SBob Moore acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
19778e25fefSLv Zheng struct acpi_pnp_device_id_list **return_cid_list)
19815b8dd53SBob Moore {
19915b8dd53SBob Moore union acpi_operand_object **cid_objects;
20015b8dd53SBob Moore union acpi_operand_object *obj_desc;
20178e25fefSLv Zheng struct acpi_pnp_device_id_list *cid_list;
20215b8dd53SBob Moore char *next_id_string;
20315b8dd53SBob Moore u32 string_area_size;
20415b8dd53SBob Moore u32 length;
20515b8dd53SBob Moore u32 cid_list_size;
20615b8dd53SBob Moore acpi_status status;
20715b8dd53SBob Moore u32 count;
20815b8dd53SBob Moore u32 i;
20915b8dd53SBob Moore
21015b8dd53SBob Moore ACPI_FUNCTION_TRACE(ut_execute_CID);
21115b8dd53SBob Moore
21215b8dd53SBob Moore /* Evaluate the _CID method for this device */
21315b8dd53SBob Moore
21415b8dd53SBob Moore status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
21515b8dd53SBob Moore ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
21615b8dd53SBob Moore | ACPI_BTYPE_PACKAGE, &obj_desc);
21715b8dd53SBob Moore if (ACPI_FAILURE(status)) {
21815b8dd53SBob Moore return_ACPI_STATUS(status);
21915b8dd53SBob Moore }
22015b8dd53SBob Moore
22115b8dd53SBob Moore /*
22215b8dd53SBob Moore * Get the count and size of the returned _CIDs. _CID can return either
22315b8dd53SBob Moore * a Package of Integers/Strings or a single Integer or String.
22415b8dd53SBob Moore * Note: This section also validates that all CID elements are of the
22515b8dd53SBob Moore * correct type (Integer or String).
22615b8dd53SBob Moore */
22715b8dd53SBob Moore if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
22815b8dd53SBob Moore count = obj_desc->package.count;
22915b8dd53SBob Moore cid_objects = obj_desc->package.elements;
23015b8dd53SBob Moore } else { /* Single Integer or String CID */
23115b8dd53SBob Moore
23215b8dd53SBob Moore count = 1;
23315b8dd53SBob Moore cid_objects = &obj_desc;
23415b8dd53SBob Moore }
23515b8dd53SBob Moore
23615b8dd53SBob Moore string_area_size = 0;
23715b8dd53SBob Moore for (i = 0; i < count; i++) {
23815b8dd53SBob Moore
23915b8dd53SBob Moore /* String lengths include null terminator */
24015b8dd53SBob Moore
24115b8dd53SBob Moore switch (cid_objects[i]->common.type) {
24215b8dd53SBob Moore case ACPI_TYPE_INTEGER:
2431d1ea1b7SChao Guan
24415b8dd53SBob Moore string_area_size += ACPI_EISAID_STRING_SIZE;
24515b8dd53SBob Moore break;
24615b8dd53SBob Moore
24715b8dd53SBob Moore case ACPI_TYPE_STRING:
2481d1ea1b7SChao Guan
24915b8dd53SBob Moore string_area_size += cid_objects[i]->string.length + 1;
25015b8dd53SBob Moore break;
25115b8dd53SBob Moore
25215b8dd53SBob Moore default:
2531d1ea1b7SChao Guan
25415b8dd53SBob Moore status = AE_TYPE;
25515b8dd53SBob Moore goto cleanup;
25615b8dd53SBob Moore }
25715b8dd53SBob Moore }
25815b8dd53SBob Moore
25915b8dd53SBob Moore /*
26015b8dd53SBob Moore * Now that we know the length of the CIDs, allocate return buffer:
26115b8dd53SBob Moore * 1) Size of the base structure +
26278e25fefSLv Zheng * 2) Size of the CID PNP_DEVICE_ID array +
26315b8dd53SBob Moore * 3) Size of the actual CID strings
26415b8dd53SBob Moore */
26578e25fefSLv Zheng cid_list_size = sizeof(struct acpi_pnp_device_id_list) +
26610cfde5dSGustavo A. R. Silva (count * sizeof(struct acpi_pnp_device_id)) + string_area_size;
26715b8dd53SBob Moore
26815b8dd53SBob Moore cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size);
26915b8dd53SBob Moore if (!cid_list) {
27015b8dd53SBob Moore status = AE_NO_MEMORY;
27115b8dd53SBob Moore goto cleanup;
27215b8dd53SBob Moore }
27315b8dd53SBob Moore
27478e25fefSLv Zheng /* Area for CID strings starts after the CID PNP_DEVICE_ID array */
27515b8dd53SBob Moore
27615b8dd53SBob Moore next_id_string = ACPI_CAST_PTR(char, cid_list->ids) +
27778e25fefSLv Zheng ((acpi_size)count * sizeof(struct acpi_pnp_device_id));
27815b8dd53SBob Moore
27915b8dd53SBob Moore /* Copy/convert the CIDs to the return buffer */
28015b8dd53SBob Moore
28115b8dd53SBob Moore for (i = 0; i < count; i++) {
28215b8dd53SBob Moore if (cid_objects[i]->common.type == ACPI_TYPE_INTEGER) {
28315b8dd53SBob Moore
28415b8dd53SBob Moore /* Convert the Integer (EISAID) CID to a string */
28515b8dd53SBob Moore
28615b8dd53SBob Moore acpi_ex_eisa_id_to_string(next_id_string,
28715b8dd53SBob Moore cid_objects[i]->integer.
28815b8dd53SBob Moore value);
28915b8dd53SBob Moore length = ACPI_EISAID_STRING_SIZE;
29015b8dd53SBob Moore } else { /* ACPI_TYPE_STRING */
29115b8dd53SBob Moore /* Copy the String CID from the returned object */
2924fa4616eSBob Moore strcpy(next_id_string, cid_objects[i]->string.pointer);
29315b8dd53SBob Moore length = cid_objects[i]->string.length + 1;
29415b8dd53SBob Moore }
29515b8dd53SBob Moore
29615b8dd53SBob Moore cid_list->ids[i].string = next_id_string;
29715b8dd53SBob Moore cid_list->ids[i].length = length;
29815b8dd53SBob Moore next_id_string += length;
29915b8dd53SBob Moore }
30015b8dd53SBob Moore
30115b8dd53SBob Moore /* Finish the CID list */
30215b8dd53SBob Moore
30315b8dd53SBob Moore cid_list->count = count;
30415b8dd53SBob Moore cid_list->list_size = cid_list_size;
30515b8dd53SBob Moore *return_cid_list = cid_list;
30615b8dd53SBob Moore
30715b8dd53SBob Moore cleanup:
30815b8dd53SBob Moore
30915b8dd53SBob Moore /* On exit, we must delete the _CID return object */
31015b8dd53SBob Moore
31115b8dd53SBob Moore acpi_ut_remove_reference(obj_desc);
31215b8dd53SBob Moore return_ACPI_STATUS(status);
31315b8dd53SBob Moore }
314f65358e5SSuravee Suthikulpanit
315f65358e5SSuravee Suthikulpanit /*******************************************************************************
316f65358e5SSuravee Suthikulpanit *
317f65358e5SSuravee Suthikulpanit * FUNCTION: acpi_ut_execute_CLS
318f65358e5SSuravee Suthikulpanit *
319f65358e5SSuravee Suthikulpanit * PARAMETERS: device_node - Node for the device
320f65358e5SSuravee Suthikulpanit * return_id - Where the _CLS is returned
321f65358e5SSuravee Suthikulpanit *
322f65358e5SSuravee Suthikulpanit * RETURN: Status
323f65358e5SSuravee Suthikulpanit *
324f65358e5SSuravee Suthikulpanit * DESCRIPTION: Executes the _CLS control method that returns PCI-defined
325f65358e5SSuravee Suthikulpanit * class code of the device. The _CLS value is always a package
326f65358e5SSuravee Suthikulpanit * containing PCI class information as a list of integers.
327f65358e5SSuravee Suthikulpanit * The returned string has format "BBSSPP", where:
328f65358e5SSuravee Suthikulpanit * BB = Base-class code
329f65358e5SSuravee Suthikulpanit * SS = Sub-class code
330f65358e5SSuravee Suthikulpanit * PP = Programming Interface code
331f65358e5SSuravee Suthikulpanit *
332f65358e5SSuravee Suthikulpanit ******************************************************************************/
333f65358e5SSuravee Suthikulpanit
334f65358e5SSuravee Suthikulpanit acpi_status
acpi_ut_execute_CLS(struct acpi_namespace_node * device_node,struct acpi_pnp_device_id ** return_id)335f65358e5SSuravee Suthikulpanit acpi_ut_execute_CLS(struct acpi_namespace_node *device_node,
336f65358e5SSuravee Suthikulpanit struct acpi_pnp_device_id **return_id)
337f65358e5SSuravee Suthikulpanit {
338f65358e5SSuravee Suthikulpanit union acpi_operand_object *obj_desc;
339f65358e5SSuravee Suthikulpanit union acpi_operand_object **cls_objects;
340f65358e5SSuravee Suthikulpanit u32 count;
341f65358e5SSuravee Suthikulpanit struct acpi_pnp_device_id *cls;
342f65358e5SSuravee Suthikulpanit u32 length;
343f65358e5SSuravee Suthikulpanit acpi_status status;
344f65358e5SSuravee Suthikulpanit u8 class_code[3] = { 0, 0, 0 };
345f65358e5SSuravee Suthikulpanit
346f65358e5SSuravee Suthikulpanit ACPI_FUNCTION_TRACE(ut_execute_CLS);
347f65358e5SSuravee Suthikulpanit
348f65358e5SSuravee Suthikulpanit status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CLS,
349f65358e5SSuravee Suthikulpanit ACPI_BTYPE_PACKAGE, &obj_desc);
350f65358e5SSuravee Suthikulpanit if (ACPI_FAILURE(status)) {
351f65358e5SSuravee Suthikulpanit return_ACPI_STATUS(status);
352f65358e5SSuravee Suthikulpanit }
353f65358e5SSuravee Suthikulpanit
354f65358e5SSuravee Suthikulpanit /* Get the size of the String to be returned, includes null terminator */
355f65358e5SSuravee Suthikulpanit
356f65358e5SSuravee Suthikulpanit length = ACPI_PCICLS_STRING_SIZE;
357f65358e5SSuravee Suthikulpanit cls_objects = obj_desc->package.elements;
358f65358e5SSuravee Suthikulpanit count = obj_desc->package.count;
359f65358e5SSuravee Suthikulpanit
360f65358e5SSuravee Suthikulpanit if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
361f65358e5SSuravee Suthikulpanit if (count > 0
362f65358e5SSuravee Suthikulpanit && cls_objects[0]->common.type == ACPI_TYPE_INTEGER) {
363f65358e5SSuravee Suthikulpanit class_code[0] = (u8)cls_objects[0]->integer.value;
364f65358e5SSuravee Suthikulpanit }
365f65358e5SSuravee Suthikulpanit if (count > 1
366f65358e5SSuravee Suthikulpanit && cls_objects[1]->common.type == ACPI_TYPE_INTEGER) {
367f65358e5SSuravee Suthikulpanit class_code[1] = (u8)cls_objects[1]->integer.value;
368f65358e5SSuravee Suthikulpanit }
369f65358e5SSuravee Suthikulpanit if (count > 2
370f65358e5SSuravee Suthikulpanit && cls_objects[2]->common.type == ACPI_TYPE_INTEGER) {
371f65358e5SSuravee Suthikulpanit class_code[2] = (u8)cls_objects[2]->integer.value;
372f65358e5SSuravee Suthikulpanit }
373f65358e5SSuravee Suthikulpanit }
374f65358e5SSuravee Suthikulpanit
375f65358e5SSuravee Suthikulpanit /* Allocate a buffer for the CLS */
376f65358e5SSuravee Suthikulpanit
377f65358e5SSuravee Suthikulpanit cls =
378f65358e5SSuravee Suthikulpanit ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
379f65358e5SSuravee Suthikulpanit (acpi_size)length);
380f65358e5SSuravee Suthikulpanit if (!cls) {
381f65358e5SSuravee Suthikulpanit status = AE_NO_MEMORY;
382f65358e5SSuravee Suthikulpanit goto cleanup;
383f65358e5SSuravee Suthikulpanit }
384f65358e5SSuravee Suthikulpanit
385f65358e5SSuravee Suthikulpanit /* Area for the string starts after PNP_DEVICE_ID struct */
386f65358e5SSuravee Suthikulpanit
387f65358e5SSuravee Suthikulpanit cls->string =
388f65358e5SSuravee Suthikulpanit ACPI_ADD_PTR(char, cls, sizeof(struct acpi_pnp_device_id));
389f65358e5SSuravee Suthikulpanit
390f65358e5SSuravee Suthikulpanit /* Simply copy existing string */
391f65358e5SSuravee Suthikulpanit
392f65358e5SSuravee Suthikulpanit acpi_ex_pci_cls_to_string(cls->string, class_code);
393f65358e5SSuravee Suthikulpanit cls->length = length;
394f65358e5SSuravee Suthikulpanit *return_id = cls;
395f65358e5SSuravee Suthikulpanit
396f65358e5SSuravee Suthikulpanit cleanup:
397f65358e5SSuravee Suthikulpanit
398f65358e5SSuravee Suthikulpanit /* On exit, we must delete the return object */
399f65358e5SSuravee Suthikulpanit
400f65358e5SSuravee Suthikulpanit acpi_ut_remove_reference(obj_desc);
401f65358e5SSuravee Suthikulpanit return_ACPI_STATUS(status);
402f65358e5SSuravee Suthikulpanit }
403