Skip to contentSkip to conversation

drm/panel: use devm_drm_panel_add() in more drivers

PATCH In review Myeonghun Pak 2 participants 4 messages May 24 – May 25

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

cover drm/panel: use devm_drm_panel_add() in more drivers

Convert two panel drivers to devm_drm_panel_add() so panel registration is cleaned up by devres on later probe failures.

Both drivers currently call drm_panel_add() before attaching one or more DSI devices. If an attach fails, probe returns with the panel still in the global panel registry. drm-misc-next has devm_drm_panel_add(), which wraps drm_panel_add() with devres-managed drm_panel_remove() cleanup.

Patch 1 updates boe-bf060y8m-aj0.
Patch 2 updates novatek-nt36523.

Myeonghun Pak (2):
drm/panel: boe-bf060y8m-aj0: use devm_drm_panel_add() drm/panel: novatek-nt36523: use devm_drm_panel_add()

 drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c |  6 +++---
 drivers/gpu/drm/panel/panel-novatek-nt36523.c  | 12 +++---------
 2 files changed, 6 insertions(+), 12 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/2 drm/panel: boe-bf060y8m-aj0: use devm_drm_panel_add()

boe_bf060y8m_aj0_probe() adds the panel before attaching the DSI device. If mipi_dsi_attach() fails, probe returns with the panel still registered.

drm-misc-next has devm_drm_panel_add(), so use it to register the panel with devres-managed cleanup. This removes the need for open-coded drm_panel_remove() handling on later probe failures and on the remove path.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes a19125a28112 ("drm/panel: Add BOE BF060Y8M-AJ0 5.99" AMOLED panel driver")
---
 drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c +3 -3
index 84c21c62a4..a6d765b402 100644
@@ -357,7 +357,9 @@ static int boe_bf060y8m_aj0_probe(struct mipi_dsi_device *dsi)
 		return dev_err_probe(dev, PTR_ERR(boe->panel.backlight),
 				     "Failed to create backlight\n");
 
-	drm_panel_add(&boe->panel);
+	ret = devm_drm_panel_add(dev, &boe->panel);
+	if (ret)
+		return ret;
 
 	ret = mipi_dsi_attach(dsi);
 	if (ret < 0) {
@@ -376,8 +378,6 @@ static void boe_bf060y8m_aj0_remove(struct mipi_dsi_device *dsi)
 	ret = mipi_dsi_detach(dsi);
 	if (ret < 0)
 		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
-
-	drm_panel_remove(&boe->panel);
 }
 
 static const struct of_device_id boe_bf060y8m_aj0_of_match[] = {
Signature · 1 line
2.47.1
#2 lore raw

PATCH 2/2 drm/panel: novatek-nt36523: use devm_drm_panel_add()

In reply to Myeonghun Pak

nt36523_probe() adds the DRM panel before attaching the DSI devices. If one of the devm_mipi_dsi_attach() calls fails, probe returns with the panel still registered.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 0993234a0045 ("drm/panel: Add driver for Novatek NT36523")
---
 drivers/gpu/drm/panel/panel-novatek-nt36523.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/panel/panel-novatek-nt36523.c +3 -9
index 226d91daf8..f6592b01df 100644
@@ -1047,13 +1047,6 @@ static int nt36523_unprepare(struct drm_panel *panel)
 	return 0;
 }
 
-static void nt36523_remove(struct mipi_dsi_device *dsi)
-{
-	struct panel_info *pinfo = mipi_dsi_get_drvdata(dsi);
-
-	drm_panel_remove(&pinfo->panel);
-}
-
 static int nt36523_get_modes(struct drm_panel *panel,
 			       struct drm_connector *connector)
 {
@@ -1225,7 +1218,9 @@ static int nt36523_probe(struct mipi_dsi_device *dsi)
 			return dev_err_probe(dev, ret, "Failed to get backlight\n");
 	}
 
-	drm_panel_add(&pinfo->panel);
+	ret = devm_drm_panel_add(dev, &pinfo->panel);
+	if (ret)
+		return ret;
 
 	for (i = 0; i < DSI_NUM_MIN + pinfo->desc->is_dual_dsi; i++) {
 		pinfo->dsi[i]->lanes = pinfo->desc->lanes;
@@ -1259,7 +1254,6 @@ MODULE_DEVICE_TABLE(of, nt36523_of_match);
 
 static struct mipi_dsi_driver nt36523_driver = {
 	.probe = nt36523_probe,
-	.remove = nt36523_remove,
 	.driver = {
 		.name = "panel-novatek-nt36523",
 		.of_match_table = nt36523_of_match,
Signature · 1 line
2.47.1
#3 lore raw

Re: [PATCH 2/2] drm/panel: novatek-nt36523: use devm_drm_panel_add()

Le 24/05/2026 à 18:36, Myeonghun Pak a écrit :

Quoted 21 lines

nt36523_probe() adds the DRM panel before attaching the DSI devices. If one of the devm_mipi_dsi_attach() calls fails, probe returns with the panel still registered.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 0993234a0045 ("drm/panel: Add driver for Novatek NT36523")
---
  drivers/gpu/drm/panel/panel-novatek-nt36523.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/panel/panel-novatek-nt36523.c +0 -0
index 226d91daf8..f6592b01df 100644

drivers/gpu/drm/panel/panel-novatek-nt36523.c static int nt36523_unprepare(struct drm_panel *panel) · line 1052

Quoted 6 lines
drivers/gpu/drm/panel/panel-novatek-nt36523.c +0 -3
@@ -1047,13 +1047,6 @@ static int nt36523_unprepare(struct drm_panel *panel)
  	return 0;
  }
 
-static void nt36523_remove(struct mipi_dsi_device *dsi)
-{
-	struct panel_info *pinfo = mipi_dsi_get_drvdata(dsi);

Hi,

Not looked in details, but the:

	mipi_dsi_set_drvdata(dsi, pinfo);

in the probe now looks useless.

CJ

Quoted 26 lines
drivers/gpu/drm/panel/panel-novatek-nt36523.c +3 -6
-
-	drm_panel_remove(&pinfo->panel);
-}
-
  static int nt36523_get_modes(struct drm_panel *panel,
  			       struct drm_connector *connector)
  {
@@ -1225,7 +1218,9 @@ static int nt36523_probe(struct mipi_dsi_device *dsi)
  			return dev_err_probe(dev, ret, "Failed to get backlight\n");
  	}
 
-	drm_panel_add(&pinfo->panel);
+	ret = devm_drm_panel_add(dev, &pinfo->panel);
+	if (ret)
+		return ret;
 
  	for (i = 0; i < DSI_NUM_MIN + pinfo->desc->is_dual_dsi; i++) {
  		pinfo->dsi[i]->lanes = pinfo->desc->lanes;
@@ -1259,7 +1254,6 @@ MODULE_DEVICE_TABLE(of, nt36523_of_match);
 
  static struct mipi_dsi_driver nt36523_driver = {
  	.probe = nt36523_probe,
-	.remove = nt36523_remove,
  	.driver = {
  		.name = "panel-novatek-nt36523",
  		.of_match_table = nt36523_of_match,