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

of: Move of_dma_set_restricted_buffer() into device.c

Rob observes that:

| of_dma_set_restricted_buffer() [...] should also be moved to
| of/device.c. There's no reason for it to be in of/address.c. It has
| nothing to do with address parsing.

Move it to of/device.c, as he suggests.

Cc: Claire Chang <tientzu@chromium.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Robin Murphy <robin.murphy@arm.com>
Suggested-by: Rob Herring <robh+dt@kernel.org>
Link: https://lore.kernel.org/r/CAL_JsqJ7ROWWJX84x2kEex9NQ8G+2=ybRuNOobX+j8bjZzSemQ@mail.gmail.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

authored by

Will Deacon and committed by
Konrad Rzeszutek Wilk
ce5cb67c a449ffaf

+34 -40
-33
drivers/of/address.c
··· 8 8 #include <linux/logic_pio.h> 9 9 #include <linux/module.h> 10 10 #include <linux/of_address.h> 11 - #include <linux/of_reserved_mem.h> 12 11 #include <linux/pci.h> 13 12 #include <linux/pci_regs.h> 14 13 #include <linux/sizes.h> ··· 994 995 out: 995 996 of_node_put(node); 996 997 return ret; 997 - } 998 - 999 - int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) 1000 - { 1001 - struct device_node *node, *of_node = dev->of_node; 1002 - int count, i; 1003 - 1004 - count = of_property_count_elems_of_size(of_node, "memory-region", 1005 - sizeof(u32)); 1006 - /* 1007 - * If dev->of_node doesn't exist or doesn't contain memory-region, try 1008 - * the OF node having DMA configuration. 1009 - */ 1010 - if (count <= 0) { 1011 - of_node = np; 1012 - count = of_property_count_elems_of_size( 1013 - of_node, "memory-region", sizeof(u32)); 1014 - } 1015 - 1016 - for (i = 0; i < count; i++) { 1017 - node = of_parse_phandle(of_node, "memory-region", i); 1018 - /* 1019 - * There might be multiple memory regions, but only one 1020 - * restricted-dma-pool region is allowed. 1021 - */ 1022 - if (of_device_is_compatible(node, "restricted-dma-pool") && 1023 - of_device_is_available(node)) 1024 - return of_reserved_mem_device_init_by_idx(dev, of_node, 1025 - i); 1026 - } 1027 - 1028 - return 0; 1029 998 } 1030 999 #endif /* CONFIG_HAS_DMA */ 1031 1000
+34
drivers/of/device.c
··· 5 5 #include <linux/of_device.h> 6 6 #include <linux/of_address.h> 7 7 #include <linux/of_iommu.h> 8 + #include <linux/of_reserved_mem.h> 8 9 #include <linux/dma-direct.h> /* for bus_dma_region */ 9 10 #include <linux/dma-map-ops.h> 10 11 #include <linux/init.h> ··· 51 50 set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); 52 51 53 52 return device_add(&ofdev->dev); 53 + } 54 + 55 + static int 56 + of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) 57 + { 58 + struct device_node *node, *of_node = dev->of_node; 59 + int count, i; 60 + 61 + count = of_property_count_elems_of_size(of_node, "memory-region", 62 + sizeof(u32)); 63 + /* 64 + * If dev->of_node doesn't exist or doesn't contain memory-region, try 65 + * the OF node having DMA configuration. 66 + */ 67 + if (count <= 0) { 68 + of_node = np; 69 + count = of_property_count_elems_of_size( 70 + of_node, "memory-region", sizeof(u32)); 71 + } 72 + 73 + for (i = 0; i < count; i++) { 74 + node = of_parse_phandle(of_node, "memory-region", i); 75 + /* 76 + * There might be multiple memory regions, but only one 77 + * restricted-dma-pool region is allowed. 78 + */ 79 + if (of_device_is_compatible(node, "restricted-dma-pool") && 80 + of_device_is_available(node)) 81 + return of_reserved_mem_device_init_by_idx(dev, of_node, 82 + i); 83 + } 84 + 85 + return 0; 54 86 } 55 87 56 88 /**
-7
drivers/of/of_private.h
··· 163 163 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_HAS_DMA) 164 164 int of_dma_get_range(struct device_node *np, 165 165 const struct bus_dma_region **map); 166 - int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np); 167 166 #else 168 167 static inline int of_dma_get_range(struct device_node *np, 169 168 const struct bus_dma_region **map) 170 169 { 171 170 return -ENODEV; 172 - } 173 - static inline int of_dma_set_restricted_buffer(struct device *dev, 174 - struct device_node *np) 175 - { 176 - /* Do nothing, successfully. */ 177 - return 0; 178 171 } 179 172 #endif 180 173