diff mbox series

drm: bridge: simple-bridge: use devm_drm_bridge_add in probe

Message ID 20240618-devm-simple-bridge-v1-1-c7ed8a09fcc5@freebox.fr (mailing list archive)
State New, archived
Headers show
Series drm: bridge: simple-bridge: use devm_drm_bridge_add in probe | expand

Commit Message

Marc Gonzalez June 18, 2024, 4:19 p.m. UTC
simple_bridge_probe() calls drm_bridge_add()
Thus, drm_bridge_remove() must be called in the remove() callback.

If we call devm_drm_bridge_add() instead, then drm_bridge_remove()
will be called automatically at device release, and the remove()
callback is no longer required.

Signed-off-by: Marc Gonzalez <mgonzalez@freebox.fr>
---
This patch was proposed in an abandoned patch series,
but it makes sense by itself. Submit now.
https://lore.kernel.org/r/20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr
---
 drivers/gpu/drm/bridge/simple-bridge.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)


---
base-commit: 17b591a4a192a8a11faad30520b8f6a9137ac514
change-id: 20240618-devm-simple-bridge-9e163fece192

Best regards,

Comments

Dmitry Baryshkov June 18, 2024, 6:30 p.m. UTC | #1
On Tue, Jun 18, 2024 at 06:19:59PM GMT, Marc Gonzalez wrote:
> simple_bridge_probe() calls drm_bridge_add()
> Thus, drm_bridge_remove() must be called in the remove() callback.
> 
> If we call devm_drm_bridge_add() instead, then drm_bridge_remove()
> will be called automatically at device release, and the remove()
> callback is no longer required.
> 
> Signed-off-by: Marc Gonzalez <mgonzalez@freebox.fr>
> ---
> This patch was proposed in an abandoned patch series,
> but it makes sense by itself. Submit now.
> https://lore.kernel.org/r/20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr
> ---
>  drivers/gpu/drm/bridge/simple-bridge.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Neil Armstrong June 19, 2024, 8:01 a.m. UTC | #2
On 18/06/2024 18:19, Marc Gonzalez wrote:
> simple_bridge_probe() calls drm_bridge_add()
> Thus, drm_bridge_remove() must be called in the remove() callback.
> 
> If we call devm_drm_bridge_add() instead, then drm_bridge_remove()
> will be called automatically at device release, and the remove()
> callback is no longer required.
> 
> Signed-off-by: Marc Gonzalez <mgonzalez@freebox.fr>
> ---
> This patch was proposed in an abandoned patch series,
> but it makes sense by itself. Submit now.
> https://lore.kernel.org/r/20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr
> ---
>   drivers/gpu/drm/bridge/simple-bridge.c | 13 +------------
>   1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
> index 5813a2c4fc5ee..dbe58f5707f08 100644
> --- a/drivers/gpu/drm/bridge/simple-bridge.c
> +++ b/drivers/gpu/drm/bridge/simple-bridge.c
> @@ -175,7 +175,6 @@ static int simple_bridge_probe(struct platform_device *pdev)
>   	sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL);
>   	if (!sbridge)
>   		return -ENOMEM;
> -	platform_set_drvdata(pdev, sbridge);
>   
>   	sbridge->info = of_device_get_match_data(&pdev->dev);
>   
> @@ -213,16 +212,7 @@ static int simple_bridge_probe(struct platform_device *pdev)
>   	sbridge->bridge.of_node = pdev->dev.of_node;
>   	sbridge->bridge.timings = sbridge->info->timings;
>   
> -	drm_bridge_add(&sbridge->bridge);
> -
> -	return 0;
> -}
> -
> -static void simple_bridge_remove(struct platform_device *pdev)
> -{
> -	struct simple_bridge *sbridge = platform_get_drvdata(pdev);
> -
> -	drm_bridge_remove(&sbridge->bridge);
> +	return devm_drm_bridge_add(&pdev->dev, &sbridge->bridge);
>   }
>   
>   /*
> @@ -299,7 +289,6 @@ MODULE_DEVICE_TABLE(of, simple_bridge_match);
>   
>   static struct platform_driver simple_bridge_driver = {
>   	.probe	= simple_bridge_probe,
> -	.remove_new = simple_bridge_remove,
>   	.driver		= {
>   		.name		= "simple-bridge",
>   		.of_match_table	= simple_bridge_match,
> 
> ---
> base-commit: 17b591a4a192a8a11faad30520b8f6a9137ac514
> change-id: 20240618-devm-simple-bridge-9e163fece192
> 
> Best regards,

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Maxime Ripard June 19, 2024, 9:05 a.m. UTC | #3
On Tue, 18 Jun 2024 18:19:59 +0200, Marc Gonzalez wrote:
> simple_bridge_probe() calls drm_bridge_add()
> Thus, drm_bridge_remove() must be called in the remove() callback.
> 
> If we call devm_drm_bridge_add() instead, then drm_bridge_remove()
> will be called automatically at device release, and the remove()
> callback is no longer required.
> 
> [...]

Applied to misc/kernel.git (drm-misc-next).

Thanks!
Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 5813a2c4fc5ee..dbe58f5707f08 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -175,7 +175,6 @@  static int simple_bridge_probe(struct platform_device *pdev)
 	sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL);
 	if (!sbridge)
 		return -ENOMEM;
-	platform_set_drvdata(pdev, sbridge);
 
 	sbridge->info = of_device_get_match_data(&pdev->dev);
 
@@ -213,16 +212,7 @@  static int simple_bridge_probe(struct platform_device *pdev)
 	sbridge->bridge.of_node = pdev->dev.of_node;
 	sbridge->bridge.timings = sbridge->info->timings;
 
-	drm_bridge_add(&sbridge->bridge);
-
-	return 0;
-}
-
-static void simple_bridge_remove(struct platform_device *pdev)
-{
-	struct simple_bridge *sbridge = platform_get_drvdata(pdev);
-
-	drm_bridge_remove(&sbridge->bridge);
+	return devm_drm_bridge_add(&pdev->dev, &sbridge->bridge);
 }
 
 /*
@@ -299,7 +289,6 @@  MODULE_DEVICE_TABLE(of, simple_bridge_match);
 
 static struct platform_driver simple_bridge_driver = {
 	.probe	= simple_bridge_probe,
-	.remove_new = simple_bridge_remove,
 	.driver		= {
 		.name		= "simple-bridge",
 		.of_match_table	= simple_bridge_match,