• Home
  • Raw
  • Download

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
643 * Find property with @name, verifify that it is a package containing at least
645 * target object in @args->adev. If the reference includes arguments, store
646 * them in the @args->args[] array.
648 * If there's more than one reference in the property value package, @index is
651 * It is possible to leave holes in the property value set like in the
655 * "cs-gpios",
664 * Calling this function with index %2 or index %3 return %-ENOENT. If the
665 * property does not contain any more values %-ENOENT is returned. The NULL
682 return -ENOENT; in __acpi_node_get_property_reference()
686 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
689 * The simplest case is when the value is a single reference. Just in __acpi_node_get_property_reference()
692 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
694 return -ENOENT; in __acpi_node_get_property_reference()
696 ret = acpi_bus_get_device(obj->reference.handle, &device); in __acpi_node_get_property_reference()
698 return ret == -ENODEV ? -EINVAL : ret; in __acpi_node_get_property_reference()
700 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
701 args->nargs = 0; in __acpi_node_get_property_reference()
706 * If it is not a single reference, then it is a package of in __acpi_node_get_property_reference()
714 if (obj->type != ACPI_TYPE_PACKAGE) in __acpi_node_get_property_reference()
715 return -EINVAL; in __acpi_node_get_property_reference()
716 if (index >= obj->package.count) in __acpi_node_get_property_reference()
717 return -ENOENT; in __acpi_node_get_property_reference()
719 element = obj->package.elements; in __acpi_node_get_property_reference()
720 end = element + obj->package.count; in __acpi_node_get_property_reference()
725 if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
728 ret = acpi_bus_get_device(element->reference.handle, in __acpi_node_get_property_reference()
731 return -EINVAL; in __acpi_node_get_property_reference()
737 * Find the referred data extension node under the in __acpi_node_get_property_reference()
738 * referred device node. in __acpi_node_get_property_reference()
741 element < end && element->type == ACPI_TYPE_STRING; in __acpi_node_get_property_reference()
744 ref_fwnode, element->string.pointer); in __acpi_node_get_property_reference()
746 return -EINVAL; in __acpi_node_get_property_reference()
758 return -EINVAL; in __acpi_node_get_property_reference()
762 return -EINVAL; in __acpi_node_get_property_reference()
765 args->fwnode = ref_fwnode; in __acpi_node_get_property_reference()
766 args->nargs = nargs; in __acpi_node_get_property_reference()
768 args->args[i] = element[i].integer.value; in __acpi_node_get_property_reference()
774 } else if (element->type == ACPI_TYPE_INTEGER) { in __acpi_node_get_property_reference()
776 return -ENOENT; in __acpi_node_get_property_reference()
779 return -EINVAL; in __acpi_node_get_property_reference()
785 return -ENOENT; in __acpi_node_get_property_reference()
803 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
804 return -EOVERFLOW; in acpi_data_prop_read_single()
807 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
811 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
812 return -EOVERFLOW; in acpi_data_prop_read_single()
815 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
819 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
820 return -EOVERFLOW; in acpi_data_prop_read_single()
823 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
828 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
841 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
845 ret = -EINVAL; in acpi_data_prop_read_single()
856 return -EINVAL; in acpi_dev_prop_read_single()
858 ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); in acpi_dev_prop_read_single()
871 return -EPROTO; in acpi_copy_property_array_u8()
873 return -EOVERFLOW; in acpi_copy_property_array_u8()
887 return -EPROTO; in acpi_copy_property_array_u16()
889 return -EOVERFLOW; in acpi_copy_property_array_u16()
903 return -EPROTO; in acpi_copy_property_array_u32()
905 return -EOVERFLOW; in acpi_copy_property_array_u32()
919 return -EPROTO; in acpi_copy_property_array_u64()
933 return -EPROTO; in acpi_copy_property_array_string()
952 * The overflow error means that the property is there and it is in acpi_data_prop_read()
953 * single-value, but its type does not match, so return. in acpi_data_prop_read()
955 if (ret >= 0 || ret == -EOVERFLOW) in acpi_data_prop_read()
959 * Reading this property as a single-value one failed, but its in acpi_data_prop_read()
960 * value may still be represented as one-element array, so in acpi_data_prop_read()
970 return obj->package.count; in acpi_data_prop_read()
972 if (proptype != DEV_PROP_STRING && nval > obj->package.count) in acpi_data_prop_read()
973 return -EOVERFLOW; in acpi_data_prop_read()
975 return -EINVAL; in acpi_data_prop_read()
977 items = obj->package.elements; in acpi_data_prop_read()
995 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
998 ret = -EINVAL; in acpi_data_prop_read()
1007 return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; in acpi_dev_prop_read()
1011 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
1012 * @fwnode: Firmware node to get the property from.
1013 * @propname: Name of the property.
1014 * @proptype: Expected property type.
1015 * @val: Location to store the property value (if not %NULL).
1019 * of the property. Otherwise, read at most @nval values to the array at the
1031 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1032 * @fwnode: Firmware node to find the next child node for.
1033 * @child: Handle to one of the device's child nodes or a null handle.
1036 struct fwnode_handle *child) in acpi_get_next_subnode() argument
1042 if (!child || is_acpi_device_node(child)) { in acpi_get_next_subnode()
1046 head = &adev->children; in acpi_get_next_subnode()
1053 if (child) { in acpi_get_next_subnode()
1054 adev = to_acpi_device_node(child); in acpi_get_next_subnode()
1055 next = adev->node.next; in acpi_get_next_subnode()
1057 child = NULL; in acpi_get_next_subnode()
1060 child_adev = list_entry(next, struct acpi_device, node); in acpi_get_next_subnode()
1063 node); in acpi_get_next_subnode()
1069 if (!child || is_acpi_data_node(child)) { in acpi_get_next_subnode()
1074 * We can have a combination of device and data nodes, e.g. with in acpi_get_next_subnode()
1082 head = &adev->data.subnodes; in acpi_get_next_subnode()
1084 head = &data->data.subnodes; in acpi_get_next_subnode()
1091 if (child) { in acpi_get_next_subnode()
1092 dn = to_acpi_data_node(child); in acpi_get_next_subnode()
1093 next = dn->sibling.next; in acpi_get_next_subnode()
1101 return &dn->fwnode; in acpi_get_next_subnode()
1107 * acpi_node_get_parent - Return parent fwnode of this fwnode
1108 * @fwnode: Firmware node whose parent to get
1110 * Returns parent node of an ACPI device or data firmware node or %NULL if
1117 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1119 struct device *dev = to_acpi_device_node(fwnode)->dev.parent; in acpi_node_get_parent()
1129 * Return true if the node is an ACPI graph node. Called on either ports
1141 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1149 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1150 * @fwnode: Pointer to the parent firmware node
1151 * @prev: Previous endpoint node or %NULL to get the first
1153 * Looks up next endpoint ACPI firmware node below a given @fwnode. Returns
1168 * followed by the number of the port node and they also in acpi_graph_get_next_endpoint()
1169 * have a "reg" property that also has the number of the in acpi_graph_get_next_endpoint()
1170 * port node. For compatibility reasons a node is also in acpi_graph_get_next_endpoint()
1171 * recognised as a port node from the "port" property. in acpi_graph_get_next_endpoint()
1194 * the number of the endpoint node and they also have a "reg" property in acpi_graph_get_next_endpoint()
1195 * that also has the number of the endpoint node. For compatibility in acpi_graph_get_next_endpoint()
1196 * reasons a node is also recognised as an endpoint node from the in acpi_graph_get_next_endpoint()
1197 * "endpoint" property. in acpi_graph_get_next_endpoint()
1206 * acpi_graph_get_child_prop_value - Return a child with a given property value
1208 * @prop_name: The name of the property to look for
1209 * @val: the desired property value
1211 * Return the port node corresponding to a given port number. Returns
1212 * the child node on success, NULL otherwise.
1218 struct fwnode_handle *child; in acpi_graph_get_child_prop_value() local
1220 fwnode_for_each_child_node(fwnode, child) { in acpi_graph_get_child_prop_value()
1223 if (fwnode_property_read_u32(child, prop_name, &nr)) in acpi_graph_get_child_prop_value()
1227 return child; in acpi_graph_get_child_prop_value()
1235 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1236 * @fwnode: Endpoint firmware node pointing to a remote device
1237 * @endpoint: Firmware node of remote endpoint is filled here if not %NULL
1250 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1311 return -ENXIO; in acpi_fwnode_property_read_int_array()
1341 /* Is this the root node? */ in acpi_fwnode_get_name()
1351 return dn->name; in acpi_fwnode_get_name()
1366 /* Is this the root node? */ in acpi_fwnode_get_name_prefix()
1371 /* Is this 2nd node from the root? */ in acpi_fwnode_get_name_prefix()
1378 /* ACPI device or data node. */ in acpi_fwnode_get_name_prefix()
1393 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1395 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1396 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1397 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1398 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1441 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1447 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()