Skip to content

Commit 5305e4d

Browse files
arndbolofj
authored andcommitted
dma: edma: move device registration to platform code
The horrible split between the low-level part of the edma support and the dmaengine front-end driver causes problems on multiplatform kernels. This is an attempt to improve the situation slightly by only registering the dmaengine devices that are actually present. Signed-off-by: Arnd Bergmann <[email protected]> [olof: add missing include of linux/dma-mapping.h] Signed-off-by: Olof Johansson <[email protected]> Signed-off-by: Olof Johansson <[email protected]>
1 parent ab699bc commit 5305e4d

File tree

2 files changed

+10
-39
lines changed

2 files changed

+10
-39
lines changed

arch/arm/common/edma.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/io.h>
2727
#include <linux/slab.h>
2828
#include <linux/edma.h>
29+
#include <linux/dma-mapping.h>
2930
#include <linux/of_address.h>
3031
#include <linux/of_device.h>
3132
#include <linux/of_dma.h>
@@ -1623,6 +1624,11 @@ static int edma_probe(struct platform_device *pdev)
16231624
struct device_node *node = pdev->dev.of_node;
16241625
struct device *dev = &pdev->dev;
16251626
int ret;
1627+
struct platform_device_info edma_dev_info = {
1628+
.name = "edma-dma-engine",
1629+
.dma_mask = DMA_BIT_MASK(32),
1630+
.parent = &pdev->dev,
1631+
};
16261632

16271633
if (node) {
16281634
/* Check if this is a second instance registered */
@@ -1793,6 +1799,9 @@ static int edma_probe(struct platform_device *pdev)
17931799
edma_write_array(j, EDMA_QRAE, i, 0x0);
17941800
}
17951801
arch_num_cc++;
1802+
1803+
edma_dev_info.id = j;
1804+
platform_device_register_full(&edma_dev_info);
17961805
}
17971806

17981807
return 0;

drivers/dma/edma.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,52 +1107,14 @@ bool edma_filter_fn(struct dma_chan *chan, void *param)
11071107
}
11081108
EXPORT_SYMBOL(edma_filter_fn);
11091109

1110-
static struct platform_device *pdev0, *pdev1;
1111-
1112-
static const struct platform_device_info edma_dev_info0 = {
1113-
.name = "edma-dma-engine",
1114-
.id = 0,
1115-
.dma_mask = DMA_BIT_MASK(32),
1116-
};
1117-
1118-
static const struct platform_device_info edma_dev_info1 = {
1119-
.name = "edma-dma-engine",
1120-
.id = 1,
1121-
.dma_mask = DMA_BIT_MASK(32),
1122-
};
1123-
11241110
static int edma_init(void)
11251111
{
1126-
int ret = platform_driver_register(&edma_driver);
1127-
1128-
if (ret == 0) {
1129-
pdev0 = platform_device_register_full(&edma_dev_info0);
1130-
if (IS_ERR(pdev0)) {
1131-
platform_driver_unregister(&edma_driver);
1132-
ret = PTR_ERR(pdev0);
1133-
goto out;
1134-
}
1135-
}
1136-
1137-
if (!of_have_populated_dt() && EDMA_CTLRS == 2) {
1138-
pdev1 = platform_device_register_full(&edma_dev_info1);
1139-
if (IS_ERR(pdev1)) {
1140-
platform_driver_unregister(&edma_driver);
1141-
platform_device_unregister(pdev0);
1142-
ret = PTR_ERR(pdev1);
1143-
}
1144-
}
1145-
1146-
out:
1147-
return ret;
1112+
return platform_driver_register(&edma_driver);
11481113
}
11491114
subsys_initcall(edma_init);
11501115

11511116
static void __exit edma_exit(void)
11521117
{
1153-
platform_device_unregister(pdev0);
1154-
if (pdev1)
1155-
platform_device_unregister(pdev1);
11561118
platform_driver_unregister(&edma_driver);
11571119
}
11581120
module_exit(edma_exit);

0 commit comments

Comments
 (0)