Lines Matching +full:bool +full:- +full:property
27 /* ACPI _DSD device properties GUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
31 /* ACPI _DSD data subnodes GUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
36 static bool acpi_enumerate_nondev_subnodes(acpi_handle scope,
40 static bool acpi_extract_properties(const union acpi_object *desc,
43 static bool acpi_nondev_subnode_extract(const union acpi_object *desc, in acpi_nondev_subnode_extract()
50 bool result; in acpi_nondev_subnode_extract()
56 dn->name = link->package.elements[0].string.pointer; in acpi_nondev_subnode_extract()
57 dn->fwnode.ops = &acpi_data_fwnode_ops; in acpi_nondev_subnode_extract()
58 dn->parent = parent; in acpi_nondev_subnode_extract()
59 INIT_LIST_HEAD(&dn->data.subnodes); in acpi_nondev_subnode_extract()
61 result = acpi_extract_properties(desc, &dn->data); in acpi_nondev_subnode_extract()
75 && acpi_enumerate_nondev_subnodes(scope, desc, &dn->data, in acpi_nondev_subnode_extract()
76 &dn->fwnode)) in acpi_nondev_subnode_extract()
78 } else if (acpi_enumerate_nondev_subnodes(NULL, desc, &dn->data, in acpi_nondev_subnode_extract()
79 &dn->fwnode)) { in acpi_nondev_subnode_extract()
84 dn->handle = handle; in acpi_nondev_subnode_extract()
85 dn->data.pointer = desc; in acpi_nondev_subnode_extract()
86 list_add_tail(&dn->sibling, list); in acpi_nondev_subnode_extract()
95 static bool acpi_nondev_subnode_data_ok(acpi_handle handle, in acpi_nondev_subnode_data_ok()
116 static bool acpi_nondev_subnode_ok(acpi_handle scope, in acpi_nondev_subnode_ok()
127 status = acpi_get_handle(scope, link->package.elements[1].string.pointer, in acpi_nondev_subnode_ok()
140 bool ret = false; in acpi_add_nondev_subnodes()
143 for (i = 0; i < links->package.count; i++) { in acpi_add_nondev_subnodes()
146 bool result; in acpi_add_nondev_subnodes()
148 link = &links->package.elements[i]; in acpi_add_nondev_subnodes()
150 if (link->package.count != 2) in acpi_add_nondev_subnodes()
154 if (link->package.elements[0].type != ACPI_TYPE_STRING) in acpi_add_nondev_subnodes()
158 switch (link->package.elements[1].type) { in acpi_add_nondev_subnodes()
164 handle = link->package.elements[1].reference.handle; in acpi_add_nondev_subnodes()
169 desc = &link->package.elements[1]; in acpi_add_nondev_subnodes()
183 static bool acpi_enumerate_nondev_subnodes(acpi_handle scope, in acpi_enumerate_nondev_subnodes()
191 for (i = 0; i < desc->package.count; i += 2) { in acpi_enumerate_nondev_subnodes()
194 guid = &desc->package.elements[i]; in acpi_enumerate_nondev_subnodes()
195 links = &desc->package.elements[i + 1]; in acpi_enumerate_nondev_subnodes()
201 if (guid->type != ACPI_TYPE_BUFFER || in acpi_enumerate_nondev_subnodes()
202 guid->buffer.length != 16 || in acpi_enumerate_nondev_subnodes()
203 links->type != ACPI_TYPE_PACKAGE) in acpi_enumerate_nondev_subnodes()
206 if (!guid_equal((guid_t *)guid->buffer.pointer, &ads_guid)) in acpi_enumerate_nondev_subnodes()
209 return acpi_add_nondev_subnodes(scope, links, &data->subnodes, in acpi_enumerate_nondev_subnodes()
216 static bool acpi_property_value_ok(const union acpi_object *value) in acpi_property_value_ok()
224 switch (value->type) { in acpi_property_value_ok()
231 for (j = 0; j < value->package.count; j++) in acpi_property_value_ok()
232 switch (value->package.elements[j].type) { in acpi_property_value_ok()
247 static bool acpi_properties_format_valid(const union acpi_object *properties) in acpi_properties_format_valid()
251 for (i = 0; i < properties->package.count; i++) { in acpi_properties_format_valid()
252 const union acpi_object *property; in acpi_properties_format_valid() local
254 property = &properties->package.elements[i]; in acpi_properties_format_valid()
259 if (property->package.count != 2 in acpi_properties_format_valid()
260 || property->package.elements[0].type != ACPI_TYPE_STRING in acpi_properties_format_valid()
261 || !acpi_property_value_ok(&property->package.elements[1])) in acpi_properties_format_valid()
272 ret = acpi_data_get_property_array(&adev->data, "compatible", in acpi_init_of_compatible()
278 if (adev->parent in acpi_init_of_compatible()
279 && adev->parent->flags.of_compatible_ok) in acpi_init_of_compatible()
285 adev->data.of_compatible = of_compatible; in acpi_init_of_compatible()
288 adev->flags.of_compatible_ok = 1; in acpi_init_of_compatible()
291 static bool acpi_extract_properties(const union acpi_object *desc, in acpi_extract_properties()
296 if (desc->package.count % 2) in acpi_extract_properties()
300 for (i = 0; i < desc->package.count; i += 2) { in acpi_extract_properties()
303 guid = &desc->package.elements[i]; in acpi_extract_properties()
304 properties = &desc->package.elements[i + 1]; in acpi_extract_properties()
310 if (guid->type != ACPI_TYPE_BUFFER || in acpi_extract_properties()
311 guid->buffer.length != 16 || in acpi_extract_properties()
312 properties->type != ACPI_TYPE_PACKAGE) in acpi_extract_properties()
315 if (!guid_equal((guid_t *)guid->buffer.pointer, &prp_guid)) in acpi_extract_properties()
325 data->properties = properties; in acpi_extract_properties()
337 bool acpi_of = false; in acpi_init_properties()
339 INIT_LIST_HEAD(&adev->data.subnodes); in acpi_init_properties()
341 if (!adev->handle) in acpi_init_properties()
348 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_init_properties()
349 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) { in acpi_init_properties()
355 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf, in acpi_init_properties()
360 if (acpi_extract_properties(buf.pointer, &adev->data)) { in acpi_init_properties()
361 adev->data.pointer = buf.pointer; in acpi_init_properties()
365 if (acpi_enumerate_nondev_subnodes(adev->handle, buf.pointer, in acpi_init_properties()
366 &adev->data, acpi_fwnode_handle(adev))) in acpi_init_properties()
367 adev->data.pointer = buf.pointer; in acpi_init_properties()
369 if (!adev->data.pointer) { in acpi_init_properties()
370 acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n"); in acpi_init_properties()
375 if (acpi_of && !adev->flags.of_compatible_ok) in acpi_init_properties()
376 acpi_handle_info(adev->handle, in acpi_init_properties()
377 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n"); in acpi_init_properties()
379 if (!adev->data.pointer) in acpi_init_properties()
391 acpi_destroy_nondev_subnodes(&dn->data.subnodes); in acpi_destroy_nondev_subnodes()
392 wait_for_completion(&dn->kobj_done); in acpi_destroy_nondev_subnodes()
393 list_del(&dn->sibling); in acpi_destroy_nondev_subnodes()
394 ACPI_FREE((void *)dn->data.pointer); in acpi_destroy_nondev_subnodes()
401 acpi_destroy_nondev_subnodes(&adev->data.subnodes); in acpi_free_properties()
402 ACPI_FREE((void *)adev->data.pointer); in acpi_free_properties()
403 adev->data.of_compatible = NULL; in acpi_free_properties()
404 adev->data.pointer = NULL; in acpi_free_properties()
405 adev->data.properties = NULL; in acpi_free_properties()
409 * acpi_data_get_property - return an ACPI property with given name
410 * @data: ACPI device deta object to get the property from
411 * @name: Name of the property
412 * @type: Expected property type
413 * @obj: Location to store the property value (if not %NULL)
415 * Look up a property with @name and store a pointer to the resulting ACPI
421 * Return: %0 if property with @name has been found (success),
422 * %-EINVAL if the arguments are invalid,
423 * %-EINVAL if the property doesn't exist,
424 * %-EPROTO if the property value type doesn't match @type.
434 return -EINVAL; in acpi_data_get_property()
436 if (!data->pointer || !data->properties) in acpi_data_get_property()
437 return -EINVAL; in acpi_data_get_property()
439 properties = data->properties; in acpi_data_get_property()
440 for (i = 0; i < properties->package.count; i++) { in acpi_data_get_property()
442 const union acpi_object *property; in acpi_data_get_property() local
444 property = &properties->package.elements[i]; in acpi_data_get_property()
446 propname = &property->package.elements[0]; in acpi_data_get_property()
447 propvalue = &property->package.elements[1]; in acpi_data_get_property()
449 if (!strcmp(name, propname->string.pointer)) { in acpi_data_get_property()
450 if (type != ACPI_TYPE_ANY && propvalue->type != type) in acpi_data_get_property()
451 return -EPROTO; in acpi_data_get_property()
458 return -EINVAL; in acpi_data_get_property()
462 * acpi_dev_get_property - return an ACPI property with given name.
463 * @adev: ACPI device to get the property from.
464 * @name: Name of the property.
465 * @type: Expected property type.
466 * @obj: Location to store the property value (if not %NULL).
471 return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; in acpi_dev_get_property()
480 return &adev->data; in acpi_device_data_of_node()
483 return &dn->data; in acpi_device_data_of_node()
489 * acpi_node_prop_get - return an ACPI property with given name.
490 * @fwnode: Firmware node to get the property from.
491 * @propname: Name of the property.
492 * @valptr: Location to store a pointer to the property value (if not %NULL).
503 * acpi_data_get_property_array - return an ACPI array property with given name
504 * @adev: ACPI data object to get the property from
505 * @name: Name of the property
507 * @obj: Location to store a pointer to the property value (if not NULL)
509 * Look up an array property with @name and store a pointer to the resulting
515 * Return: %0 if array property (package) with @name has been found (success),
516 * %-EINVAL if the arguments are invalid,
517 * %-EINVAL if the property doesn't exist,
518 * %-EPROTO if the property is not a package or the type of its elements
535 for (i = 0; i < prop->package.count; i++) in acpi_data_get_property_array()
536 if (prop->package.elements[i].type != type) in acpi_data_get_property_array()
537 return -EPROTO; in acpi_data_get_property_array()
553 * For ACPI this will be a data only sub-node. in acpi_fwnode_get_named_child_node()
563 * __acpi_node_get_property_reference - returns handle to the referenced object
564 * @fwnode: Firmware node to get the property from
565 * @propname: Name of the property
570 * Find property with @name, verifify that it is a package containing at least
572 * target object in @args->adev. If the reference includes arguments, store
573 * them in the @args->args[] array.
575 * If there's more than one reference in the property value package, @index is
578 * It is possible to leave holes in the property value set like in the
582 * "cs-gpios",
591 * Calling this function with index %2 or index %3 return %-ENOENT. If the
592 * property does not contain any more values %-ENOENT is returned. The NULL
609 return -ENOENT; in __acpi_node_get_property_reference()
613 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
619 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
621 return -EINVAL; in __acpi_node_get_property_reference()
623 ret = acpi_bus_get_device(obj->reference.handle, &device); in __acpi_node_get_property_reference()
625 return ret == -ENODEV ? -EINVAL : ret; in __acpi_node_get_property_reference()
627 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
628 args->nargs = 0; in __acpi_node_get_property_reference()
641 if (obj->type != ACPI_TYPE_PACKAGE) in __acpi_node_get_property_reference()
642 return -EINVAL; in __acpi_node_get_property_reference()
643 if (index >= obj->package.count) in __acpi_node_get_property_reference()
644 return -ENOENT; in __acpi_node_get_property_reference()
646 element = obj->package.elements; in __acpi_node_get_property_reference()
647 end = element + obj->package.count; in __acpi_node_get_property_reference()
652 if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { in __acpi_node_get_property_reference()
655 ret = acpi_bus_get_device(element->reference.handle, in __acpi_node_get_property_reference()
658 return -EINVAL; in __acpi_node_get_property_reference()
668 element < end && element->type == ACPI_TYPE_STRING; in __acpi_node_get_property_reference()
671 ref_fwnode, element->string.pointer); in __acpi_node_get_property_reference()
673 return -EINVAL; in __acpi_node_get_property_reference()
685 return -EINVAL; in __acpi_node_get_property_reference()
689 return -EINVAL; in __acpi_node_get_property_reference()
692 args->fwnode = ref_fwnode; in __acpi_node_get_property_reference()
693 args->nargs = nargs; in __acpi_node_get_property_reference()
695 args->args[i] = element[i].integer.value; in __acpi_node_get_property_reference()
701 } else if (element->type == ACPI_TYPE_INTEGER) { in __acpi_node_get_property_reference()
703 return -ENOENT; in __acpi_node_get_property_reference()
706 return -EINVAL; in __acpi_node_get_property_reference()
712 return -ENOENT; in __acpi_node_get_property_reference()
724 return -EINVAL; in acpi_data_prop_read_single()
733 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
734 return -EOVERFLOW; in acpi_data_prop_read_single()
735 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
738 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
739 return -EOVERFLOW; in acpi_data_prop_read_single()
740 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
743 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
744 return -EOVERFLOW; in acpi_data_prop_read_single()
745 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
748 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
756 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
760 ret = -EINVAL; in acpi_data_prop_read_single()
771 return -EINVAL; in acpi_dev_prop_read_single()
773 ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); in acpi_dev_prop_read_single()
786 return -EPROTO; in acpi_copy_property_array_u8()
788 return -EOVERFLOW; in acpi_copy_property_array_u8()
802 return -EPROTO; in acpi_copy_property_array_u16()
804 return -EOVERFLOW; in acpi_copy_property_array_u16()
818 return -EPROTO; in acpi_copy_property_array_u32()
820 return -EOVERFLOW; in acpi_copy_property_array_u32()
834 return -EPROTO; in acpi_copy_property_array_u64()
848 return -EPROTO; in acpi_copy_property_array_string()
875 return obj->package.count; in acpi_data_prop_read()
877 if (proptype != DEV_PROP_STRING && nval > obj->package.count) in acpi_data_prop_read()
878 return -EOVERFLOW; in acpi_data_prop_read()
880 return -EINVAL; in acpi_data_prop_read()
882 items = obj->package.elements; in acpi_data_prop_read()
900 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
903 ret = -EINVAL; in acpi_data_prop_read()
912 return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; in acpi_dev_prop_read()
916 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
917 * @fwnode: Firmware node to get the property from.
918 * @propname: Name of the property.
919 * @proptype: Expected property type.
920 * @val: Location to store the property value (if not %NULL).
924 * of the property. Otherwise, read at most @nval values to the array at the
936 * acpi_get_next_subnode - Return the next child node handle for a fwnode
951 head = &adev->children; in acpi_get_next_subnode()
960 next = adev->node.next; in acpi_get_next_subnode()
987 head = &adev->data.subnodes; in acpi_get_next_subnode()
989 head = &data->data.subnodes; in acpi_get_next_subnode()
998 next = dn->sibling.next; in acpi_get_next_subnode()
1006 return &dn->fwnode; in acpi_get_next_subnode()
1012 * acpi_node_get_parent - Return parent fwnode of this fwnode
1022 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1026 handle = to_acpi_device_node(fwnode)->handle; in acpi_node_get_parent()
1042 static bool is_acpi_graph_node(struct fwnode_handle *fwnode, in is_acpi_graph_node()
1051 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1059 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1079 * have a "reg" property that also has the number of the in acpi_graph_get_next_endpoint()
1081 * recognised as a port node from the "port" property. in acpi_graph_get_next_endpoint()
1104 * the number of the endpoint node and they also have a "reg" property in acpi_graph_get_next_endpoint()
1107 * "endpoint" property. in acpi_graph_get_next_endpoint()
1116 * acpi_graph_get_child_prop_value - Return a child with a given property value
1118 * @prop_name: The name of the property to look for
1119 * @val: the desired property value
1145 * acpi_graph_get_remote_enpoint - Parses and returns remote end of an endpoint
1160 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1185 static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) in acpi_fwnode_device_is_available()
1193 static bool acpi_fwnode_property_present(const struct fwnode_handle *fwnode, in acpi_fwnode_property_present()
1221 return -ENXIO; in acpi_fwnode_property_read_int_array()
1257 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1259 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1260 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1261 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1262 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1300 bool is_acpi_device_node(const struct fwnode_handle *fwnode) in is_acpi_device_node()
1303 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1307 bool is_acpi_data_node(const struct fwnode_handle *fwnode) in is_acpi_data_node()
1309 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()