Skip to contentSkip to conversation

media: platform: Use dev_err_probe instead of dev_err

PATCH In review Wang Ming 2 participants 4 messages Jul 26, 2023 – Jul 27, 2023

Subsystems (3)

v2 of 3 In review Latest is v3 →

lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH v2 1/1 media: platform: Use dev_err_probe instead of dev_err

It is possible that dma_request_chan will return EPROBE_DEFER, which means that dma->xdev->dev is not ready yet. In this case, dev_err(dma->xdev->dev), there will be no output. This patch fixes the bug.

---
 drivers/media/platform/xilinx/xilinx-dma.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/xilinx/xilinx-dma.c +2 -3
index 80d6f5b072ea..16ad39bef6c6 100644
@@ -708,9 +708,8 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 	snprintf(name, sizeof(name), "port%u", port);
 	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");
+		ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
+			"no VDMA channel found\n");
 		goto error;
 	}
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Wang,

Thank you for the patch.

Quoted 4 lines · Wang Ming

It is possible that dma_request_chan will return EPROBE_DEFER, which means that dma->xdev->dev is not ready yet. In this case, dev_err(dma->xdev->dev), there will be no output. This patch fixes the bug.

It's not a bug. The existing code works as expected. dev_err_probe() is nicer though, as it records the reason for the probe deferral. Here's a proposal for a better commit message:

It is possible that dma_request_chan() returns EPROBE_DEFER, in which case the driver defers probing without printing any message. Use dev_err_probe() to record the probe deferral cause and ease debugging.

If you're fine with this, there's no need to resubmit, I'll update the commit message locally and merge the patch.

Quoted 21 lines
---
 drivers/media/platform/xilinx/xilinx-dma.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/xilinx/xilinx-dma.c +2 -3
index 80d6f5b072ea..16ad39bef6c6 100644
@@ -708,9 +708,8 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 	snprintf(name, sizeof(name), "port%u", port);
 	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");
+		ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
+			"no VDMA channel found\n");
 		goto error;
 	}
 
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer
#2 lore raw
Quoted 28 lines · Laurent Pinchart

Hi Wang,

Thank you for the patch.

Quoted 4 lines · Wang Ming

It is possible that dma_request_chan will return EPROBE_DEFER, which means that dma->xdev->dev is not ready yet. In this case, dev_err(dma->xdev->dev), there will be no output. This patch fixes the bug.

It's not a bug. The existing code works as expected. dev_err_probe() is nicer though, as it records the reason for the probe deferral. Here's a proposal for a better commit message:

It is possible that dma_request_chan() returns EPROBE_DEFER, in which case the driver defers probing without printing any message. Use dev_err_probe() to record the probe deferral cause and ease debugging.

If you're fine with this, there's no need to resubmit, I'll update the commit message locally and merge the patch.

Quoted 5 lines
---
 drivers/media/platform/xilinx/xilinx-dma.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 13 lines

drivers/media/platform/xilinx/xilinx-dma.c int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, · line 712

Quoted 13 lines
drivers/media/platform/xilinx/xilinx-dma.c +2 -3
index 80d6f5b072ea..16ad39bef6c6 100644
@@ -708,9 +708,8 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 	snprintf(name, sizeof(name), "port%u", port);
 	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");
+		ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
+			"no VDMA channel found\n");

I forgot to mention that the message should be aligned:

		ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
				    "no VDMA channel found\n");

I can fix this locally too.

Quoted 3 lines
Quoted 3 lines
drivers/media/platform/xilinx/xilinx-dma.c +0 -0
 		goto error;
 	}
 
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw
Quoted 50 lines · Laurent Pinchart

[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 27 lines · Laurent Pinchart

Hi Wang,

Thank you for the patch.

Quoted 4 lines · Wang Ming

It is possible that dma_request_chan will return EPROBE_DEFER, which means that dma->xdev->dev is not ready yet. In this case, dev_err(dma->xdev->dev), there will be no output. This patch fixes the bug.

It's not a bug. The existing code works as expected. dev_err_probe() is nicer though, as it records the reason for the probe deferral. Here's a proposal for a better commit message:

It is possible that dma_request_chan() returns EPROBE_DEFER, in which case the driver defers probing without printing any message. Use dev_err_probe() to record the probe deferral cause and ease debugging.

If you're fine with this, there's no need to resubmit, I'll update the commit message locally and merge the patch.

Quoted 5 lines
---
  drivers/media/platform/xilinx/xilinx-dma.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 13 lines

drivers/media/platform/xilinx/xilinx-dma.c int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, · line 712

Quoted 13 lines
drivers/media/platform/xilinx/xilinx-dma.c +2 -3
index 80d6f5b072ea..16ad39bef6c6 100644
@@ -708,9 +708,8 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
     snprintf(name, sizeof(name), "port%u", port);
     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");
+           ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
+                   "no VDMA channel found\n");

I forgot to mention that the message should be aligned:

                 ret = dev_err_probe(dma->xdev->dev, PTR_ERR(dma->dma),
                                     "no VDMA channel found\n");

I can fix this locally too.

Quoted 7 lines
Quoted 3 lines

drivers/media/platform/xilinx/xilinx-dma.c int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, · line 715

Quoted 3 lines
drivers/media/platform/xilinx/xilinx-dma.c +0 -0
             goto error;
     }
 

--
Regards,

Laurent Pinchart

Okay

thank you.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel