Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0-only
28 * not defined without a warning. For instance if any of the properties
29 * from different GUID appear in a property list of another, it will be
33 /* ACPI _DSD device properties GUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
36 /* Hotplug in D3 GUID: 6211e2c0-58a3-4af3-90e1-927a4e0c55a4 */
39 /* External facing port GUID: efcc06cc-73ac-4bc3-bff0-76143807c389 */
42 /* Thunderbolt GUID for IMR_VALID: c44d002f-69f9-4e7d-a904-a7baabdf43f7 */
45 /* Thunderbolt GUID for WAKE_SUPPORTED: 6c501103-c189-4296-ba72-9bf5a26ebe5d */
48 /* Storage device needs D3 GUID: 5025030f-842f-4ab4-a561-99a5189762d0 */
53 /* ACPI _DSD data subnodes GUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
78 dn->name = link->package.elements[0].string.pointer; in acpi_nondev_subnode_extract()
79 dn->fwnode.ops = &acpi_data_fwnode_ops; in acpi_nondev_subnode_extract()
80 dn->parent = parent; in acpi_nondev_subnode_extract()
81 INIT_LIST_HEAD(&dn->data.properties); in acpi_nondev_subnode_extract()
82 INIT_LIST_HEAD(&dn->data.subnodes); in acpi_nondev_subnode_extract()
84 result = acpi_extract_properties(desc, &dn->data); in acpi_nondev_subnode_extract()
92 * namespace node (device) containing the object that has in acpi_nondev_subnode_extract()
98 && acpi_enumerate_nondev_subnodes(scope, desc, &dn->data, in acpi_nondev_subnode_extract()
99 &dn->fwnode)) in acpi_nondev_subnode_extract()
101 } else if (acpi_enumerate_nondev_subnodes(NULL, desc, &dn->data, in acpi_nondev_subnode_extract()
102 &dn->fwnode)) { in acpi_nondev_subnode_extract()
107 dn->handle = handle; in acpi_nondev_subnode_extract()
108 dn->data.pointer = desc; in acpi_nondev_subnode_extract()
109 list_add_tail(&dn->sibling, list); in acpi_nondev_subnode_extract()
150 status = acpi_get_handle(scope, link->package.elements[1].string.pointer, in acpi_nondev_subnode_ok()
166 for (i = 0; i < links->package.count; i++) { in acpi_add_nondev_subnodes()
171 link = &links->package.elements[i]; in acpi_add_nondev_subnodes()
173 if (link->package.count != 2) in acpi_add_nondev_subnodes()
176 /* The first one must be a string. */ in acpi_add_nondev_subnodes()
177 if (link->package.elements[0].type != ACPI_TYPE_STRING) in acpi_add_nondev_subnodes()
180 /* The second one may be a string, a reference or a package. */ in acpi_add_nondev_subnodes()
181 switch (link->package.elements[1].type) { in acpi_add_nondev_subnodes()
187 handle = link->package.elements[1].reference.handle; in acpi_add_nondev_subnodes()
192 desc = &link->package.elements[1]; in acpi_add_nondev_subnodes()
214 for (i = 0; i < desc->package.count; i += 2) { in acpi_enumerate_nondev_subnodes()
217 guid = &desc->package.elements[i]; in acpi_enumerate_nondev_subnodes()
218 links = &desc->package.elements[i + 1]; in acpi_enumerate_nondev_subnodes()
221 * The first element must be a GUID and the second one must be in acpi_enumerate_nondev_subnodes()
222 * a package. in acpi_enumerate_nondev_subnodes()
224 if (guid->type != ACPI_TYPE_BUFFER || in acpi_enumerate_nondev_subnodes()
225 guid->buffer.length != 16 || in acpi_enumerate_nondev_subnodes()
226 links->type != ACPI_TYPE_PACKAGE) in acpi_enumerate_nondev_subnodes()
229 if (!guid_equal((guid_t *)guid->buffer.pointer, &ads_guid)) in acpi_enumerate_nondev_subnodes()
232 return acpi_add_nondev_subnodes(scope, links, &data->subnodes, in acpi_enumerate_nondev_subnodes()
244 * The value must be an integer, a string, a reference, or a package in acpi_property_value_ok()
245 * whose every element must be an integer, a string, or a reference. in acpi_property_value_ok()
247 switch (value->type) { in acpi_property_value_ok()
254 for (j = 0; j < value->package.count; j++) in acpi_property_value_ok()
255 switch (value->package.elements[j].type) { in acpi_property_value_ok()
274 for (i = 0; i < properties->package.count; i++) { in acpi_properties_format_valid()
275 const union acpi_object *property; in acpi_properties_format_valid() local
277 property = &properties->package.elements[i]; in acpi_properties_format_valid()
279 * Only two elements allowed, the first one must be a string and in acpi_properties_format_valid()
282 if (property->package.count != 2 in acpi_properties_format_valid()
283 || property->package.elements[0].type != ACPI_TYPE_STRING in acpi_properties_format_valid()
284 || !acpi_property_value_ok(&property->package.elements[1])) in acpi_properties_format_valid()
295 ret = acpi_data_get_property_array(&adev->data, "compatible", in acpi_init_of_compatible()
301 if (adev->parent in acpi_init_of_compatible()
302 && adev->parent->flags.of_compatible_ok) in acpi_init_of_compatible()
308 adev->data.of_compatible = of_compatible; in acpi_init_of_compatible()
311 adev->flags.of_compatible_ok = 1; in acpi_init_of_compatible()
334 INIT_LIST_HEAD(&props->list); in acpi_data_add_props()
335 props->guid = guid; in acpi_data_add_props()
336 props->properties = properties; in acpi_data_add_props()
337 list_add_tail(&props->list, &data->properties); in acpi_data_add_props()
348 if (desc->package.count % 2) in acpi_extract_properties()
352 for (i = 0; i < desc->package.count; i += 2) { in acpi_extract_properties()
355 guid = &desc->package.elements[i]; in acpi_extract_properties()
356 properties = &desc->package.elements[i + 1]; in acpi_extract_properties()
359 * The first element must be a GUID and the second one must be in acpi_extract_properties()
360 * a package. in acpi_extract_properties()
362 if (guid->type != ACPI_TYPE_BUFFER || in acpi_extract_properties()
363 guid->buffer.length != 16 || in acpi_extract_properties()
364 properties->type != ACPI_TYPE_PACKAGE) in acpi_extract_properties()
367 if (!acpi_is_property_guid((guid_t *)guid->buffer.pointer)) in acpi_extract_properties()
377 acpi_data_add_props(data, (const guid_t *)guid->buffer.pointer, in acpi_extract_properties()
381 return !list_empty(&data->properties); in acpi_extract_properties()
391 INIT_LIST_HEAD(&adev->data.properties); in acpi_init_properties()
392 INIT_LIST_HEAD(&adev->data.subnodes); in acpi_init_properties()
394 if (!adev->handle) in acpi_init_properties()
401 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_init_properties()
402 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) { in acpi_init_properties()
408 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf, in acpi_init_properties()
413 if (acpi_extract_properties(buf.pointer, &adev->data)) { in acpi_init_properties()
414 adev->data.pointer = buf.pointer; in acpi_init_properties()
418 if (acpi_enumerate_nondev_subnodes(adev->handle, buf.pointer, in acpi_init_properties()
419 &adev->data, acpi_fwnode_handle(adev))) in acpi_init_properties()
420 adev->data.pointer = buf.pointer; in acpi_init_properties()
422 if (!adev->data.pointer) { in acpi_init_properties()
423 acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n"); in acpi_init_properties()
428 if (acpi_of && !adev->flags.of_compatible_ok) in acpi_init_properties()
429 acpi_handle_info(adev->handle, in acpi_init_properties()
430 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n"); in acpi_init_properties()
432 if (!adev->data.pointer) in acpi_init_properties()
441 list_del(&props->list); in acpi_free_device_properties()
454 acpi_destroy_nondev_subnodes(&dn->data.subnodes); in acpi_destroy_nondev_subnodes()
455 wait_for_completion(&dn->kobj_done); in acpi_destroy_nondev_subnodes()
456 list_del(&dn->sibling); in acpi_destroy_nondev_subnodes()
457 ACPI_FREE((void *)dn->data.pointer); in acpi_destroy_nondev_subnodes()
458 acpi_free_device_properties(&dn->data.properties); in acpi_destroy_nondev_subnodes()
465 acpi_destroy_nondev_subnodes(&adev->data.subnodes); in acpi_free_properties()
466 ACPI_FREE((void *)adev->data.pointer); in acpi_free_properties()
467 adev->data.of_compatible = NULL; in acpi_free_properties()
468 adev->data.pointer = NULL; in acpi_free_properties()
469 acpi_free_device_properties(&adev->data.properties); in acpi_free_properties()
473 * acpi_data_get_property - return an ACPI property with given name
474 * @data: ACPI device deta object to get the property from
475 * @name: Name of the property
476 * @type: Expected property type
477 * @obj: Location to store the property value (if not %NULL)
479 * Look up a property with @name and store a pointer to the resulting ACPI
485 * Return: %0 if property with @name has been found (success),
486 * %-EINVAL if the arguments are invalid,
487 * %-EINVAL if the property doesn't exist,
488 * %-EPROTO if the property value type doesn't match @type.
497 return -EINVAL; in acpi_data_get_property()
499 if (!data->pointer || list_empty(&data->properties)) in acpi_data_get_property()
500 return -EINVAL; in acpi_data_get_property()
502 list_for_each_entry(props, &data->properties, list) { in acpi_data_get_property()
506 properties = props->properties; in acpi_data_get_property()
507 for (i = 0; i < properties->package.count; i++) { in acpi_data_get_property()
509 const union acpi_object *property; in acpi_data_get_property() local
511 property = &properties->package.elements[i]; in acpi_data_get_property()
513 propname = &property->package.elements[0]; in acpi_data_get_property()
514 propvalue = &property->package.elements[1]; in acpi_data_get_property()
516 if (!strcmp(name, propname->string.pointer)) { in acpi_data_get_property()
518 propvalue->type != type) in acpi_data_get_property()
519 return -EPROTO; in acpi_data_get_property()
527 return -EINVAL; in acpi_data_get_property()
531 * acpi_dev_get_property - return an ACPI property with given name.
532 * @adev: ACPI device to get the property from.
533 * @name: Name of the property.
534 * @type: Expected property type.
535 * @obj: Location to store the property value (if not %NULL).
540 return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; in acpi_dev_get_property()
549 return &adev->data; in acpi_device_data_of_node()
552 return &dn->data; in acpi_device_data_of_node()
558 * acpi_node_prop_get - return an ACPI property with given name.
559 * @fwnode: Firmware node to get the property from.
560 * @propname: Name of the property.
561 * @valptr: Location to store a pointer to the property value (if not %NULL).
572 * acpi_data_get_property_array - return an ACPI array property with given name
573 * @adev: ACPI data object to get the property from
574 * @name: Name of the property
576 * @obj: Location to store a pointer to the property value (if not NULL)
578 * Look up an array property with @name and store a pointer to the resulting
584 * Return: %0 if array property (package) with @name has been found (success),
585 * %-EINVAL if the arguments are invalid,
586 * %-EINVAL if the property doesn't exist,
587 * %-EPROTO if the property is not a package or the type of its elements
604 for (i = 0; i < prop->package.count; i++) in acpi_data_get_property_array()
605 if (prop->package.elements[i].type != type) in acpi_data_get_property_array()
606 return -EPROTO; in acpi_data_get_property_array()
618 struct fwnode_handle *child; in acpi_fwnode_get_named_child_node() local
620 fwnode_for_each_child_node(fwnode, child) { in acpi_fwnode_get_named_child_node()
621 if (is_acpi_data_node(child)) { in acpi_fwnode_get_named_child_node()
622 if (acpi_data_node_match(child, childname)) in acpi_fwnode_get_named_child_node()
623 return child; in acpi_fwnode_get_named_child_node()
627 if (!strncmp(acpi_device_bid(to_acpi_device_node(child)), in acpi_fwnode_get_named_child_node()
629 return child; in acpi_fwnode_get_named_child_node()
636 * __acpi_node_get_property_reference - returns handle to the referenced object
637 * @fwnode: Firmware node to get the property from
638 * @propname: Name of the property
644 * Find property with @name, verifify that it is a package containing at least
646 * target object in @args->adev. If the reference includes arguments, store
647 * them in the @args->args[] array.
649 * If there's more than one reference in the property value package, @index is
652 * It is possible to leave holes in the property value set like in the
656 * "cs-gpios",
665 * Calling this function with index %2 or index %3 return %-ENOENT. If the
666 * property does not contain any more values %-ENOENT is returned. The NULL
683 return -ENOENT; in __acpi_node_get_property_reference()
687 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
690 * The simplest case is when the value is a single reference. Just in __acpi_node_get_property_reference()
693 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
695 return -ENOENT; in __acpi_node_get_property_reference()
697 ret = acpi_bus_get_device(obj->reference.handle, &device); in __acpi_node_get_property_reference()
699 return ret == -ENODEV ? -EINVAL : ret; in __acpi_node_get_property_reference()
704 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
705 args->nargs = 0; in __acpi_node_get_property_reference()
710 * If it is not a single reference, then it is a package of in __acpi_node_get_property_reference()
718 if (obj->type != ACPI_TYPE_PACKAGE) in __acpi_node_get_property_reference()
719 return -EINVAL; in __acpi_node_get_property_reference()
720 if (index >= obj->package.count) in __acpi_node_get_property_reference()
721 return -ENOENT; in __acpi_node_get_property_reference()
723 element = obj->package.elements; in __acpi_node_get_property_reference()
724 end = element + obj->package.count; in __acpi_node_get_property_reference()
729 if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
732 ret = acpi_bus_get_device(element->reference.handle, in __acpi_node_get_property_reference()
735 return -EINVAL; in __acpi_node_get_property_reference()
741 * Find the referred data extension node under the in __acpi_node_get_property_reference()
742 * referred device node. in __acpi_node_get_property_reference()
745 element < end && element->type == ACPI_TYPE_STRING; in __acpi_node_get_property_reference()
748 ref_fwnode, element->string.pointer); in __acpi_node_get_property_reference()
750 return -EINVAL; in __acpi_node_get_property_reference()
762 return -EINVAL; in __acpi_node_get_property_reference()
766 return -EINVAL; in __acpi_node_get_property_reference()
769 args->fwnode = ref_fwnode; in __acpi_node_get_property_reference()
770 args->nargs = nargs; in __acpi_node_get_property_reference()
772 args->args[i] = element[i].integer.value; in __acpi_node_get_property_reference()
778 } else if (element->type == ACPI_TYPE_INTEGER) { in __acpi_node_get_property_reference()
780 return -ENOENT; in __acpi_node_get_property_reference()
783 return -EINVAL; in __acpi_node_get_property_reference()
789 return -ENOENT; in __acpi_node_get_property_reference()
807 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
808 return -EOVERFLOW; in acpi_data_prop_read_single()
811 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
815 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
816 return -EOVERFLOW; in acpi_data_prop_read_single()
819 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
823 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
824 return -EOVERFLOW; in acpi_data_prop_read_single()
827 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
832 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
845 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
849 ret = -EINVAL; in acpi_data_prop_read_single()
860 return -EINVAL; in acpi_dev_prop_read_single()
862 ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); in acpi_dev_prop_read_single()
875 return -EPROTO; in acpi_copy_property_array_u8()
877 return -EOVERFLOW; in acpi_copy_property_array_u8()
891 return -EPROTO; in acpi_copy_property_array_u16()
893 return -EOVERFLOW; in acpi_copy_property_array_u16()
907 return -EPROTO; in acpi_copy_property_array_u32()
909 return -EOVERFLOW; in acpi_copy_property_array_u32()
923 return -EPROTO; in acpi_copy_property_array_u64()
937 return -EPROTO; in acpi_copy_property_array_string()
956 * The overflow error means that the property is there and it is in acpi_data_prop_read()
957 * single-value, but its type does not match, so return. in acpi_data_prop_read()
959 if (ret >= 0 || ret == -EOVERFLOW) in acpi_data_prop_read()
963 * Reading this property as a single-value one failed, but its in acpi_data_prop_read()
964 * value may still be represented as one-element array, so in acpi_data_prop_read()
974 return obj->package.count; in acpi_data_prop_read()
976 if (proptype != DEV_PROP_STRING && nval > obj->package.count) in acpi_data_prop_read()
977 return -EOVERFLOW; in acpi_data_prop_read()
979 return -EINVAL; in acpi_data_prop_read()
981 items = obj->package.elements; in acpi_data_prop_read()
999 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
1002 ret = -EINVAL; in acpi_data_prop_read()
1011 return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; in acpi_dev_prop_read()
1015 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
1016 * @fwnode: Firmware node to get the property from.
1017 * @propname: Name of the property.
1018 * @proptype: Expected property type.
1019 * @val: Location to store the property value (if not %NULL).
1023 * of the property. Otherwise, read at most @nval values to the array at the
1035 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1036 * @fwnode: Firmware node to find the next child node for.
1037 * @child: Handle to one of the device's child nodes or a null handle.
1040 struct fwnode_handle *child) in acpi_get_next_subnode() argument
1046 if (!child || is_acpi_device_node(child)) { in acpi_get_next_subnode()
1050 head = &adev->children; in acpi_get_next_subnode()
1057 if (child) { in acpi_get_next_subnode()
1058 adev = to_acpi_device_node(child); in acpi_get_next_subnode()
1059 next = adev->node.next; in acpi_get_next_subnode()
1061 child = NULL; in acpi_get_next_subnode()
1064 child_adev = list_entry(next, struct acpi_device, node); in acpi_get_next_subnode()
1067 node); in acpi_get_next_subnode()
1073 if (!child || is_acpi_data_node(child)) { in acpi_get_next_subnode()
1078 * We can have a combination of device and data nodes, e.g. with in acpi_get_next_subnode()
1086 head = &adev->data.subnodes; in acpi_get_next_subnode()
1088 head = &data->data.subnodes; in acpi_get_next_subnode()
1095 if (child) { in acpi_get_next_subnode()
1096 dn = to_acpi_data_node(child); in acpi_get_next_subnode()
1097 next = dn->sibling.next; in acpi_get_next_subnode()
1105 return &dn->fwnode; in acpi_get_next_subnode()
1111 * acpi_node_get_parent - Return parent fwnode of this fwnode
1112 * @fwnode: Firmware node whose parent to get
1114 * Returns parent node of an ACPI device or data firmware node or %NULL if
1121 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1123 struct device *dev = to_acpi_device_node(fwnode)->dev.parent; in acpi_node_get_parent()
1133 * Return true if the node is an ACPI graph node. Called on either ports
1145 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1153 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1154 * @fwnode: Pointer to the parent firmware node
1155 * @prev: Previous endpoint node or %NULL to get the first
1157 * Looks up next endpoint ACPI firmware node below a given @fwnode. Returns
1172 * followed by the number of the port node and they also in acpi_graph_get_next_endpoint()
1173 * have a "reg" property that also has the number of the in acpi_graph_get_next_endpoint()
1174 * port node. For compatibility reasons a node is also in acpi_graph_get_next_endpoint()
1175 * recognised as a port node from the "port" property. in acpi_graph_get_next_endpoint()
1198 * the number of the endpoint node and they also have a "reg" property in acpi_graph_get_next_endpoint()
1199 * that also has the number of the endpoint node. For compatibility in acpi_graph_get_next_endpoint()
1200 * reasons a node is also recognised as an endpoint node from the in acpi_graph_get_next_endpoint()
1201 * "endpoint" property. in acpi_graph_get_next_endpoint()
1210 * acpi_graph_get_child_prop_value - Return a child with a given property value
1212 * @prop_name: The name of the property to look for
1213 * @val: the desired property value
1215 * Return the port node corresponding to a given port number. Returns
1216 * the child node on success, NULL otherwise.
1222 struct fwnode_handle *child; in acpi_graph_get_child_prop_value() local
1224 fwnode_for_each_child_node(fwnode, child) { in acpi_graph_get_child_prop_value()
1227 if (fwnode_property_read_u32(child, prop_name, &nr)) in acpi_graph_get_child_prop_value()
1231 return child; in acpi_graph_get_child_prop_value()
1239 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1240 * @fwnode: Endpoint firmware node pointing to a remote device
1241 * @endpoint: Firmware node of remote endpoint is filled here if not %NULL
1254 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1315 return -ENXIO; in acpi_fwnode_property_read_int_array()
1345 /* Is this the root node? */ in acpi_fwnode_get_name()
1355 return dn->name; in acpi_fwnode_get_name()
1370 /* Is this the root node? */ in acpi_fwnode_get_name_prefix()
1375 /* Is this 2nd node from the root? */ in acpi_fwnode_get_name_prefix()
1382 /* ACPI device or data node. */ in acpi_fwnode_get_name_prefix()
1397 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1399 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1400 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1401 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1402 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1445 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1451 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()