2021-12-06 02:11:11

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH] mfd: omap-usb-host: Handle dma_set_coherent_mask error codes

The return value of dma_set_coherent_mask() is not always 0.
To catch the exception in case that dma is not support the mask.

Fixes: cbb8c220e70d ("mfd: Remove omap-usb-host magic numbers for dev dma mask")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/mfd/omap-usb-host.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 2a3a240b4619..05af9ad314b1 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -169,7 +169,11 @@ static struct platform_device *omap_usbhs_alloc_child(const char *name,
}

child->dev.dma_mask = &usbhs_dmamask;
- dma_set_coherent_mask(&child->dev, DMA_BIT_MASK(32));
+ ret = dma_set_coherent_mask(&child->dev, DMA_BIT_MASK(32));
+ if (ret) {
+ dev_err(&child->dev, "DMA enable failed\n");
+ goto err_alloc;
+ }
child->dev.parent = dev;

ret = platform_device_add(child);
--
2.25.1