Skip to content

Commit

Permalink
mtd: rawnand: qcom: stop using phys_to_dma()
Browse files Browse the repository at this point in the history
Compile-testing this driver on x86 caused a link error:

ERROR: "__phys_to_dma" [drivers/mtd/nand/raw/qcom_nandc.ko] undefined!

The problem here is that the driver attempts to convert the physical
address into the DMA controller as a dma_addr_t and calls phys_to_dma()
to do the conversion.

The correct way to do the conversion is using the dma mapping interfaces.

Fixes: c76b78d ("mtd: nand: Qualcomm NAND controller driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
Arnd Bergmann authored and Miquel Raynal committed Jul 19, 2018
1 parent d535934 commit 7330fc5
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions drivers/mtd/nand/raw/qcom_nandc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2957,14 +2957,6 @@ static int qcom_nandc_probe(struct platform_device *pdev)

nandc->props = dev_data;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
nandc->base = devm_ioremap_resource(dev, res);
if (IS_ERR(nandc->base))
return PTR_ERR(nandc->base);

nandc->base_phys = res->start;
nandc->base_dma = phys_to_dma(dev, (phys_addr_t)res->start);

nandc->core_clk = devm_clk_get(dev, "core");
if (IS_ERR(nandc->core_clk))
return PTR_ERR(nandc->core_clk);
Expand All @@ -2977,9 +2969,21 @@ static int qcom_nandc_probe(struct platform_device *pdev)
if (ret)
return ret;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
nandc->base = devm_ioremap_resource(dev, res);
if (IS_ERR(nandc->base))
return PTR_ERR(nandc->base);

nandc->base_phys = res->start;
nandc->base_dma = dma_map_resource(dev, res->start,
resource_size(res),
DMA_BIDIRECTIONAL, 0);
if (!nandc->base_dma)
return -ENXIO;

ret = qcom_nandc_alloc(nandc);
if (ret)
goto err_core_clk;
goto err_nandc_alloc;

ret = clk_prepare_enable(nandc->core_clk);
if (ret)
Expand All @@ -3005,23 +3009,31 @@ static int qcom_nandc_probe(struct platform_device *pdev)
clk_disable_unprepare(nandc->core_clk);
err_core_clk:
qcom_nandc_unalloc(nandc);
err_nandc_alloc:
dma_unmap_resource(dev, res->start, resource_size(res),
DMA_BIDIRECTIONAL, 0);

return ret;
}

static int qcom_nandc_remove(struct platform_device *pdev)
{
struct qcom_nand_controller *nandc = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct qcom_nand_host *host;

list_for_each_entry(host, &nandc->host_list, node)
nand_release(nand_to_mtd(&host->chip));


qcom_nandc_unalloc(nandc);

clk_disable_unprepare(nandc->aon_clk);
clk_disable_unprepare(nandc->core_clk);

dma_unmap_resource(&pdev->dev, nandc->base_dma, resource_size(res),
DMA_BIDIRECTIONAL, 0);

return 0;
}

Expand Down

0 comments on commit 7330fc5

Please sign in to comment.