From abfec2e172c0728363824f45f11a913bd77bd791 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Mon, 6 May 2024 12:09:16 +0200 Subject: media: bcm2835-unicam: Convert to platform remove callback returning void MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Laurent Pinchart Link: https://lore.kernel.org/r/20240506100917.1544174-2-u.kleine-koenig@pengutronix.de Signed-off-by: Laurent Pinchart --- drivers/media/platform/broadcom/bcm2835-unicam.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c index 3c7878d8d79b..b11bcec5b225 100644 --- a/drivers/media/platform/broadcom/bcm2835-unicam.c +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c @@ -2704,7 +2704,7 @@ err_unicam_put: return ret; } -static int unicam_remove(struct platform_device *pdev) +static void unicam_remove(struct platform_device *pdev) { struct unicam_device *unicam = platform_get_drvdata(pdev); @@ -2718,8 +2718,6 @@ static int unicam_remove(struct platform_device *pdev) unicam_put(unicam); pm_runtime_disable(&pdev->dev); - - return 0; } static const struct of_device_id unicam_of_match[] = { @@ -2730,7 +2728,7 @@ MODULE_DEVICE_TABLE(of, unicam_of_match); static struct platform_driver unicam_driver = { .probe = unicam_probe, - .remove = unicam_remove, + .remove_new = unicam_remove, .driver = { .name = UNICAM_MODULE_NAME, .pm = pm_ptr(&unicam_pm_ops), -- cgit v1.2.3-59-g8ed1b From 05b0b07953b7630705e364fe342689c9af340b32 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 6 May 2024 19:24:46 +0000 Subject: media: bcm2835-unicam: Do not replace IRQ retcode during probe platform_get_irq() cannot return the value 0. It will either return a non-zero irq or a errcode. If a errcode is returned, we need to populate the error code upwards. It will give a more accurate reason of why it failed to the caller, who might decide to retry later. Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart Link: https://lore.kernel.org/r/20240506-fix-broad-v2-1-e6a2a5c0d609@chromium.org Signed-off-by: Laurent Pinchart --- drivers/media/platform/broadcom/bcm2835-unicam.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c index b11bcec5b225..94cd66255b7e 100644 --- a/drivers/media/platform/broadcom/bcm2835-unicam.c +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c @@ -2661,9 +2661,8 @@ 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; goto err_unicam_put; } @@ -2671,7 +2670,6 @@ static int unicam_probe(struct platform_device *pdev) "unicam_capture0", unicam); if (ret) { dev_err(&pdev->dev, "Unable to request interrupt\n"); - ret = -EINVAL; goto err_unicam_put; } -- cgit v1.2.3-59-g8ed1b From 0cc50ced282a3236c0cac72f72c6b027beaa2660 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 6 May 2024 19:24:47 +0000 Subject: media: bcm2835-unicam: Do not print error when irq not found platform_get_irq() already prints an error for us. Fix this cocci warning: drivers/media/platform/broadcom/bcm2835-unicam.c:2664:2-9: line 2664 is redundant because platform_get_irq() already prints an error Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda Link: https://lore.kernel.org/r/20240506-fix-broad-v2-2-e6a2a5c0d609@chromium.org Signed-off-by: Laurent Pinchart --- drivers/media/platform/broadcom/bcm2835-unicam.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c index 94cd66255b7e..bdcb04d63338 100644 --- a/drivers/media/platform/broadcom/bcm2835-unicam.c +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c @@ -2661,10 +2661,8 @@ static int unicam_probe(struct platform_device *pdev) } ret = platform_get_irq(pdev, 0); - if (ret < 0) { - dev_err(&pdev->dev, "No IRQ resource\n"); + if (ret < 0) goto err_unicam_put; - } ret = devm_request_irq(&pdev->dev, ret, unicam_isr, 0, "unicam_capture0", unicam); -- cgit v1.2.3-59-g8ed1b From b6041c9e9f2d85514358ed478c53dfabd4015e3b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 8 May 2024 15:31:00 +0300 Subject: media: bcm2835-unicam: Fix a NULL vs IS_ERR() check The media_pad_remote_pad_unique() function returns error pointers, not NULL. Update the check accordingly. Fixes: 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface") Signed-off-by: Dan Carpenter Reviewed-by: Laurent Pinchart Link: https://lore.kernel.org/r/fbbe7862-2820-44eb-81cb-7f33b99cca35@moroto.mountain Signed-off-by: Laurent Pinchart --- drivers/media/platform/broadcom/bcm2835-unicam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c index bdcb04d63338..a1d93c14553d 100644 --- a/drivers/media/platform/broadcom/bcm2835-unicam.c +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c @@ -2433,9 +2433,9 @@ static int unicam_async_bound(struct v4l2_async_notifier *notifier, return ret; source = media_pad_remote_pad_unique(sink); - if (!source) { + if (IS_ERR(source)) { dev_err(unicam->dev, "No connected sensor pad\n"); - return -ENOTCONN; + return PTR_ERR(source); } unicam->sensor.subdev = subdev; -- cgit v1.2.3-59-g8ed1b From 33108abc0e22f6f5d1209f4ba2b53cc94328f633 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 1 May 2024 14:54:39 +0300 Subject: media: bcm2835-unicam: Fix driver path in MAINTAINERS The MAINTAINERS file entry for the bcm2835-unicam driver incorrectly references the non-existing drivers/media/platform/bcm2835/ path. Fix it. Fixes: 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface") Reviewed-by: Hans Verkuil Link: https://lore.kernel.org/r/20240501115439.9789-1-laurent.pinchart@ideasonboard.com Signed-off-by: Laurent Pinchart --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 01b86927a7ad..ef6be9d95143 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4039,7 +4039,7 @@ M: Raspberry Pi Kernel Maintenance L: linux-media@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/media/brcm,bcm2835-unicam.yaml -F: drivers/media/platform/bcm2835/ +F: drivers/media/platform/broadcom/bcm2835-unicam* BROADCOM BCM47XX MIPS ARCHITECTURE M: Hauke Mehrtens -- cgit v1.2.3-59-g8ed1b