Lines Matching +full:int +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0-only
19 static int acpi_data_get_property_array(const struct acpi_device_data *data,
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()
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()
158 static int acpi_add_nondev_subnodes(acpi_handle scope, in acpi_add_nondev_subnodes()
164 int i; in acpi_add_nondev_subnodes()
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()
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()
211 int i; 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()
241 int j; 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()
272 int i; 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()
293 int ret; in acpi_init_of_compatible()
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()
316 int i; 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()
346 int i; 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()
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.
484 static int acpi_data_get_property(const struct acpi_device_data *data, in acpi_data_get_property()
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()
498 unsigned int i; 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).
531 int acpi_dev_get_property(const struct acpi_device *adev, const char *name, in acpi_dev_get_property()
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).
557 int acpi_node_prop_get(const struct fwnode_handle *fwnode, in acpi_node_prop_get()
566 * acpi_data_get_property_array - return an ACPI array property with given name
567 * @adev: 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
584 static int acpi_data_get_property_array(const struct acpi_device_data *data, in acpi_data_get_property_array()
590 int ret, i; in acpi_data_get_property_array()
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
664 int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, in __acpi_node_get_property_reference()
672 int ret, idx = 0; in __acpi_node_get_property_reference()
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()
703 * Package () { REF, INT, REF, INT, INT } 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()
745 int type = element[i].type; 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()
783 static int acpi_data_prop_read_single(const struct acpi_device_data *data, in acpi_data_prop_read_single()
788 int ret; in acpi_data_prop_read_single()
791 return -EINVAL; in acpi_data_prop_read_single()
800 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
801 return -EOVERFLOW; in acpi_data_prop_read_single()
802 *(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()
807 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
810 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
811 return -EOVERFLOW; in acpi_data_prop_read_single()
812 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
815 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
823 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
827 ret = -EINVAL; in acpi_data_prop_read_single()
832 int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, in acpi_dev_prop_read_single()
835 int ret; in acpi_dev_prop_read_single()
838 return -EINVAL; in acpi_dev_prop_read_single()
840 ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); in acpi_dev_prop_read_single()
846 static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, in acpi_copy_property_array_u8()
849 int i; in acpi_copy_property_array_u8()
853 return -EPROTO; in acpi_copy_property_array_u8()
855 return -EOVERFLOW; in acpi_copy_property_array_u8()
862 static int acpi_copy_property_array_u16(const union acpi_object *items, in acpi_copy_property_array_u16()
865 int i; in acpi_copy_property_array_u16()
869 return -EPROTO; in acpi_copy_property_array_u16()
871 return -EOVERFLOW; in acpi_copy_property_array_u16()
878 static int acpi_copy_property_array_u32(const union acpi_object *items, in acpi_copy_property_array_u32()
881 int i; in acpi_copy_property_array_u32()
885 return -EPROTO; in acpi_copy_property_array_u32()
887 return -EOVERFLOW; in acpi_copy_property_array_u32()
894 static int acpi_copy_property_array_u64(const union acpi_object *items, in acpi_copy_property_array_u64()
897 int i; in acpi_copy_property_array_u64()
901 return -EPROTO; in acpi_copy_property_array_u64()
908 static int acpi_copy_property_array_string(const union acpi_object *items, in acpi_copy_property_array_string()
911 int i; in acpi_copy_property_array_string()
915 return -EPROTO; in acpi_copy_property_array_string()
922 static int acpi_data_prop_read(const struct acpi_device_data *data, in acpi_data_prop_read()
929 int ret; in acpi_data_prop_read()
942 return obj->package.count; in acpi_data_prop_read()
944 if (proptype != DEV_PROP_STRING && nval > obj->package.count) in acpi_data_prop_read()
945 return -EOVERFLOW; in acpi_data_prop_read()
947 return -EINVAL; in acpi_data_prop_read()
949 items = obj->package.elements; in acpi_data_prop_read()
967 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
970 ret = -EINVAL; in acpi_data_prop_read()
976 int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname, in acpi_dev_prop_read()
979 return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; in acpi_dev_prop_read()
983 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
984 * @fwnode: Firmware node to get the property from.
985 * @propname: Name of the property.
986 * @proptype: Expected property type.
987 * @val: Location to store the property value (if not %NULL).
991 * of the property. Otherwise, read at most @nval values to the array at the
994 int acpi_node_prop_read(const struct fwnode_handle *fwnode, in acpi_node_prop_read()
1003 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1018 head = &adev->children; in acpi_get_next_subnode()
1027 next = adev->node.next; in acpi_get_next_subnode()
1054 head = &adev->data.subnodes; in acpi_get_next_subnode()
1056 head = &data->data.subnodes; in acpi_get_next_subnode()
1065 next = dn->sibling.next; in acpi_get_next_subnode()
1073 return &dn->fwnode; in acpi_get_next_subnode()
1079 * acpi_node_get_parent - Return parent fwnode of this fwnode
1089 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1093 handle = to_acpi_device_node(fwnode)->handle; in acpi_node_get_parent()
1112 unsigned int len = strlen(str); in is_acpi_graph_node()
1118 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1126 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1146 * have a "reg" property that also has the number of the in acpi_graph_get_next_endpoint()
1148 * recognised as a port node from the "port" property. in acpi_graph_get_next_endpoint()
1171 * the number of the endpoint node and they also have a "reg" property in acpi_graph_get_next_endpoint()
1174 * "endpoint" property. in acpi_graph_get_next_endpoint()
1183 * acpi_graph_get_child_prop_value - Return a child with a given property value
1185 * @prop_name: The name of the property to look for
1186 * @val: the desired property value
1193 unsigned int val) in acpi_graph_get_child_prop_value()
1212 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1222 unsigned int port_nr, endpoint_nr; in acpi_graph_get_remote_endpoint()
1224 int ret; in acpi_graph_get_remote_endpoint()
1227 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1266 static int
1269 unsigned int elem_size, void *val, in acpi_fwnode_property_read_int_array()
1288 return -ENXIO; in acpi_fwnode_property_read_int_array()
1294 static int
1303 static int
1306 unsigned int args_count, unsigned int index, in acpi_fwnode_get_reference_args()
1328 return dn->name; in acpi_fwnode_get_name()
1365 static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, in acpi_fwnode_graph_parse_endpoint()
1370 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1372 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1373 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1374 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1375 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1418 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1424 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()