Skip to contentSkip to conversation

media: xilinx: Use dma_request_chan() instead dma_request_slave_channel()

PATCH Superseded Peter Ujfalusi 3 participants 3 messages Jan 10, 2020 – Jan 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: xilinx: 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.

By using dma_request_chan() directly the driver can support deferred probing against DMA.

---
Hi,

Changes since v1:
- Fix cleanup path when DMA request failed as suggested by Laurent
- Print error only in case when the error is not EPROBE_DEFER

Regards,
Peter

 drivers/media/platform/xilinx/xilinx-dma.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/media/platform/xilinx/xilinx-dma.c +6 -5
index b211380a11f2..3bb54a4db6a4 100644
@@ -725,10 +725,11 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 
 	/* ... and the DMA channel. */
 	snprintf(name, sizeof(name), "port%u", port);
-	dma->dma = dma_request_slave_channel(dma->xdev->dev, name);
-	if (dma->dma == NULL) {
-		dev_err(dma->xdev->dev, "no VDMA channel found\n");
-		ret = -ENODEV;
+	dma->dma = dma_request_chan(dma->xdev->dev, name);
+	if (IS_ERR(dma->dma)) {
+		ret = PTR_ERR(dma->dma);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dma->xdev->dev, "no VDMA channel found\n");
 		goto error;
 	}
 
@@ -752,7 +753,7 @@ void xvip_dma_cleanup(struct xvip_dma *dma)
 	if (video_is_registered(&dma->video))
 		video_unregister_device(&dma->video);
 
-	if (dma->dma)
+	if (!IS_ERR_OR_NULL(dma->dma))
 		dma_release_channel(dma->dma);
 
 	media_entity_cleanup(&dma->video.entity);
Signature · 10 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Peter,

(CC'ing Hans)

Thank you for the patch.

Quoted 7 lines · Peter Ujfalusi

dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code.

By using dma_request_chan() directly the driver can support deferred probing against DMA.

and taken in my tree. Hans, you asked me on IRC to review this, did you plan to get it merged upstream yourself ? If so I'll drop it.

Quoted 39 lines

---
Hi,

Changes since v1:
- Fix cleanup path when DMA request failed as suggested by Laurent
- Print error only in case when the error is not EPROBE_DEFER

 drivers/media/platform/xilinx/xilinx-dma.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/media/platform/xilinx/xilinx-dma.c +6 -5
index b211380a11f2..3bb54a4db6a4 100644
@@ -725,10 +725,11 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 
 	/* ... and the DMA channel. */
 	snprintf(name, sizeof(name), "port%u", port);
-	dma->dma = dma_request_slave_channel(dma->xdev->dev, name);
-	if (dma->dma == NULL) {
-		dev_err(dma->xdev->dev, "no VDMA channel found\n");
-		ret = -ENODEV;
+	dma->dma = dma_request_chan(dma->xdev->dev, name);
+	if (IS_ERR(dma->dma)) {
+		ret = PTR_ERR(dma->dma);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dma->xdev->dev, "no VDMA channel found\n");
 		goto error;
 	}
 
@@ -752,7 +753,7 @@ void xvip_dma_cleanup(struct xvip_dma *dma)
 	if (video_is_registered(&dma->video))
 		video_unregister_device(&dma->video);
 
-	if (dma->dma)
+	if (!IS_ERR_OR_NULL(dma->dma))
 		dma_release_channel(dma->dma);
 
 	media_entity_cleanup(&dma->video.entity);
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
Quoted 13 lines · Laurent Pinchart

Hi Peter,

(CC'ing Hans)

Thank you for the patch.

Quoted 6 lines · Peter Ujfalusi

dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code.

By using dma_request_chan() directly the driver can support deferred probing against DMA.

Quoted 6 lines
Quoted 1 line

and taken in my tree. Hans, you asked me on IRC to review this, did you plan to get it merged upstream yourself ? If so I'll drop it.

Yes, I'll take it. I have similar patches as well in my upcoming PR, so it makes sense to combine them.

Thanks for reviewing this!

Hans

Quoted 41 lines
Quoted 40 lines

---
Hi,

Changes since v1:
- Fix cleanup path when DMA request failed as suggested by Laurent
- Print error only in case when the error is not EPROBE_DEFER

 drivers/media/platform/xilinx/xilinx-dma.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/media/platform/xilinx/xilinx-dma.c +6 -5
index b211380a11f2..3bb54a4db6a4 100644
@@ -725,10 +725,11 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 
 	/* ... and the DMA channel. */
 	snprintf(name, sizeof(name), "port%u", port);
-	dma->dma = dma_request_slave_channel(dma->xdev->dev, name);
-	if (dma->dma == NULL) {
-		dev_err(dma->xdev->dev, "no VDMA channel found\n");
-		ret = -ENODEV;
+	dma->dma = dma_request_chan(dma->xdev->dev, name);
+	if (IS_ERR(dma->dma)) {
+		ret = PTR_ERR(dma->dma);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dma->xdev->dev, "no VDMA channel found\n");
 		goto error;
 	}
 
@@ -752,7 +753,7 @@ void xvip_dma_cleanup(struct xvip_dma *dma)
 	if (video_is_registered(&dma->video))
 		video_unregister_device(&dma->video);
 
-	if (dma->dma)
+	if (!IS_ERR_OR_NULL(dma->dma))
 		dma_release_channel(dma->dma);
 
 	media_entity_cleanup(&dma->video.entity);