Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'devprop-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull device properties framework updates from Rafael Wysocki:
"These mostly extend the device property API and make it easier to use
in some cases.

Specifics:

- Allow error pointer to be passed to fwnode APIs (Andy Shevchenko).

- Introduce fwnode_for_each_parent_node() (Andy Shevchenko, Douglas
Anderson).

- Advertise fwnode and device property count API calls (Andy
Shevchenko).

- Clean up fwnode_is_ancestor_of() (Andy Shevchenko).

- Convert device_{dma_supported,get_dma_attr} to fwnode (Sakari
Ailus).

- Release subnode properties with data nodes (Sakari Ailus).

- Add ->iomap() and ->irq_get() to fwnode operations (Sakari Ailus)"

* tag 'devprop-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
device property: Advertise fwnode and device property count API calls
device property: Fix recent breakage of fwnode_get_next_parent_dev()
device property: Drop 'test' prefix in parameters of fwnode_is_ancestor_of()
device property: Introduce fwnode_for_each_parent_node()
device property: Allow error pointer to be passed to fwnode APIs
ACPI: property: Release subnode properties with data nodes
device property: Add irq_get to fwnode operation
device property: Add iomap to fwnode operations
ACPI: property: Move acpi_fwnode_device_get_match_data() up
device property: Convert device_{dma_supported,get_dma_attr} to fwnode

+211 -121
+44 -10
drivers/acpi/property.c
··· 433 433 acpi_extract_apple_properties(adev); 434 434 } 435 435 436 + static void acpi_free_device_properties(struct list_head *list) 437 + { 438 + struct acpi_device_properties *props, *tmp; 439 + 440 + list_for_each_entry_safe(props, tmp, list, list) { 441 + list_del(&props->list); 442 + kfree(props); 443 + } 444 + } 445 + 436 446 static void acpi_destroy_nondev_subnodes(struct list_head *list) 437 447 { 438 448 struct acpi_data_node *dn, *next; ··· 455 445 wait_for_completion(&dn->kobj_done); 456 446 list_del(&dn->sibling); 457 447 ACPI_FREE((void *)dn->data.pointer); 448 + acpi_free_device_properties(&dn->data.properties); 458 449 kfree(dn); 459 450 } 460 451 } 461 452 462 453 void acpi_free_properties(struct acpi_device *adev) 463 454 { 464 - struct acpi_device_properties *props, *tmp; 465 - 466 455 acpi_destroy_nondev_subnodes(&adev->data.subnodes); 467 456 ACPI_FREE((void *)adev->data.pointer); 468 457 adev->data.of_compatible = NULL; 469 458 adev->data.pointer = NULL; 470 - list_for_each_entry_safe(props, tmp, &adev->data.properties, list) { 471 - list_del(&props->list); 472 - kfree(props); 473 - } 459 + acpi_free_device_properties(&adev->data.properties); 474 460 } 475 461 476 462 /** ··· 1262 1256 return acpi_device_is_present(to_acpi_device_node(fwnode)); 1263 1257 } 1264 1258 1259 + static const void * 1260 + acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, 1261 + const struct device *dev) 1262 + { 1263 + return acpi_device_get_match_data(dev); 1264 + } 1265 + 1266 + static bool acpi_fwnode_device_dma_supported(const struct fwnode_handle *fwnode) 1267 + { 1268 + return acpi_dma_supported(to_acpi_device_node(fwnode)); 1269 + } 1270 + 1271 + static enum dev_dma_attr 1272 + acpi_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode) 1273 + { 1274 + return acpi_get_dma_attr(to_acpi_device_node(fwnode)); 1275 + } 1276 + 1265 1277 static bool acpi_fwnode_property_present(const struct fwnode_handle *fwnode, 1266 1278 const char *propname) 1267 1279 { ··· 1400 1376 return 0; 1401 1377 } 1402 1378 1403 - static const void * 1404 - acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, 1405 - const struct device *dev) 1379 + static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, 1380 + unsigned int index) 1406 1381 { 1407 - return acpi_device_get_match_data(dev); 1382 + struct resource res; 1383 + int ret; 1384 + 1385 + ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res); 1386 + if (ret) 1387 + return ret; 1388 + 1389 + return res.start; 1408 1390 } 1409 1391 1410 1392 #define DECLARE_ACPI_FWNODE_OPS(ops) \ 1411 1393 const struct fwnode_operations ops = { \ 1412 1394 .device_is_available = acpi_fwnode_device_is_available, \ 1413 1395 .device_get_match_data = acpi_fwnode_device_get_match_data, \ 1396 + .device_dma_supported = \ 1397 + acpi_fwnode_device_dma_supported, \ 1398 + .device_get_dma_attr = acpi_fwnode_device_get_dma_attr, \ 1414 1399 .property_present = acpi_fwnode_property_present, \ 1415 1400 .property_read_int_array = \ 1416 1401 acpi_fwnode_property_read_int_array, \ ··· 1437 1404 acpi_graph_get_remote_endpoint, \ 1438 1405 .graph_get_port_parent = acpi_fwnode_get_parent, \ 1439 1406 .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ 1407 + .irq_get = acpi_fwnode_irq_get, \ 1440 1408 }; \ 1441 1409 EXPORT_SYMBOL_GPL(ops) 1442 1410
+115 -102
drivers/base/property.c
··· 47 47 { 48 48 bool ret; 49 49 50 + if (IS_ERR_OR_NULL(fwnode)) 51 + return false; 52 + 50 53 ret = fwnode_call_bool_op(fwnode, property_present, propname); 51 - if (ret == false && !IS_ERR_OR_NULL(fwnode) && 52 - !IS_ERR_OR_NULL(fwnode->secondary)) 53 - ret = fwnode_call_bool_op(fwnode->secondary, property_present, 54 - propname); 55 - return ret; 54 + if (ret) 55 + return ret; 56 + 57 + return fwnode_call_bool_op(fwnode->secondary, property_present, propname); 56 58 } 57 59 EXPORT_SYMBOL_GPL(fwnode_property_present); 58 60 ··· 67 65 * 68 66 * Function reads an array of u8 properties with @propname from the device 69 67 * firmware description and stores them to @val if found. 68 + * 69 + * It's recommended to call device_property_count_u8() instead of calling 70 + * this function with @val equals %NULL and @nval equals 0. 70 71 * 71 72 * Return: number of values if @val was %NULL, 72 73 * %0 if the property was found (success), ··· 96 91 * Function reads an array of u16 properties with @propname from the device 97 92 * firmware description and stores them to @val if found. 98 93 * 94 + * It's recommended to call device_property_count_u16() instead of calling 95 + * this function with @val equals %NULL and @nval equals 0. 96 + * 99 97 * Return: number of values if @val was %NULL, 100 98 * %0 if the property was found (success), 101 99 * %-EINVAL if given arguments are not valid, ··· 123 115 * 124 116 * Function reads an array of u32 properties with @propname from the device 125 117 * firmware description and stores them to @val if found. 118 + * 119 + * It's recommended to call device_property_count_u32() instead of calling 120 + * this function with @val equals %NULL and @nval equals 0. 126 121 * 127 122 * Return: number of values if @val was %NULL, 128 123 * %0 if the property was found (success), ··· 152 141 * Function reads an array of u64 properties with @propname from the device 153 142 * firmware description and stores them to @val if found. 154 143 * 144 + * It's recommended to call device_property_count_u64() instead of calling 145 + * this function with @val equals %NULL and @nval equals 0. 146 + * 155 147 * Return: number of values if @val was %NULL, 156 148 * %0 if the property was found (success), 157 149 * %-EINVAL if given arguments are not valid, ··· 179 165 * 180 166 * Function reads an array of string properties with @propname from the device 181 167 * firmware description and stores them to @val if found. 168 + * 169 + * It's recommended to call device_property_string_array_count() instead of calling 170 + * this function with @val equals %NULL and @nval equals 0. 182 171 * 183 172 * Return: number of values read on success if @val is non-NULL, 184 173 * number of values available on success if @val is NULL, ··· 249 232 { 250 233 int ret; 251 234 235 + if (IS_ERR_OR_NULL(fwnode)) 236 + return -EINVAL; 237 + 252 238 ret = fwnode_call_int_op(fwnode, property_read_int_array, propname, 253 239 elem_size, val, nval); 254 - if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) && 255 - !IS_ERR_OR_NULL(fwnode->secondary)) 256 - ret = fwnode_call_int_op( 257 - fwnode->secondary, property_read_int_array, propname, 258 - elem_size, val, nval); 240 + if (ret != -EINVAL) 241 + return ret; 259 242 260 - return ret; 243 + return fwnode_call_int_op(fwnode->secondary, property_read_int_array, propname, 244 + elem_size, val, nval); 261 245 } 262 246 263 247 /** ··· 270 252 * 271 253 * Read an array of u8 properties with @propname from @fwnode and stores them to 272 254 * @val if found. 255 + * 256 + * It's recommended to call fwnode_property_count_u8() instead of calling 257 + * this function with @val equals %NULL and @nval equals 0. 273 258 * 274 259 * Return: number of values if @val was %NULL, 275 260 * %0 if the property was found (success), ··· 300 279 * Read an array of u16 properties with @propname from @fwnode and store them to 301 280 * @val if found. 302 281 * 282 + * It's recommended to call fwnode_property_count_u16() instead of calling 283 + * this function with @val equals %NULL and @nval equals 0. 284 + * 303 285 * Return: number of values if @val was %NULL, 304 286 * %0 if the property was found (success), 305 287 * %-EINVAL if given arguments are not valid, ··· 328 304 * 329 305 * Read an array of u32 properties with @propname from @fwnode store them to 330 306 * @val if found. 307 + * 308 + * It's recommended to call fwnode_property_count_u32() instead of calling 309 + * this function with @val equals %NULL and @nval equals 0. 331 310 * 332 311 * Return: number of values if @val was %NULL, 333 312 * %0 if the property was found (success), ··· 358 331 * Read an array of u64 properties with @propname from @fwnode and store them to 359 332 * @val if found. 360 333 * 334 + * It's recommended to call fwnode_property_count_u64() instead of calling 335 + * this function with @val equals %NULL and @nval equals 0. 336 + * 361 337 * Return: number of values if @val was %NULL, 362 338 * %0 if the property was found (success), 363 339 * %-EINVAL if given arguments are not valid, ··· 387 357 * Read an string list property @propname from the given firmware node and store 388 358 * them to @val if found. 389 359 * 360 + * It's recommended to call fwnode_property_string_array_count() instead of calling 361 + * this function with @val equals %NULL and @nval equals 0. 362 + * 390 363 * Return: number of values read on success if @val is non-NULL, 391 364 * number of values available on success if @val is NULL, 392 365 * %-EINVAL if given arguments are not valid, ··· 404 371 { 405 372 int ret; 406 373 374 + if (IS_ERR_OR_NULL(fwnode)) 375 + return -EINVAL; 376 + 407 377 ret = fwnode_call_int_op(fwnode, property_read_string_array, propname, 408 378 val, nval); 409 - if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) && 410 - !IS_ERR_OR_NULL(fwnode->secondary)) 411 - ret = fwnode_call_int_op(fwnode->secondary, 412 - property_read_string_array, propname, 413 - val, nval); 414 - return ret; 379 + if (ret != -EINVAL) 380 + return ret; 381 + 382 + return fwnode_call_int_op(fwnode->secondary, property_read_string_array, propname, 383 + val, nval); 415 384 } 416 385 EXPORT_SYMBOL_GPL(fwnode_property_read_string_array); 417 386 ··· 515 480 { 516 481 int ret; 517 482 483 + if (IS_ERR_OR_NULL(fwnode)) 484 + return -ENOENT; 485 + 518 486 ret = fwnode_call_int_op(fwnode, get_reference_args, prop, nargs_prop, 519 487 nargs, index, args); 488 + if (ret == 0) 489 + return ret; 520 490 521 - if (ret < 0 && !IS_ERR_OR_NULL(fwnode) && 522 - !IS_ERR_OR_NULL(fwnode->secondary)) 523 - ret = fwnode_call_int_op(fwnode->secondary, get_reference_args, 524 - prop, nargs_prop, nargs, index, args); 491 + if (IS_ERR_OR_NULL(fwnode->secondary)) 492 + return ret; 525 493 526 - return ret; 494 + return fwnode_call_int_op(fwnode->secondary, get_reference_args, prop, nargs_prop, 495 + nargs, index, args); 527 496 } 528 497 EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args); 529 498 ··· 626 587 */ 627 588 struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode) 628 589 { 590 + struct fwnode_handle *parent; 629 591 struct device *dev; 630 592 631 - fwnode_handle_get(fwnode); 632 - do { 633 - fwnode = fwnode_get_next_parent(fwnode); 634 - if (!fwnode) 635 - return NULL; 636 - dev = get_dev_from_fwnode(fwnode); 637 - } while (!dev); 638 - fwnode_handle_put(fwnode); 639 - return dev; 593 + fwnode_for_each_parent_node(fwnode, parent) { 594 + dev = get_dev_from_fwnode(parent); 595 + if (dev) { 596 + fwnode_handle_put(parent); 597 + return dev; 598 + } 599 + } 600 + return NULL; 640 601 } 641 602 642 603 /** ··· 647 608 */ 648 609 unsigned int fwnode_count_parents(const struct fwnode_handle *fwnode) 649 610 { 650 - struct fwnode_handle *__fwnode; 651 - unsigned int count; 611 + struct fwnode_handle *parent; 612 + unsigned int count = 0; 652 613 653 - __fwnode = fwnode_get_parent(fwnode); 654 - 655 - for (count = 0; __fwnode; count++) 656 - __fwnode = fwnode_get_next_parent(__fwnode); 614 + fwnode_for_each_parent_node(fwnode, parent) 615 + count++; 657 616 658 617 return count; 659 618 } ··· 672 635 struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwnode, 673 636 unsigned int depth) 674 637 { 675 - unsigned int i; 638 + struct fwnode_handle *parent; 676 639 677 - fwnode_handle_get(fwnode); 640 + if (depth == 0) 641 + return fwnode_handle_get(fwnode); 678 642 679 - for (i = 0; i < depth && fwnode; i++) 680 - fwnode = fwnode_get_next_parent(fwnode); 681 - 682 - return fwnode; 643 + fwnode_for_each_parent_node(fwnode, parent) { 644 + if (--depth == 0) 645 + return parent; 646 + } 647 + return NULL; 683 648 } 684 649 EXPORT_SYMBOL_GPL(fwnode_get_nth_parent); 685 650 686 651 /** 687 - * fwnode_is_ancestor_of - Test if @test_ancestor is ancestor of @test_child 688 - * @test_ancestor: Firmware which is tested for being an ancestor 689 - * @test_child: Firmware which is tested for being the child 652 + * fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child 653 + * @ancestor: Firmware which is tested for being an ancestor 654 + * @child: Firmware which is tested for being the child 690 655 * 691 656 * A node is considered an ancestor of itself too. 692 657 * 693 - * Returns true if @test_ancestor is an ancestor of @test_child. 694 - * Otherwise, returns false. 658 + * Returns true if @ancestor is an ancestor of @child. Otherwise, returns false. 695 659 */ 696 - bool fwnode_is_ancestor_of(struct fwnode_handle *test_ancestor, 697 - struct fwnode_handle *test_child) 660 + bool fwnode_is_ancestor_of(struct fwnode_handle *ancestor, struct fwnode_handle *child) 698 661 { 699 - if (!test_ancestor) 662 + struct fwnode_handle *parent; 663 + 664 + if (IS_ERR_OR_NULL(ancestor)) 700 665 return false; 701 666 702 - fwnode_handle_get(test_child); 703 - while (test_child) { 704 - if (test_child == test_ancestor) { 705 - fwnode_handle_put(test_child); 667 + if (child == ancestor) 668 + return true; 669 + 670 + fwnode_for_each_parent_node(child, parent) { 671 + if (parent == ancestor) { 672 + fwnode_handle_put(parent); 706 673 return true; 707 674 } 708 - test_child = fwnode_get_next_parent(test_child); 709 675 } 710 676 return false; 711 677 } ··· 738 698 { 739 699 struct fwnode_handle *next_child = child; 740 700 741 - if (!fwnode) 701 + if (IS_ERR_OR_NULL(fwnode)) 742 702 return NULL; 743 703 744 704 do { ··· 762 722 const struct fwnode_handle *fwnode = dev_fwnode(dev); 763 723 struct fwnode_handle *next; 764 724 725 + if (IS_ERR_OR_NULL(fwnode)) 726 + return NULL; 727 + 765 728 /* Try to find a child in primary fwnode */ 766 729 next = fwnode_get_next_child_node(fwnode, child); 767 730 if (next) 768 731 return next; 769 732 770 733 /* When no more children in primary, continue with secondary */ 771 - if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) 772 - next = fwnode_get_next_child_node(fwnode->secondary, child); 773 - 774 - return next; 734 + return fwnode_get_next_child_node(fwnode->secondary, child); 775 735 } 776 736 EXPORT_SYMBOL_GPL(device_get_next_child_node); 777 737 ··· 838 798 */ 839 799 bool fwnode_device_is_available(const struct fwnode_handle *fwnode) 840 800 { 801 + if (IS_ERR_OR_NULL(fwnode)) 802 + return false; 803 + 841 804 if (!fwnode_has_op(fwnode, device_is_available)) 842 805 return true; 843 806 ··· 866 823 867 824 bool device_dma_supported(struct device *dev) 868 825 { 869 - const struct fwnode_handle *fwnode = dev_fwnode(dev); 870 - 871 - /* For DT, this is always supported. 872 - * For ACPI, this depends on CCA, which 873 - * is determined by the acpi_dma_supported(). 874 - */ 875 - if (is_of_node(fwnode)) 876 - return true; 877 - 878 - return acpi_dma_supported(to_acpi_device_node(fwnode)); 826 + return fwnode_call_bool_op(dev_fwnode(dev), device_dma_supported); 879 827 } 880 828 EXPORT_SYMBOL_GPL(device_dma_supported); 881 829 882 830 enum dev_dma_attr device_get_dma_attr(struct device *dev) 883 831 { 884 - const struct fwnode_handle *fwnode = dev_fwnode(dev); 885 - enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED; 832 + if (!fwnode_has_op(dev_fwnode(dev), device_get_dma_attr)) 833 + return DEV_DMA_NOT_SUPPORTED; 886 834 887 - if (is_of_node(fwnode)) { 888 - if (of_dma_is_coherent(to_of_node(fwnode))) 889 - attr = DEV_DMA_COHERENT; 890 - else 891 - attr = DEV_DMA_NON_COHERENT; 892 - } else 893 - attr = acpi_get_dma_attr(to_acpi_device_node(fwnode)); 894 - 895 - return attr; 835 + return fwnode_call_int_op(dev_fwnode(dev), device_get_dma_attr); 896 836 } 897 837 EXPORT_SYMBOL_GPL(device_get_dma_attr); 898 838 ··· 930 904 */ 931 905 void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index) 932 906 { 933 - if (IS_ENABLED(CONFIG_OF_ADDRESS) && is_of_node(fwnode)) 934 - return of_iomap(to_of_node(fwnode), index); 935 - 936 - return NULL; 907 + return fwnode_call_ptr_op(fwnode, iomap, index); 937 908 } 938 909 EXPORT_SYMBOL(fwnode_iomap); 939 910 ··· 944 921 */ 945 922 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) 946 923 { 947 - struct resource res; 948 - int ret; 949 - 950 - if (is_of_node(fwnode)) 951 - return of_irq_get(to_of_node(fwnode), index); 952 - 953 - ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res); 954 - if (ret) 955 - return ret; 956 - 957 - return res.start; 924 + return fwnode_call_int_op(fwnode, irq_get, index); 958 925 } 959 926 EXPORT_SYMBOL(fwnode_irq_get); 960 927 ··· 1001 988 parent = fwnode_graph_get_port_parent(prev); 1002 989 else 1003 990 parent = fwnode; 991 + if (IS_ERR_OR_NULL(parent)) 992 + return NULL; 1004 993 1005 994 ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev); 995 + if (ep) 996 + return ep; 1006 997 1007 - if (IS_ERR_OR_NULL(ep) && 1008 - !IS_ERR_OR_NULL(parent) && !IS_ERR_OR_NULL(parent->secondary)) 1009 - ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL); 1010 - 1011 - return ep; 998 + return fwnode_graph_get_next_endpoint(parent->secondary, NULL); 1012 999 } 1013 1000 EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint); 1014 1001
+34
drivers/of/property.c
··· 22 22 #define pr_fmt(fmt) "OF: " fmt 23 23 24 24 #include <linux/of.h> 25 + #include <linux/of_address.h> 25 26 #include <linux/of_device.h> 26 27 #include <linux/of_graph.h> 27 28 #include <linux/of_irq.h> ··· 873 872 return of_device_is_available(to_of_node(fwnode)); 874 873 } 875 874 875 + static bool of_fwnode_device_dma_supported(const struct fwnode_handle *fwnode) 876 + { 877 + return true; 878 + } 879 + 880 + static enum dev_dma_attr 881 + of_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode) 882 + { 883 + if (of_dma_is_coherent(to_of_node(fwnode))) 884 + return DEV_DMA_COHERENT; 885 + else 886 + return DEV_DMA_NON_COHERENT; 887 + } 888 + 876 889 static bool of_fwnode_property_present(const struct fwnode_handle *fwnode, 877 890 const char *propname) 878 891 { ··· 1465 1450 return 0; 1466 1451 } 1467 1452 1453 + static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index) 1454 + { 1455 + #ifdef CONFIG_OF_ADDRESS 1456 + return of_iomap(to_of_node(fwnode), index); 1457 + #else 1458 + return NULL; 1459 + #endif 1460 + } 1461 + 1462 + static int of_fwnode_irq_get(const struct fwnode_handle *fwnode, 1463 + unsigned int index) 1464 + { 1465 + return of_irq_get(to_of_node(fwnode), index); 1466 + } 1467 + 1468 1468 static int of_fwnode_add_links(struct fwnode_handle *fwnode) 1469 1469 { 1470 1470 struct property *p; ··· 1502 1472 .put = of_fwnode_put, 1503 1473 .device_is_available = of_fwnode_device_is_available, 1504 1474 .device_get_match_data = of_fwnode_device_get_match_data, 1475 + .device_dma_supported = of_fwnode_device_dma_supported, 1476 + .device_get_dma_attr = of_fwnode_device_get_dma_attr, 1505 1477 .property_present = of_fwnode_property_present, 1506 1478 .property_read_int_array = of_fwnode_property_read_int_array, 1507 1479 .property_read_string_array = of_fwnode_property_read_string_array, ··· 1517 1485 .graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint, 1518 1486 .graph_get_port_parent = of_fwnode_graph_get_port_parent, 1519 1487 .graph_parse_endpoint = of_fwnode_graph_parse_endpoint, 1488 + .iomap = of_fwnode_iomap, 1489 + .irq_get = of_fwnode_irq_get, 1520 1490 .add_links = of_fwnode_add_links, 1521 1491 }; 1522 1492 EXPORT_SYMBOL_GPL(of_fwnode_ops);
+10 -5
include/linux/fwnode.h
··· 113 113 bool (*device_is_available)(const struct fwnode_handle *fwnode); 114 114 const void *(*device_get_match_data)(const struct fwnode_handle *fwnode, 115 115 const struct device *dev); 116 + bool (*device_dma_supported)(const struct fwnode_handle *fwnode); 117 + enum dev_dma_attr 118 + (*device_get_dma_attr)(const struct fwnode_handle *fwnode); 116 119 bool (*property_present)(const struct fwnode_handle *fwnode, 117 120 const char *propname); 118 121 int (*property_read_int_array)(const struct fwnode_handle *fwnode, ··· 148 145 (*graph_get_port_parent)(struct fwnode_handle *fwnode); 149 146 int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode, 150 147 struct fwnode_endpoint *endpoint); 148 + void __iomem *(*iomap)(struct fwnode_handle *fwnode, int index); 149 + int (*irq_get)(const struct fwnode_handle *fwnode, unsigned int index); 151 150 int (*add_links)(struct fwnode_handle *fwnode); 152 151 }; 153 152 154 - #define fwnode_has_op(fwnode, op) \ 155 - ((fwnode) && (fwnode)->ops && (fwnode)->ops->op) 153 + #define fwnode_has_op(fwnode, op) \ 154 + (!IS_ERR_OR_NULL(fwnode) && (fwnode)->ops && (fwnode)->ops->op) 155 + 156 156 #define fwnode_call_int_op(fwnode, op, ...) \ 157 - (fwnode ? (fwnode_has_op(fwnode, op) ? \ 158 - (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \ 159 - -EINVAL) 157 + (fwnode_has_op(fwnode, op) ? \ 158 + (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : (IS_ERR_OR_NULL(fwnode) ? -EINVAL : -ENXIO)) 160 159 161 160 #define fwnode_call_bool_op(fwnode, op, ...) \ 162 161 (fwnode_has_op(fwnode, op) ? \
+8 -4
include/linux/property.h
··· 83 83 84 84 const char *fwnode_get_name(const struct fwnode_handle *fwnode); 85 85 const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode); 86 + 86 87 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); 87 - struct fwnode_handle *fwnode_get_next_parent( 88 - struct fwnode_handle *fwnode); 88 + struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode); 89 + 90 + #define fwnode_for_each_parent_node(fwnode, parent) \ 91 + for (parent = fwnode_get_parent(fwnode); parent; \ 92 + parent = fwnode_get_next_parent(parent)) 93 + 89 94 struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode); 90 95 unsigned int fwnode_count_parents(const struct fwnode_handle *fwn); 91 96 struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn, 92 97 unsigned int depth); 93 - bool fwnode_is_ancestor_of(struct fwnode_handle *test_ancestor, 94 - struct fwnode_handle *test_child); 98 + bool fwnode_is_ancestor_of(struct fwnode_handle *ancestor, struct fwnode_handle *child); 95 99 struct fwnode_handle *fwnode_get_next_child_node( 96 100 const struct fwnode_handle *fwnode, struct fwnode_handle *child); 97 101 struct fwnode_handle *fwnode_get_next_available_child_node(