Skip to contentSkip to conversation

drm/bridge: Remove a small useless code snippet

PATCH In review Sui Jingfeng 2 participants 3 messages May 11, 2024 – May 13, 2024

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

PATCH 1/1 drm/bridge: Remove a small useless code snippet

Because the check on the non-existence (encoder == NULL) has already been done in the implementation of drm_bridge_attach() function, and drm_bridge_attach() is called earlier. The driver won't get to check point even if drm_bridge_attach() fails for some reasons, as it will clear the bridge->encoder to NULL and return a negective error code.

Therefore, there is no need to check another again. Remove the redundant codes at the later.

---
 drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/bridge/simple-bridge.c +0 -5
index 28376d0ecd09..3caa918ac2e0 100644
@@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
 		return 0;
 
-	if (!bridge->encoder) {
-		DRM_ERROR("Missing encoder\n");
-		return -ENODEV;
-	}
-
 	drm_connector_helper_add(&sbridge->connector,
 				 &simple_bridge_con_helper_funcs);
 	ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Sui,

Thank you for the patch.

Quoted 5 lines · Sui Jingfeng

Because the check on the non-existence (encoder == NULL) has already been done in the implementation of drm_bridge_attach() function, and drm_bridge_attach() is called earlier. The driver won't get to check point even if drm_bridge_attach() fails for some reasons, as it will clear the bridge->encoder to NULL and return a negective error code.

s/negective/negative/

Quoted 5 lines

Therefore, there is no need to check another again. Remove the redundant codes at the later.

If you end up sending a second version of this patch, please include all similar patches you have sent at the same time in a patch series, instead of sending them separately.

Quoted 20 lines
---
 drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/bridge/simple-bridge.c +0 -5
index 28376d0ecd09..3caa918ac2e0 100644
@@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
 		return 0;
 
-	if (!bridge->encoder) {
-		DRM_ERROR("Missing encoder\n");
-		return -ENODEV;
-	}
-
 	drm_connector_helper_add(&sbridge->connector,
 				 &simple_bridge_con_helper_funcs);
 	ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Hi,

Quoted 4 lines · Laurent Pinchart

Hi Sui,

Thank you for the patch.

Quoted 8 lines
Quoted 5 lines · Sui Jingfeng

Because the check on the non-existence (encoder == NULL) has already been done in the implementation of drm_bridge_attach() function, and drm_bridge_attach() is called earlier. The driver won't get to check point even if drm_bridge_attach() fails for some reasons, as it will clear the bridge->encoder to NULL and return a negective error code.

s/negective/negative/

Sorry, my bad.

Quoted 9 lines
Quoted 4 lines

Therefore, there is no need to check another again. Remove the redundant codes at the later.

If you end up sending a second version of this patch, please include all similar patches you have sent at the same time in a patch series, instead of sending them separately.

I will send a second version to correct spell error and collect and fold them into a series.

By the way, thanks a lot for you time review my patch and thanks a lot for the generous.

So happy be reviewed and its my pleasure to have opportunities to talk with you. Thanks a lot!

Quoted 20 lines
Quoted 20 lines
---
  drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
  1 file changed, 5 deletions(-)
drivers/gpu/drm/bridge/simple-bridge.c +0 -5
index 28376d0ecd09..3caa918ac2e0 100644
@@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
  	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
  		return 0;
 
-	if (!bridge->encoder) {
-		DRM_ERROR("Missing encoder\n");
-		return -ENODEV;
-	}
-
  	drm_connector_helper_add(&sbridge->connector,
  				 &simple_bridge_con_helper_funcs);
  	ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
Signature · 2 lines
Best regards,
Sui