Lines Matching +full:bool +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0-only
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 */
58 static bool acpi_enumerate_nondev_subnodes(acpi_handle scope,
62 static bool acpi_extract_properties(const union acpi_object *desc,
65 static bool acpi_nondev_subnode_extract(const union acpi_object *desc, in acpi_nondev_subnode_extract()
72 bool result; in acpi_nondev_subnode_extract()
78 dn->name = link->package.elements[0].string.pointer; in acpi_nondev_subnode_extract()
79 fwnode_init(&dn->fwnode, &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()
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()
118 static bool acpi_nondev_subnode_data_ok(acpi_handle handle, in acpi_nondev_subnode_data_ok()
139 static bool acpi_nondev_subnode_ok(acpi_handle scope, in acpi_nondev_subnode_ok()
150 status = acpi_get_handle(scope, link->package.elements[1].string.pointer, in acpi_nondev_subnode_ok()
163 bool ret = false; in acpi_add_nondev_subnodes()
166 for (i = 0; i < links->package.count; i++) { in acpi_add_nondev_subnodes()
169 bool result; 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()
177 if (link->package.elements[0].type != ACPI_TYPE_STRING) 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()
206 static bool acpi_enumerate_nondev_subnodes(acpi_handle scope, in acpi_enumerate_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()
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()
239 static bool acpi_property_value_ok(const union acpi_object *value) 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()
270 static bool acpi_properties_format_valid(const union acpi_object *properties) in acpi_properties_format_valid()
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()
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()
314 static bool acpi_is_property_guid(const guid_t *guid) in acpi_is_property_guid()
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()
343 static bool acpi_extract_properties(const union acpi_object *desc, in acpi_extract_properties()
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()
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()
389 bool acpi_of = false; in acpi_init_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()
444 acpi_destroy_nondev_subnodes(&dn->data.subnodes); in acpi_destroy_nondev_subnodes()
445 wait_for_completion(&dn->kobj_done); in acpi_destroy_nondev_subnodes()
446 list_del(&dn->sibling); in acpi_destroy_nondev_subnodes()
447 ACPI_FREE((void *)dn->data.pointer); in acpi_destroy_nondev_subnodes()
456 acpi_destroy_nondev_subnodes(&adev->data.subnodes); in acpi_free_properties()
457 ACPI_FREE((void *)adev->data.pointer); in acpi_free_properties()
458 adev->data.of_compatible = NULL; in acpi_free_properties()
459 adev->data.pointer = NULL; in acpi_free_properties()
460 list_for_each_entry_safe(props, tmp, &adev->data.properties, list) { in acpi_free_properties()
461 list_del(&props->list); in acpi_free_properties()
467 * acpi_data_get_property - return an ACPI property with given name
468 * @data: ACPI device deta object to get the property from
469 * @name: Name of the property
470 * @type: Expected property type
471 * @obj: Location to store the property value (if not %NULL)
473 * Look up a property with @name and store a pointer to the resulting ACPI
479 * Return: %0 if property with @name has been found (success),
480 * %-EINVAL if the arguments are invalid,
481 * %-EINVAL if the property doesn't exist,
482 * %-EPROTO if the property value type doesn't match @type.
491 return -EINVAL; in acpi_data_get_property()
493 if (!data->pointer || list_empty(&data->properties)) in acpi_data_get_property()
494 return -EINVAL; in acpi_data_get_property()
496 list_for_each_entry(props, &data->properties, list) { in acpi_data_get_property()
500 properties = props->properties; in acpi_data_get_property()
501 for (i = 0; i < properties->package.count; i++) { in acpi_data_get_property()
503 const union acpi_object *property; in acpi_data_get_property() local
505 property = &properties->package.elements[i]; in acpi_data_get_property()
507 propname = &property->package.elements[0]; in acpi_data_get_property()
508 propvalue = &property->package.elements[1]; in acpi_data_get_property()
510 if (!strcmp(name, propname->string.pointer)) { in acpi_data_get_property()
512 propvalue->type != type) in acpi_data_get_property()
513 return -EPROTO; in acpi_data_get_property()
521 return -EINVAL; in acpi_data_get_property()
525 * acpi_dev_get_property - return an ACPI property with given name.
526 * @adev: ACPI device to get the property from.
527 * @name: Name of the property.
528 * @type: Expected property type.
529 * @obj: Location to store the property value (if not %NULL).
534 return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; in acpi_dev_get_property()
543 return &adev->data; in acpi_device_data_of_node()
546 return &dn->data; in acpi_device_data_of_node()
552 * acpi_node_prop_get - return an ACPI property with given name.
553 * @fwnode: Firmware node to get the property from.
554 * @propname: Name of the property.
555 * @valptr: Location to store a pointer to the property value (if not %NULL).
566 * acpi_data_get_property_array - return an ACPI array property with given name
567 * @data: ACPI data object to get the property from
568 * @name: Name of the property
570 * @obj: Location to store a pointer to the property value (if not NULL)
572 * Look up an array property with @name and store a pointer to the resulting
578 * Return: %0 if array property (package) with @name has been found (success),
579 * %-EINVAL if the arguments are invalid,
580 * %-EINVAL if the property doesn't exist,
581 * %-EPROTO if the property is not a package or the type of its elements
598 for (i = 0; i < prop->package.count; i++) in acpi_data_get_property_array()
599 if (prop->package.elements[i].type != type) in acpi_data_get_property_array()
600 return -EPROTO; in acpi_data_get_property_array()
630 * __acpi_node_get_property_reference - returns handle to the referenced object
631 * @fwnode: Firmware node to get the property from
632 * @propname: Name of the property
637 * Find property with @name, verifify that it is a package containing at least
639 * target object in @args->adev. If the reference includes arguments, store
640 * them in the @args->args[] array.
642 * If there's more than one reference in the property value package, @index is
645 * It is possible to leave holes in the property value set like in the
649 * "cs-gpios",
658 * Calling this function with index %2 or index %3 return %-ENOENT. If the
659 * property does not contain any more values %-ENOENT is returned. The NULL
676 return -ENOENT; in __acpi_node_get_property_reference()
680 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
686 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
688 return -EINVAL; in __acpi_node_get_property_reference()
690 ret = acpi_bus_get_device(obj->reference.handle, &device); in __acpi_node_get_property_reference()
692 return ret == -ENODEV ? -EINVAL : ret; in __acpi_node_get_property_reference()
694 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
695 args->nargs = 0; in __acpi_node_get_property_reference()
708 if (obj->type != ACPI_TYPE_PACKAGE) in __acpi_node_get_property_reference()
709 return -EINVAL; in __acpi_node_get_property_reference()
710 if (index >= obj->package.count) in __acpi_node_get_property_reference()
711 return -ENOENT; in __acpi_node_get_property_reference()
713 element = obj->package.elements; in __acpi_node_get_property_reference()
714 end = element + obj->package.count; in __acpi_node_get_property_reference()
719 if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
722 ret = acpi_bus_get_device(element->reference.handle, in __acpi_node_get_property_reference()
725 return -EINVAL; in __acpi_node_get_property_reference()
735 element < end && element->type == ACPI_TYPE_STRING; in __acpi_node_get_property_reference()
738 ref_fwnode, element->string.pointer); in __acpi_node_get_property_reference()
740 return -EINVAL; in __acpi_node_get_property_reference()
752 return -EINVAL; in __acpi_node_get_property_reference()
756 return -EINVAL; in __acpi_node_get_property_reference()
759 args->fwnode = ref_fwnode; in __acpi_node_get_property_reference()
760 args->nargs = nargs; in __acpi_node_get_property_reference()
762 args->args[i] = element[i].integer.value; in __acpi_node_get_property_reference()
768 } else if (element->type == ACPI_TYPE_INTEGER) { in __acpi_node_get_property_reference()
770 return -ENOENT; in __acpi_node_get_property_reference()
773 return -EINVAL; in __acpi_node_get_property_reference()
779 return -ENOENT; in __acpi_node_get_property_reference()
797 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
798 return -EOVERFLOW; in acpi_data_prop_read_single()
801 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
805 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
806 return -EOVERFLOW; in acpi_data_prop_read_single()
809 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
813 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
814 return -EOVERFLOW; in acpi_data_prop_read_single()
817 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
822 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
835 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
839 ret = -EINVAL; in acpi_data_prop_read_single()
851 return -EPROTO; in acpi_copy_property_array_u8()
853 return -EOVERFLOW; in acpi_copy_property_array_u8()
867 return -EPROTO; in acpi_copy_property_array_u16()
869 return -EOVERFLOW; in acpi_copy_property_array_u16()
883 return -EPROTO; in acpi_copy_property_array_u32()
885 return -EOVERFLOW; in acpi_copy_property_array_u32()
899 return -EPROTO; in acpi_copy_property_array_u64()
913 return -EPROTO; in acpi_copy_property_array_string()
932 * The overflow error means that the property is there and it is in acpi_data_prop_read()
933 * single-value, but its type does not match, so return. in acpi_data_prop_read()
935 if (ret >= 0 || ret == -EOVERFLOW) in acpi_data_prop_read()
939 * Reading this property as a single-value one failed, but its in acpi_data_prop_read()
940 * value may still be represented as one-element array, so in acpi_data_prop_read()
950 return obj->package.count; in acpi_data_prop_read()
952 if (proptype != DEV_PROP_STRING && nval > obj->package.count) in acpi_data_prop_read()
953 return -EOVERFLOW; in acpi_data_prop_read()
955 return -EINVAL; in acpi_data_prop_read()
957 items = obj->package.elements; in acpi_data_prop_read()
975 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
978 ret = -EINVAL; in acpi_data_prop_read()
985 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
986 * @fwnode: Firmware node to get the property from.
987 * @propname: Name of the property.
988 * @proptype: Expected property type.
989 * @val: Location to store the property value (if not %NULL).
993 * of the property. Otherwise, read at most @nval values to the array at the
1005 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1020 head = &adev->children; in acpi_get_next_subnode()
1029 next = adev->node.next; in acpi_get_next_subnode()
1056 head = &adev->data.subnodes; in acpi_get_next_subnode()
1058 head = &data->data.subnodes; in acpi_get_next_subnode()
1067 next = dn->sibling.next; in acpi_get_next_subnode()
1075 return &dn->fwnode; in acpi_get_next_subnode()
1081 * acpi_node_get_parent - Return parent fwnode of this fwnode
1091 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1095 handle = to_acpi_device_node(fwnode)->handle; in acpi_node_get_parent()
1111 static bool is_acpi_graph_node(struct fwnode_handle *fwnode, in is_acpi_graph_node()
1120 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1128 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1148 * have a "reg" property that also has the number of the in acpi_graph_get_next_endpoint()
1150 * recognised as a port node from the "port" property. in acpi_graph_get_next_endpoint()
1173 * the number of the endpoint node and they also have a "reg" property in acpi_graph_get_next_endpoint()
1176 * "endpoint" property. in acpi_graph_get_next_endpoint()
1185 * acpi_graph_get_child_prop_value - Return a child with a given property value
1187 * @prop_name: The name of the property to look for
1188 * @val: the desired property value
1214 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1228 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1253 static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) in acpi_fwnode_device_is_available()
1261 static bool acpi_fwnode_property_present(const struct fwnode_handle *fwnode, in acpi_fwnode_property_present()
1289 return -ENXIO; in acpi_fwnode_property_read_int_array()
1329 return dn->name; in acpi_fwnode_get_name()
1371 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1373 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1374 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1375 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1376 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1416 bool is_acpi_device_node(const struct fwnode_handle *fwnode) in is_acpi_device_node()
1419 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1423 bool is_acpi_data_node(const struct fwnode_handle *fwnode) in is_acpi_data_node()
1425 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()