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>
This commit is contained in:
Родитель
a449ffaf91
Коммит
ce5cb67c66
|
@ -8,7 +8,6 @@
|
|||
#include <linux/logic_pio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/pci_regs.h>
|
||||
#include <linux/sizes.h>
|
||||
|
@ -996,38 +995,6 @@ out:
|
|||
of_node_put(node);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
|
||||
{
|
||||
struct device_node *node, *of_node = dev->of_node;
|
||||
int count, i;
|
||||
|
||||
count = of_property_count_elems_of_size(of_node, "memory-region",
|
||||
sizeof(u32));
|
||||
/*
|
||||
* If dev->of_node doesn't exist or doesn't contain memory-region, try
|
||||
* the OF node having DMA configuration.
|
||||
*/
|
||||
if (count <= 0) {
|
||||
of_node = np;
|
||||
count = of_property_count_elems_of_size(
|
||||
of_node, "memory-region", sizeof(u32));
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
node = of_parse_phandle(of_node, "memory-region", i);
|
||||
/*
|
||||
* There might be multiple memory regions, but only one
|
||||
* restricted-dma-pool region is allowed.
|
||||
*/
|
||||
if (of_device_is_compatible(node, "restricted-dma-pool") &&
|
||||
of_device_is_available(node))
|
||||
return of_reserved_mem_device_init_by_idx(dev, of_node,
|
||||
i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_HAS_DMA */
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <linux/of_device.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_iommu.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/dma-direct.h> /* for bus_dma_region */
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/init.h>
|
||||
|
@ -52,6 +53,39 @@ int of_device_add(struct platform_device *ofdev)
|
|||
return device_add(&ofdev->dev);
|
||||
}
|
||||
|
||||
static int
|
||||
of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
|
||||
{
|
||||
struct device_node *node, *of_node = dev->of_node;
|
||||
int count, i;
|
||||
|
||||
count = of_property_count_elems_of_size(of_node, "memory-region",
|
||||
sizeof(u32));
|
||||
/*
|
||||
* If dev->of_node doesn't exist or doesn't contain memory-region, try
|
||||
* the OF node having DMA configuration.
|
||||
*/
|
||||
if (count <= 0) {
|
||||
of_node = np;
|
||||
count = of_property_count_elems_of_size(
|
||||
of_node, "memory-region", sizeof(u32));
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
node = of_parse_phandle(of_node, "memory-region", i);
|
||||
/*
|
||||
* There might be multiple memory regions, but only one
|
||||
* restricted-dma-pool region is allowed.
|
||||
*/
|
||||
if (of_device_is_compatible(node, "restricted-dma-pool") &&
|
||||
of_device_is_available(node))
|
||||
return of_reserved_mem_device_init_by_idx(dev, of_node,
|
||||
i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_dma_configure_id - Setup DMA configuration
|
||||
* @dev: Device to apply DMA configuration
|
||||
|
|
|
@ -163,19 +163,12 @@ struct bus_dma_region;
|
|||
#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_HAS_DMA)
|
||||
int of_dma_get_range(struct device_node *np,
|
||||
const struct bus_dma_region **map);
|
||||
int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np);
|
||||
#else
|
||||
static inline int of_dma_get_range(struct device_node *np,
|
||||
const struct bus_dma_region **map)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
static inline int of_dma_set_restricted_buffer(struct device *dev,
|
||||
struct device_node *np)
|
||||
{
|
||||
/* Do nothing, successfully. */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void fdt_init_reserved_mem(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче