@@ -1221,7 +1221,7 @@ int platform_dma_configure(struct device *dev)
int ret = 0;
if (dev->of_node) {
- ret = of_dma_configure(dev, dev->of_node, true);
+ ret = of_dma_configure(dev, true);
} else if (has_acpi_companion(dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
ret = acpi_dma_configure(dev, attr);
@@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent,
core->irq = bcma_of_get_irq(parent, core, 0);
- of_dma_configure(&core->dev, node, false);
+ of_dma_configure(&core->dev, false);
}
unsigned int bcma_core_irq(struct bcma_device *core, int num)
@@ -388,7 +388,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
goto out;
}
new_pdev->dev.of_node = child;
- of_dma_configure(&new_pdev->dev, child, true);
+ of_dma_configure(&new_pdev->dev, true);
/*
* It is assumed that calling of_msi_configure is safe on
* platforms with or without MSI support.
@@ -706,7 +706,7 @@ static int __init etnaviv_init(void)
* device as the GPU we found. This assumes that all Vivante
* GPUs in the system share the same DMA constraints.
*/
- of_dma_configure(&pdev->dev, np, true);
+ of_dma_configure_copy(&pdev->dev, np, true);
ret = platform_device_add(pdev);
if (ret) {
@@ -1268,7 +1268,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
gmu->dev = &pdev->dev;
- of_dma_configure(gmu->dev, node, true);
+ of_dma_configure(gmu->dev, true);
/* Fow now, don't do anything fancy until we get our feet under us */
gmu->idle_level = GMU_IDLE_STATE_ACTIVE;
@@ -802,7 +802,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
* for us, and DRM doesn't do per-device allocation either, so
* we would need to fix DRM first...
*/
- ret = of_dma_configure(drm->dev, dev->of_node, true);
+ ret = of_dma_configure_copy(drm->dev, dev->of_node, true);
if (ret)
return ret;
} else {
@@ -726,7 +726,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev,
* node to set default DMA ops.
*/
dev->coherent_dma_mask = DMA_BIT_MASK(32);
- ret = of_dma_configure(dev, NULL, true);
+ ret = of_dma_configure(dev, true);
if (ret < 0) {
DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
return ret;
@@ -337,7 +337,7 @@ static int host1x_device_uevent(struct device *dev,
static int host1x_dma_configure(struct device *dev)
{
- return of_dma_configure(dev, dev->of_node, true);
+ return of_dma_configure(dev, true);
}
static const struct dev_pm_ops host1x_device_pm_ops = {
@@ -238,7 +238,7 @@ int venus_firmware_init(struct venus_core *core)
pdev->dev.of_node = np;
- ret = of_dma_configure(&pdev->dev, np, true);
+ ret = of_dma_configure(&pdev->dev, true);
if (ret) {
dev_err(core->dev, "dma configure fail\n");
goto err_unregister;
@@ -1095,7 +1095,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
* to be treated as valid DMA masters we need a bit of a hack to force
* them to inherit the MFC node's DMA configuration.
*/
- of_dma_configure(child, dev->of_node, true);
+ of_dma_configure_copy(child, dev->of_node, true);
if (device_add(child) == 0) {
ret = of_reserved_mem_device_init_by_idx(child, dev->of_node,
@@ -75,19 +75,18 @@ int of_device_add(struct platform_device *ofdev)
/**
* of_dma_configure - Setup DMA configuration
* @dev: Device to apply DMA configuration
- * @np: Pointer to OF node having DMA configuration
* @force_dma: Whether device is to be set up by of_dma_configure() even if
* DMA capability is not explicitly described by firmware.
*
* Try to get devices's DMA configuration from DT and update it
* accordingly.
*/
-int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
+int of_dma_configure(struct device *dev, bool force_dma)
{
struct device_node *dma_parent;
int ret;
- dma_parent = __of_get_dma_parent(np);
+ dma_parent = __of_get_dma_parent(dev->of_node);
ret = of_dma_configure_parent(dev, dma_parent, force_dma);
of_node_put(dma_parent);
@@ -95,6 +94,31 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
}
EXPORT_SYMBOL_GPL(of_dma_configure);
+/**
+ * of_dma_configure_copy - Setup DMA configuration based on another device's DT
+ * node
+ * @dev: Device to apply DMA configuration
+ * @np: Device node to copy the configuration from
+ * @force_dma: Whether device is to be set up by of_dma_configure() even if
+ * DMA capability is not explicitly described by firmware.
+ *
+ * Try to get devices's DMA configuration from DT and update it
+ * accordingly.
+ */
+int of_dma_configure_copy(struct device *dev, struct device_node *np,
+ bool force_dma)
+{
+ struct device_node *dma_parent;
+ int ret;
+
+ dma_parent = __of_get_dma_parent(np);
+ ret = of_dma_configure_parent(dev, dma_parent, force_dma);
+ of_node_put(dma_parent);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(of_dma_configure_copy);
+
/**
* of_dma_configure_parent - Setup DMA configuration based on a parent bus'
* DT node
@@ -632,7 +632,7 @@ static int gntdev_open(struct inode *inode, struct file *flip)
* Fix this by calling of_dma_configure() with a NULL node to set
* default DMA ops.
*/
- of_dma_configure(priv->dma_dev, NULL, true);
+ of_dma_configure(priv->dma_dev, true);
#endif
pr_debug("priv %p\n", priv);
@@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
return of_node_get(cpu_dev->of_node);
}
-int of_dma_configure(struct device *dev, struct devce_node *np, bool force_dma);
+int of_dma_configure(struct device *dev, bool force_dma);
+int of_dma_configure_copy(struct device *dev, struct device_node *np,
+ bool force_dma);
int of_dma_configure_parent(struct device *dev, struct device_node *parent,
bool force_dma);
#else /* CONFIG_OF */
@@ -107,12 +109,18 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
}
static inline int of_dma_configure(struct device *dev,
- struct device_node *np,
bool force_dma)
{
return 0;
}
+static inline int of_dma_configure_copy(struct device *dev,
+ struct device_node *np,
+ bool force_dma)
+{
+ return 0;
+}
+
static inline int of_dma_configure_parent(struct device *dev,
struct device_node *parent,
bool force_dma)
The widespread use case for of_dma_config() highlights a redundant argument. Most callers provide both 'dev' and 'dev->of_node'. The rest of users use it to copy some device's DMA configuration into a device not represented in DT. In order to simplify the common use case, and make code a little more explicit, create of_dma_config_copy() which will take another device's DT node as an argument and simplify of_dma_config() by removing one of it's redundant arguments. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> --- drivers/base/platform.c | 2 +- drivers/bcma/main.c | 2 +- drivers/dma/qcom/hidma_mgmt.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +- drivers/gpu/drm/sun4i/sun4i_backend.c | 2 +- drivers/gpu/drm/xen/xen_drm_front.c | 2 +- drivers/gpu/host1x/bus.c | 2 +- drivers/media/platform/qcom/venus/firmware.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +- drivers/of/device.c | 30 ++++++++++++++++++-- drivers/xen/gntdev.c | 2 +- include/linux/of_device.h | 12 ++++++-- 13 files changed, 48 insertions(+), 16 deletions(-)