|
21 | 21 | struct fwnode_handle *dev_fwnode(struct device *dev) |
22 | 22 | { |
23 | 23 | return IS_ENABLED(CONFIG_OF) && dev->of_node ? |
24 | | - &dev->of_node->fwnode : dev->fwnode; |
| 24 | + of_fwnode_handle(dev->of_node) : dev->fwnode; |
25 | 25 | } |
26 | 26 | EXPORT_SYMBOL_GPL(dev_fwnode); |
27 | 27 |
|
@@ -759,13 +759,8 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node); |
759 | 759 | struct fwnode_handle *device_get_next_child_node(struct device *dev, |
760 | 760 | struct fwnode_handle *child) |
761 | 761 | { |
762 | | - struct acpi_device *adev = ACPI_COMPANION(dev); |
763 | | - struct fwnode_handle *fwnode = NULL, *next; |
764 | | - |
765 | | - if (dev->of_node) |
766 | | - fwnode = &dev->of_node->fwnode; |
767 | | - else if (adev) |
768 | | - fwnode = acpi_fwnode_handle(adev); |
| 762 | + const struct fwnode_handle *fwnode = dev_fwnode(dev); |
| 763 | + struct fwnode_handle *next; |
769 | 764 |
|
770 | 765 | /* Try to find a child in primary fwnode */ |
771 | 766 | next = fwnode_get_next_child_node(fwnode, child); |
@@ -868,28 +863,31 @@ EXPORT_SYMBOL_GPL(device_get_child_node_count); |
868 | 863 |
|
869 | 864 | bool device_dma_supported(struct device *dev) |
870 | 865 | { |
| 866 | + const struct fwnode_handle *fwnode = dev_fwnode(dev); |
| 867 | + |
871 | 868 | /* For DT, this is always supported. |
872 | 869 | * For ACPI, this depends on CCA, which |
873 | 870 | * is determined by the acpi_dma_supported(). |
874 | 871 | */ |
875 | | - if (IS_ENABLED(CONFIG_OF) && dev->of_node) |
| 872 | + if (is_of_node(fwnode)) |
876 | 873 | return true; |
877 | 874 |
|
878 | | - return acpi_dma_supported(ACPI_COMPANION(dev)); |
| 875 | + return acpi_dma_supported(to_acpi_device_node(fwnode)); |
879 | 876 | } |
880 | 877 | EXPORT_SYMBOL_GPL(device_dma_supported); |
881 | 878 |
|
882 | 879 | enum dev_dma_attr device_get_dma_attr(struct device *dev) |
883 | 880 | { |
| 881 | + const struct fwnode_handle *fwnode = dev_fwnode(dev); |
884 | 882 | enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED; |
885 | 883 |
|
886 | | - if (IS_ENABLED(CONFIG_OF) && dev->of_node) { |
887 | | - if (of_dma_is_coherent(dev->of_node)) |
| 884 | + if (is_of_node(fwnode)) { |
| 885 | + if (of_dma_is_coherent(to_of_node(fwnode))) |
888 | 886 | attr = DEV_DMA_COHERENT; |
889 | 887 | else |
890 | 888 | attr = DEV_DMA_NON_COHERENT; |
891 | 889 | } else |
892 | | - attr = acpi_get_dma_attr(ACPI_COMPANION(dev)); |
| 890 | + attr = acpi_get_dma_attr(to_acpi_device_node(fwnode)); |
893 | 891 |
|
894 | 892 | return attr; |
895 | 893 | } |
@@ -1007,14 +1005,13 @@ EXPORT_SYMBOL(device_get_mac_address); |
1007 | 1005 | * Returns Linux IRQ number on success. Other values are determined |
1008 | 1006 | * accordingly to acpi_/of_ irq_get() operation. |
1009 | 1007 | */ |
1010 | | -int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index) |
| 1008 | +int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) |
1011 | 1009 | { |
1012 | | - struct device_node *of_node = to_of_node(fwnode); |
1013 | 1010 | struct resource res; |
1014 | 1011 | int ret; |
1015 | 1012 |
|
1016 | | - if (IS_ENABLED(CONFIG_OF) && of_node) |
1017 | | - return of_irq_get(of_node, index); |
| 1013 | + if (is_of_node(fwnode)) |
| 1014 | + return of_irq_get(to_of_node(fwnode), index); |
1018 | 1015 |
|
1019 | 1016 | ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res); |
1020 | 1017 | if (ret) |
|
0 commit comments