diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-08-26 22:40:05 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-09-14 19:47:34 -0400 |
commit | 3a7a2ab839ad18c2d542b40f4a647c98d068e55a (patch) | |
tree | fca2c5a901c97d41b2aa3ad44d72299b32226183 | |
parent | 263b4c1a64bc12470684aeaf7c44f03d31716819 (diff) |
ACPI / property: Extend fwnode_property_* to data-only subnodes
Modify is_acpi_node() to return "true" for ACPI data-only subnodes as
well as for ACPI device objects and change the name of to_acpi_node()
to to_acpi_device_node() so it is clear that it covers ACPI device
objects only. Accordingly, introduce to_acpi_data_node() to cover
data-only subnodes in an analogous way.
With that, make the fwnode_property_* family of functions work with
ACPI data-only subnodes introduced previously.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r-- | drivers/acpi/property.c | 138 | ||||
-rw-r--r-- | drivers/base/property.c | 16 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 6 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 21 | ||||
-rw-r--r-- | include/linux/acpi.h | 53 |
5 files changed, 173 insertions, 61 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 333f9146d19e..e78551726acb 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c | |||
@@ -19,6 +19,11 @@ | |||
19 | 19 | ||
20 | #include "internal.h" | 20 | #include "internal.h" |
21 | 21 | ||
22 | static int acpi_data_get_property_array(struct acpi_device_data *data, | ||
23 | const char *name, | ||
24 | acpi_object_type type, | ||
25 | const union acpi_object **obj); | ||
26 | |||
22 | /* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */ | 27 | /* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */ |
23 | static const u8 prp_uuid[16] = { | 28 | static const u8 prp_uuid[16] = { |
24 | 0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d, | 29 | 0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d, |
@@ -191,8 +196,8 @@ static void acpi_init_of_compatible(struct acpi_device *adev) | |||
191 | const union acpi_object *of_compatible; | 196 | const union acpi_object *of_compatible; |
192 | int ret; | 197 | int ret; |
193 | 198 | ||
194 | ret = acpi_dev_get_property_array(adev, "compatible", ACPI_TYPE_STRING, | 199 | ret = acpi_data_get_property_array(&adev->data, "compatible", |
195 | &of_compatible); | 200 | ACPI_TYPE_STRING, &of_compatible); |
196 | if (ret) { | 201 | if (ret) { |
197 | ret = acpi_dev_get_property(adev, "compatible", | 202 | ret = acpi_dev_get_property(adev, "compatible", |
198 | ACPI_TYPE_STRING, &of_compatible); | 203 | ACPI_TYPE_STRING, &of_compatible); |
@@ -320,8 +325,8 @@ void acpi_free_properties(struct acpi_device *adev) | |||
320 | } | 325 | } |
321 | 326 | ||
322 | /** | 327 | /** |
323 | * acpi_dev_get_property - return an ACPI property with given name | 328 | * acpi_data_get_property - return an ACPI property with given name |
324 | * @adev: ACPI device to get property | 329 | * @data: ACPI device deta object to get the property from |
325 | * @name: Name of the property | 330 | * @name: Name of the property |
326 | * @type: Expected property type | 331 | * @type: Expected property type |
327 | * @obj: Location to store the property value (if not %NULL) | 332 | * @obj: Location to store the property value (if not %NULL) |
@@ -330,26 +335,27 @@ void acpi_free_properties(struct acpi_device *adev) | |||
330 | * object at the location pointed to by @obj if found. | 335 | * object at the location pointed to by @obj if found. |
331 | * | 336 | * |
332 | * Callers must not attempt to free the returned objects. These objects will be | 337 | * Callers must not attempt to free the returned objects. These objects will be |
333 | * freed by the ACPI core automatically during the removal of @adev. | 338 | * freed by the ACPI core automatically during the removal of @data. |
334 | * | 339 | * |
335 | * Return: %0 if property with @name has been found (success), | 340 | * Return: %0 if property with @name has been found (success), |
336 | * %-EINVAL if the arguments are invalid, | 341 | * %-EINVAL if the arguments are invalid, |
337 | * %-ENODATA if the property doesn't exist, | 342 | * %-ENODATA if the property doesn't exist, |
338 | * %-EPROTO if the property value type doesn't match @type. | 343 | * %-EPROTO if the property value type doesn't match @type. |
339 | */ | 344 | */ |
340 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, | 345 | static int acpi_data_get_property(struct acpi_device_data *data, |
341 | acpi_object_type type, const union acpi_object **obj) | 346 | const char *name, acpi_object_type type, |
347 | const union acpi_object **obj) | ||
342 | { | 348 | { |
343 | const union acpi_object *properties; | 349 | const union acpi_object *properties; |
344 | int i; | 350 | int i; |
345 | 351 | ||
346 | if (!adev || !name) | 352 | if (!data || !name) |
347 | return -EINVAL; | 353 | return -EINVAL; |
348 | 354 | ||
349 | if (!adev->data.pointer || !adev->data.properties) | 355 | if (!data->pointer || !data->properties) |
350 | return -ENODATA; | 356 | return -ENODATA; |
351 | 357 | ||
352 | properties = adev->data.properties; | 358 | properties = data->properties; |
353 | for (i = 0; i < properties->package.count; i++) { | 359 | for (i = 0; i < properties->package.count; i++) { |
354 | const union acpi_object *propname, *propvalue; | 360 | const union acpi_object *propname, *propvalue; |
355 | const union acpi_object *property; | 361 | const union acpi_object *property; |
@@ -370,11 +376,50 @@ int acpi_dev_get_property(struct acpi_device *adev, const char *name, | |||
370 | } | 376 | } |
371 | return -ENODATA; | 377 | return -ENODATA; |
372 | } | 378 | } |
379 | |||
380 | /** | ||
381 | * acpi_dev_get_property - return an ACPI property with given name. | ||
382 | * @adev: ACPI device to get the property from. | ||
383 | * @name: Name of the property. | ||
384 | * @type: Expected property type. | ||
385 | * @obj: Location to store the property value (if not %NULL). | ||
386 | */ | ||
387 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, | ||
388 | acpi_object_type type, const union acpi_object **obj) | ||
389 | { | ||
390 | return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; | ||
391 | } | ||
373 | EXPORT_SYMBOL_GPL(acpi_dev_get_property); | 392 | EXPORT_SYMBOL_GPL(acpi_dev_get_property); |
374 | 393 | ||
394 | static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *fwnode) | ||
395 | { | ||
396 | if (fwnode->type == FWNODE_ACPI) { | ||
397 | struct acpi_device *adev = to_acpi_device_node(fwnode); | ||
398 | return &adev->data; | ||
399 | } else if (fwnode->type == FWNODE_ACPI_DATA) { | ||
400 | struct acpi_data_node *dn = to_acpi_data_node(fwnode); | ||
401 | return &dn->data; | ||
402 | } | ||
403 | return NULL; | ||
404 | } | ||
405 | |||
375 | /** | 406 | /** |
376 | * acpi_dev_get_property_array - return an ACPI array property with given name | 407 | * acpi_node_prop_get - return an ACPI property with given name. |
377 | * @adev: ACPI device to get property | 408 | * @fwnode: Firmware node to get the property from. |
409 | * @propname: Name of the property. | ||
410 | * @valptr: Location to store a pointer to the property value (if not %NULL). | ||
411 | */ | ||
412 | int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname, | ||
413 | void **valptr) | ||
414 | { | ||
415 | return acpi_data_get_property(acpi_device_data_of_node(fwnode), | ||
416 | propname, ACPI_TYPE_ANY, | ||
417 | (const union acpi_object **)valptr); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * acpi_data_get_property_array - return an ACPI array property with given name | ||
422 | * @adev: ACPI data object to get the property from | ||
378 | * @name: Name of the property | 423 | * @name: Name of the property |
379 | * @type: Expected type of array elements | 424 | * @type: Expected type of array elements |
380 | * @obj: Location to store a pointer to the property value (if not NULL) | 425 | * @obj: Location to store a pointer to the property value (if not NULL) |
@@ -383,7 +428,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property); | |||
383 | * ACPI object at the location pointed to by @obj if found. | 428 | * ACPI object at the location pointed to by @obj if found. |
384 | * | 429 | * |
385 | * Callers must not attempt to free the returned objects. Those objects will be | 430 | * Callers must not attempt to free the returned objects. Those objects will be |
386 | * freed by the ACPI core automatically during the removal of @adev. | 431 | * freed by the ACPI core automatically during the removal of @data. |
387 | * | 432 | * |
388 | * Return: %0 if array property (package) with @name has been found (success), | 433 | * Return: %0 if array property (package) with @name has been found (success), |
389 | * %-EINVAL if the arguments are invalid, | 434 | * %-EINVAL if the arguments are invalid, |
@@ -391,14 +436,15 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property); | |||
391 | * %-EPROTO if the property is not a package or the type of its elements | 436 | * %-EPROTO if the property is not a package or the type of its elements |
392 | * doesn't match @type. | 437 | * doesn't match @type. |
393 | */ | 438 | */ |
394 | int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, | 439 | static int acpi_data_get_property_array(struct acpi_device_data *data, |
395 | acpi_object_type type, | 440 | const char *name, |
396 | const union acpi_object **obj) | 441 | acpi_object_type type, |
442 | const union acpi_object **obj) | ||
397 | { | 443 | { |
398 | const union acpi_object *prop; | 444 | const union acpi_object *prop; |
399 | int ret, i; | 445 | int ret, i; |
400 | 446 | ||
401 | ret = acpi_dev_get_property(adev, name, ACPI_TYPE_PACKAGE, &prop); | 447 | ret = acpi_data_get_property(data, name, ACPI_TYPE_PACKAGE, &prop); |
402 | if (ret) | 448 | if (ret) |
403 | return ret; | 449 | return ret; |
404 | 450 | ||
@@ -413,7 +459,6 @@ int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, | |||
413 | 459 | ||
414 | return 0; | 460 | return 0; |
415 | } | 461 | } |
416 | EXPORT_SYMBOL_GPL(acpi_dev_get_property_array); | ||
417 | 462 | ||
418 | /** | 463 | /** |
419 | * acpi_dev_get_property_reference - returns handle to the referenced object | 464 | * acpi_dev_get_property_reference - returns handle to the referenced object |
@@ -518,15 +563,9 @@ int acpi_dev_get_property_reference(struct acpi_device *adev, | |||
518 | } | 563 | } |
519 | EXPORT_SYMBOL_GPL(acpi_dev_get_property_reference); | 564 | EXPORT_SYMBOL_GPL(acpi_dev_get_property_reference); |
520 | 565 | ||
521 | int acpi_dev_prop_get(struct acpi_device *adev, const char *propname, | 566 | static int acpi_data_prop_read_single(struct acpi_device_data *data, |
522 | void **valptr) | 567 | const char *propname, |
523 | { | 568 | enum dev_prop_type proptype, void *val) |
524 | return acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, | ||
525 | (const union acpi_object **)valptr); | ||
526 | } | ||
527 | |||
528 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | ||
529 | enum dev_prop_type proptype, void *val) | ||
530 | { | 569 | { |
531 | const union acpi_object *obj; | 570 | const union acpi_object *obj; |
532 | int ret; | 571 | int ret; |
@@ -535,7 +574,7 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | |||
535 | return -EINVAL; | 574 | return -EINVAL; |
536 | 575 | ||
537 | if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) { | 576 | if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) { |
538 | ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_INTEGER, &obj); | 577 | ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj); |
539 | if (ret) | 578 | if (ret) |
540 | return ret; | 579 | return ret; |
541 | 580 | ||
@@ -560,7 +599,7 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | |||
560 | break; | 599 | break; |
561 | } | 600 | } |
562 | } else if (proptype == DEV_PROP_STRING) { | 601 | } else if (proptype == DEV_PROP_STRING) { |
563 | ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_STRING, &obj); | 602 | ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj); |
564 | if (ret) | 603 | if (ret) |
565 | return ret; | 604 | return ret; |
566 | 605 | ||
@@ -571,6 +610,12 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | |||
571 | return ret; | 610 | return ret; |
572 | } | 611 | } |
573 | 612 | ||
613 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | ||
614 | enum dev_prop_type proptype, void *val) | ||
615 | { | ||
616 | return adev ? acpi_data_prop_read_single(&adev->data, propname, proptype, val) : -EINVAL; | ||
617 | } | ||
618 | |||
574 | static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, | 619 | static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, |
575 | size_t nval) | 620 | size_t nval) |
576 | { | 621 | { |
@@ -647,20 +692,22 @@ static int acpi_copy_property_array_string(const union acpi_object *items, | |||
647 | return 0; | 692 | return 0; |
648 | } | 693 | } |
649 | 694 | ||
650 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, | 695 | static int acpi_data_prop_read(struct acpi_device_data *data, |
651 | enum dev_prop_type proptype, void *val, size_t nval) | 696 | const char *propname, |
697 | enum dev_prop_type proptype, | ||
698 | void *val, size_t nval) | ||
652 | { | 699 | { |
653 | const union acpi_object *obj; | 700 | const union acpi_object *obj; |
654 | const union acpi_object *items; | 701 | const union acpi_object *items; |
655 | int ret; | 702 | int ret; |
656 | 703 | ||
657 | if (val && nval == 1) { | 704 | if (val && nval == 1) { |
658 | ret = acpi_dev_prop_read_single(adev, propname, proptype, val); | 705 | ret = acpi_data_prop_read_single(data, propname, proptype, val); |
659 | if (!ret) | 706 | if (!ret) |
660 | return ret; | 707 | return ret; |
661 | } | 708 | } |
662 | 709 | ||
663 | ret = acpi_dev_get_property_array(adev, propname, ACPI_TYPE_ANY, &obj); | 710 | ret = acpi_data_get_property_array(data, propname, ACPI_TYPE_ANY, &obj); |
664 | if (ret) | 711 | if (ret) |
665 | return ret; | 712 | return ret; |
666 | 713 | ||
@@ -696,3 +743,28 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, | |||
696 | } | 743 | } |
697 | return ret; | 744 | return ret; |
698 | } | 745 | } |
746 | |||
747 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, | ||
748 | enum dev_prop_type proptype, void *val, size_t nval) | ||
749 | { | ||
750 | return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; | ||
751 | } | ||
752 | |||
753 | /** | ||
754 | * acpi_node_prop_read - retrieve the value of an ACPI property with given name. | ||
755 | * @fwnode: Firmware node to get the property from. | ||
756 | * @propname: Name of the property. | ||
757 | * @proptype: Expected property type. | ||
758 | * @val: Location to store the property value (if not %NULL). | ||
759 | * @nval: Size of the array pointed to by @val. | ||
760 | * | ||
761 | * If @val is %NULL, return the number of array elements comprising the value | ||
762 | * of the property. Otherwise, read at most @nval values to the array at the | ||
763 | * location pointed to by @val. | ||
764 | */ | ||
765 | int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname, | ||
766 | enum dev_prop_type proptype, void *val, size_t nval) | ||
767 | { | ||
768 | return acpi_data_prop_read(acpi_device_data_of_node(fwnode), | ||
769 | propname, proptype, val, nval); | ||
770 | } | ||
diff --git a/drivers/base/property.c b/drivers/base/property.c index 2d75366c61e0..ca118169a6c5 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
@@ -134,7 +134,7 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname) | |||
134 | if (is_of_node(fwnode)) | 134 | if (is_of_node(fwnode)) |
135 | return of_property_read_bool(to_of_node(fwnode), propname); | 135 | return of_property_read_bool(to_of_node(fwnode), propname); |
136 | else if (is_acpi_node(fwnode)) | 136 | else if (is_acpi_node(fwnode)) |
137 | return !acpi_dev_prop_get(to_acpi_node(fwnode), propname, NULL); | 137 | return !acpi_node_prop_get(fwnode, propname, NULL); |
138 | 138 | ||
139 | return !!pset_prop_get(to_pset(fwnode), propname); | 139 | return !!pset_prop_get(to_pset(fwnode), propname); |
140 | } | 140 | } |
@@ -298,8 +298,8 @@ EXPORT_SYMBOL_GPL(device_property_read_string); | |||
298 | _ret_ = OF_DEV_PROP_READ_ARRAY(to_of_node(_fwnode_), _propname_, \ | 298 | _ret_ = OF_DEV_PROP_READ_ARRAY(to_of_node(_fwnode_), _propname_, \ |
299 | _type_, _val_, _nval_); \ | 299 | _type_, _val_, _nval_); \ |
300 | else if (is_acpi_node(_fwnode_)) \ | 300 | else if (is_acpi_node(_fwnode_)) \ |
301 | _ret_ = acpi_dev_prop_read(to_acpi_node(_fwnode_), _propname_, \ | 301 | _ret_ = acpi_node_prop_read(_fwnode_, _propname_, _proptype_, \ |
302 | _proptype_, _val_, _nval_); \ | 302 | _val_, _nval_); \ |
303 | else if (is_pset(_fwnode_)) \ | 303 | else if (is_pset(_fwnode_)) \ |
304 | _ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \ | 304 | _ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \ |
305 | _proptype_, _val_, _nval_); \ | 305 | _proptype_, _val_, _nval_); \ |
@@ -440,8 +440,8 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode, | |||
440 | propname, val, nval) : | 440 | propname, val, nval) : |
441 | of_property_count_strings(to_of_node(fwnode), propname); | 441 | of_property_count_strings(to_of_node(fwnode), propname); |
442 | else if (is_acpi_node(fwnode)) | 442 | else if (is_acpi_node(fwnode)) |
443 | return acpi_dev_prop_read(to_acpi_node(fwnode), propname, | 443 | return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING, |
444 | DEV_PROP_STRING, val, nval); | 444 | val, nval); |
445 | else if (is_pset(fwnode)) | 445 | else if (is_pset(fwnode)) |
446 | return pset_prop_read_array(to_pset(fwnode), propname, | 446 | return pset_prop_read_array(to_pset(fwnode), propname, |
447 | DEV_PROP_STRING, val, nval); | 447 | DEV_PROP_STRING, val, nval); |
@@ -470,8 +470,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode, | |||
470 | if (is_of_node(fwnode)) | 470 | if (is_of_node(fwnode)) |
471 | return of_property_read_string(to_of_node(fwnode), propname, val); | 471 | return of_property_read_string(to_of_node(fwnode), propname, val); |
472 | else if (is_acpi_node(fwnode)) | 472 | else if (is_acpi_node(fwnode)) |
473 | return acpi_dev_prop_read(to_acpi_node(fwnode), propname, | 473 | return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING, |
474 | DEV_PROP_STRING, val, 1); | 474 | val, 1); |
475 | 475 | ||
476 | return pset_prop_read_array(to_pset(fwnode), propname, | 476 | return pset_prop_read_array(to_pset(fwnode), propname, |
477 | DEV_PROP_STRING, val, 1); | 477 | DEV_PROP_STRING, val, 1); |
@@ -495,7 +495,7 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev, | |||
495 | } else if (IS_ENABLED(CONFIG_ACPI)) { | 495 | } else if (IS_ENABLED(CONFIG_ACPI)) { |
496 | struct acpi_device *node; | 496 | struct acpi_device *node; |
497 | 497 | ||
498 | node = acpi_get_next_child(dev, to_acpi_node(child)); | 498 | node = acpi_get_next_child(dev, to_acpi_device_node(child)); |
499 | if (node) | 499 | if (node) |
500 | return acpi_fwnode_handle(node); | 500 | return acpi_fwnode_handle(node); |
501 | } | 501 | } |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 980c1f87866a..f43e808a49d9 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -2083,11 +2083,11 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
2083 | &flags); | 2083 | &flags); |
2084 | if (!IS_ERR(desc)) | 2084 | if (!IS_ERR(desc)) |
2085 | active_low = flags & OF_GPIO_ACTIVE_LOW; | 2085 | active_low = flags & OF_GPIO_ACTIVE_LOW; |
2086 | } else if (is_acpi_node(fwnode)) { | 2086 | } else if (is_acpi_device_node(fwnode)) { |
2087 | struct acpi_gpio_info info; | 2087 | struct acpi_gpio_info info; |
2088 | 2088 | ||
2089 | desc = acpi_get_gpiod_by_index(to_acpi_node(fwnode), propname, 0, | 2089 | desc = acpi_get_gpiod_by_index(to_acpi_device_node(fwnode), |
2090 | &info); | 2090 | propname, 0, &info); |
2091 | if (!IS_ERR(desc)) | 2091 | if (!IS_ERR(desc)) |
2092 | active_low = info.active_low; | 2092 | active_low = info.active_low; |
2093 | } | 2093 | } |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index e0d7c193d6e0..e234725eadc7 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -425,15 +425,32 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) | |||
425 | 425 | ||
426 | static inline bool is_acpi_node(struct fwnode_handle *fwnode) | 426 | static inline bool is_acpi_node(struct fwnode_handle *fwnode) |
427 | { | 427 | { |
428 | return fwnode && (fwnode->type == FWNODE_ACPI | ||
429 | || fwnode->type == FWNODE_ACPI_DATA); | ||
430 | } | ||
431 | |||
432 | static inline bool is_acpi_device_node(struct fwnode_handle *fwnode) | ||
433 | { | ||
428 | return fwnode && fwnode->type == FWNODE_ACPI; | 434 | return fwnode && fwnode->type == FWNODE_ACPI; |
429 | } | 435 | } |
430 | 436 | ||
431 | static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode) | 437 | static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode) |
432 | { | 438 | { |
433 | return is_acpi_node(fwnode) ? | 439 | return is_acpi_device_node(fwnode) ? |
434 | container_of(fwnode, struct acpi_device, fwnode) : NULL; | 440 | container_of(fwnode, struct acpi_device, fwnode) : NULL; |
435 | } | 441 | } |
436 | 442 | ||
443 | static inline bool is_acpi_data_node(struct fwnode_handle *fwnode) | ||
444 | { | ||
445 | return fwnode && fwnode->type == FWNODE_ACPI_DATA; | ||
446 | } | ||
447 | |||
448 | static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode) | ||
449 | { | ||
450 | return is_acpi_data_node(fwnode) ? | ||
451 | container_of(fwnode, struct acpi_data_node, fwnode) : NULL; | ||
452 | } | ||
453 | |||
437 | static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) | 454 | static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) |
438 | { | 455 | { |
439 | return &adev->fwnode; | 456 | return &adev->fwnode; |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 7235c4851460..6be94ba4e980 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -49,7 +49,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) | |||
49 | return adev ? adev->handle : NULL; | 49 | return adev ? adev->handle : NULL; |
50 | } | 50 | } |
51 | 51 | ||
52 | #define ACPI_COMPANION(dev) to_acpi_node((dev)->fwnode) | 52 | #define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode) |
53 | #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ | 53 | #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ |
54 | acpi_fwnode_handle(adev) : NULL) | 54 | acpi_fwnode_handle(adev) : NULL) |
55 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) | 55 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) |
@@ -69,7 +69,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) | |||
69 | 69 | ||
70 | static inline bool has_acpi_companion(struct device *dev) | 70 | static inline bool has_acpi_companion(struct device *dev) |
71 | { | 71 | { |
72 | return is_acpi_node(dev->fwnode); | 72 | return is_acpi_device_node(dev->fwnode); |
73 | } | 73 | } |
74 | 74 | ||
75 | static inline void acpi_preset_companion(struct device *dev, | 75 | static inline void acpi_preset_companion(struct device *dev, |
@@ -461,7 +461,22 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode) | |||
461 | return false; | 461 | return false; |
462 | } | 462 | } |
463 | 463 | ||
464 | static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode) | 464 | static inline bool is_acpi_device_node(struct fwnode_handle *fwnode) |
465 | { | ||
466 | return false; | ||
467 | } | ||
468 | |||
469 | static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode) | ||
470 | { | ||
471 | return NULL; | ||
472 | } | ||
473 | |||
474 | static inline bool is_acpi_data_node(struct fwnode_handle *fwnode) | ||
475 | { | ||
476 | return false; | ||
477 | } | ||
478 | |||
479 | static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode) | ||
465 | { | 480 | { |
466 | return NULL; | 481 | return NULL; |
467 | } | 482 | } |
@@ -743,17 +758,16 @@ struct acpi_reference_args { | |||
743 | #ifdef CONFIG_ACPI | 758 | #ifdef CONFIG_ACPI |
744 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, | 759 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, |
745 | acpi_object_type type, const union acpi_object **obj); | 760 | acpi_object_type type, const union acpi_object **obj); |
746 | int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, | ||
747 | acpi_object_type type, | ||
748 | const union acpi_object **obj); | ||
749 | int acpi_dev_get_property_reference(struct acpi_device *adev, | 761 | int acpi_dev_get_property_reference(struct acpi_device *adev, |
750 | const char *name, size_t index, | 762 | const char *name, size_t index, |
751 | struct acpi_reference_args *args); | 763 | struct acpi_reference_args *args); |
752 | 764 | ||
753 | int acpi_dev_prop_get(struct acpi_device *adev, const char *propname, | 765 | int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname, |
754 | void **valptr); | 766 | void **valptr); |
755 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | 767 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, |
756 | enum dev_prop_type proptype, void *val); | 768 | enum dev_prop_type proptype, void *val); |
769 | int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname, | ||
770 | enum dev_prop_type proptype, void *val, size_t nval); | ||
757 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, | 771 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, |
758 | enum dev_prop_type proptype, void *val, size_t nval); | 772 | enum dev_prop_type proptype, void *val, size_t nval); |
759 | 773 | ||
@@ -766,13 +780,7 @@ static inline int acpi_dev_get_property(struct acpi_device *adev, | |||
766 | { | 780 | { |
767 | return -ENXIO; | 781 | return -ENXIO; |
768 | } | 782 | } |
769 | static inline int acpi_dev_get_property_array(struct acpi_device *adev, | 783 | |
770 | const char *name, | ||
771 | acpi_object_type type, | ||
772 | const union acpi_object **obj) | ||
773 | { | ||
774 | return -ENXIO; | ||
775 | } | ||
776 | static inline int acpi_dev_get_property_reference(struct acpi_device *adev, | 784 | static inline int acpi_dev_get_property_reference(struct acpi_device *adev, |
777 | const char *name, const char *cells_name, | 785 | const char *name, const char *cells_name, |
778 | size_t index, struct acpi_reference_args *args) | 786 | size_t index, struct acpi_reference_args *args) |
@@ -780,6 +788,13 @@ static inline int acpi_dev_get_property_reference(struct acpi_device *adev, | |||
780 | return -ENXIO; | 788 | return -ENXIO; |
781 | } | 789 | } |
782 | 790 | ||
791 | static inline int acpi_node_prop_get(struct fwnode_handle *fwnode, | ||
792 | const char *propname, | ||
793 | void **valptr) | ||
794 | { | ||
795 | return -ENXIO; | ||
796 | } | ||
797 | |||
783 | static inline int acpi_dev_prop_get(struct acpi_device *adev, | 798 | static inline int acpi_dev_prop_get(struct acpi_device *adev, |
784 | const char *propname, | 799 | const char *propname, |
785 | void **valptr) | 800 | void **valptr) |
@@ -795,6 +810,14 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev, | |||
795 | return -ENXIO; | 810 | return -ENXIO; |
796 | } | 811 | } |
797 | 812 | ||
813 | static inline int acpi_node_prop_read(struct fwnode_handle *fwnode, | ||
814 | const char *propname, | ||
815 | enum dev_prop_type proptype, | ||
816 | void *val, size_t nval) | ||
817 | { | ||
818 | return -ENXIO; | ||
819 | } | ||
820 | |||
798 | static inline int acpi_dev_prop_read(struct acpi_device *adev, | 821 | static inline int acpi_dev_prop_read(struct acpi_device *adev, |
799 | const char *propname, | 822 | const char *propname, |
800 | enum dev_prop_type proptype, | 823 | enum dev_prop_type proptype, |