[PATCH 1/3] media: bcm2835-unicam: Fix error handling for platform_get_irq

Ricardo Ribalda posted 3 patches 1 year, 7 months ago
There is a newer version of this series
[PATCH 1/3] media: bcm2835-unicam: Fix error handling for platform_get_irq
Posted by Ricardo Ribalda 1 year, 7 months ago
platform_get_irq() cannot return the value 0.

If it returns -EPROBE_DEFER, we need to populate the error code upwards
to retry probing once the irq handler is ready.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/broadcom/bcm2835-unicam.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
index bd2bbb53070e..2a3a27ac70ba 100644
--- a/drivers/media/platform/broadcom/bcm2835-unicam.c
+++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
@@ -2660,9 +2660,10 @@ static int unicam_probe(struct platform_device *pdev)
 	}
 
 	ret = platform_get_irq(pdev, 0);
-	if (ret <= 0) {
+	if (ret < 0) {
 		dev_err(&pdev->dev, "No IRQ resource\n");
-		ret = -EINVAL;
+		if (ret != -EPROBE_DEFER)
+			ret = -EINVAL;
 		goto err_unicam_put;
 	}
 

-- 
2.44.0.769.g3c40516874-goog
Re: [PATCH 1/3] media: bcm2835-unicam: Fix error handling for platform_get_irq
Posted by Laurent Pinchart 1 year, 7 months ago
Hi Ricardo,

Thank you for the patch.

On Tue, Apr 30, 2024 at 07:51:26AM +0000, Ricardo Ribalda wrote:
> platform_get_irq() cannot return the value 0.
> 
> If it returns -EPROBE_DEFER, we need to populate the error code upwards
> to retry probing once the irq handler is ready.
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/platform/broadcom/bcm2835-unicam.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
> index bd2bbb53070e..2a3a27ac70ba 100644
> --- a/drivers/media/platform/broadcom/bcm2835-unicam.c
> +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
> @@ -2660,9 +2660,10 @@ static int unicam_probe(struct platform_device *pdev)
>  	}
>  
>  	ret = platform_get_irq(pdev, 0);
> -	if (ret <= 0) {
> +	if (ret < 0) {
>  		dev_err(&pdev->dev, "No IRQ resource\n");
> -		ret = -EINVAL;
> +		if (ret != -EPROBE_DEFER)
> +			ret = -EINVAL;

What's wrong with leaving ret untouched ? I assume it was set to -EINVAL
to avoid returning success in case ret was 0. Now that the test has
changed, I think we can leave the value as-is.

>  		goto err_unicam_put;
>  	}
>  
> 

-- 
Regards,

Laurent Pinchart