@@ -23,6 +23,7 @@
#include <linux/of_device.h>
#include <linux/of_dma.h>
#include <linux/slab.h>
+#include <linux/probe-helper.h>
#include "virt-dma.h"
#define OWL_DMA_FRAME_MAX_LENGTH 0xfffff
@@ -1045,20 +1046,15 @@ static int owl_dma_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct owl_dma *od;
- struct resource *res;
int ret, i, nr_channels, nr_requests;
-
- od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL);
- if (!od)
- return -ENOMEM;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -EINVAL;
-
- od->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(od->base))
- return PTR_ERR(od->base);
+ /*
+ * This macro internally combines following functions:
+ * devm_kzalloc, platform_get_resource, devm_ioremap_resource,
+ * devm_clk_get, platform_get_irq
+ */
+ ret = devm_platform_probe_helper(pdev, od, NULL);
+ if (ret < 0)
+ return ret;
ret = of_property_read_u32(np, "dma-channels", &nr_channels);
if (ret) {
@@ -1105,18 +1101,11 @@ static int owl_dma_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&od->dma.channels);
- od->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(od->clk)) {
- dev_err(&pdev->dev, "unable to get clock\n");
- return PTR_ERR(od->clk);
- }
-
/*
* Eventhough the DMA controller is capable of generating 4
* IRQ's for DMA priority feature, we only use 1 IRQ for
* simplification.
*/
- od->irq = platform_get_irq(pdev, 0);
ret = devm_request_irq(&pdev->dev, od->irq, owl_dma_interrupt, 0,
dev_name(&pdev->dev), od);
if (ret) {