Skip to content

Commit b35f79a

Browse files
Peter Ujfalusimiquelraynal
authored andcommitted
mtd: rawnand: stm32_fmc2: Use dma_request_chan() instead dma_request_slave_channel()
dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code. Use using dma_request_chan() directly and inform user of error in case the DMA request failed. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20200227123749.24064-8-peter.ujfalusi@ti.com
1 parent 92f0f8e commit b35f79a

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

‎drivers/mtd/nand/raw/stm32_fmc2_nand.c‎

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,15 +1606,36 @@ static int stm32_fmc2_setup_interface(struct nand_chip *chip, int chipnr,
16061606
/* DMA configuration */
16071607
static int stm32_fmc2_dma_setup(struct stm32_fmc2_nfc *fmc2)
16081608
{
1609-
int ret;
1609+
int ret = 0;
16101610

1611-
fmc2->dma_tx_ch = dma_request_slave_channel(fmc2->dev, "tx");
1612-
fmc2->dma_rx_ch = dma_request_slave_channel(fmc2->dev, "rx");
1613-
fmc2->dma_ecc_ch = dma_request_slave_channel(fmc2->dev, "ecc");
1611+
fmc2->dma_tx_ch = dma_request_chan(fmc2->dev, "tx");
1612+
if (IS_ERR(fmc2->dma_tx_ch)) {
1613+
ret = PTR_ERR(fmc2->dma_tx_ch);
1614+
if (ret != -ENODEV)
1615+
dev_err(fmc2->dev,
1616+
"failed to request tx DMA channel: %d\n", ret);
1617+
fmc2->dma_tx_ch = NULL;
1618+
goto err_dma;
1619+
}
16141620

1615-
if (!fmc2->dma_tx_ch || !fmc2->dma_rx_ch || !fmc2->dma_ecc_ch) {
1616-
dev_warn(fmc2->dev, "DMAs not defined in the device tree, polling mode is used\n");
1617-
return 0;
1621+
fmc2->dma_rx_ch = dma_request_chan(fmc2->dev, "rx");
1622+
if (IS_ERR(fmc2->dma_rx_ch)) {
1623+
ret = PTR_ERR(fmc2->dma_rx_ch);
1624+
if (ret != -ENODEV)
1625+
dev_err(fmc2->dev,
1626+
"failed to request rx DMA channel: %d\n", ret);
1627+
fmc2->dma_rx_ch = NULL;
1628+
goto err_dma;
1629+
}
1630+
1631+
fmc2->dma_ecc_ch = dma_request_chan(fmc2->dev, "ecc");
1632+
if (IS_ERR(fmc2->dma_ecc_ch)) {
1633+
ret = PTR_ERR(fmc2->dma_ecc_ch);
1634+
if (ret != -ENODEV)
1635+
dev_err(fmc2->dev,
1636+
"failed to request ecc DMA channel: %d\n", ret);
1637+
fmc2->dma_ecc_ch = NULL;
1638+
goto err_dma;
16181639
}
16191640

16201641
ret = sg_alloc_table(&fmc2->dma_ecc_sg, FMC2_MAX_SG, GFP_KERNEL);
@@ -1635,6 +1656,15 @@ static int stm32_fmc2_dma_setup(struct stm32_fmc2_nfc *fmc2)
16351656
init_completion(&fmc2->dma_ecc_complete);
16361657

16371658
return 0;
1659+
1660+
err_dma:
1661+
if (ret == -ENODEV) {
1662+
dev_warn(fmc2->dev,
1663+
"DMAs not defined in the DT, polling mode is used\n");
1664+
ret = 0;
1665+
}
1666+
1667+
return ret;
16381668
}
16391669

16401670
/* NAND callbacks setup */

0 commit comments

Comments
 (0)