Skip to contentSkip to conversation

drm/msm/dpu: simplify and unify dpu_encoder_get_intf and dpu_encoder_get_wb

PATCH In review Dmitry Baryshkov 2 participants 2 messages Jun 25, 2022

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

PATCH v2 1/1 drm/msm/dpu: simplify and unify dpu_encoder_get_intf and dpu_encoder_get_wb

Remove extra nestting level from the dpu_encoder_get_intf(), replacing it with the explicit return in case the INTF_WB was passed to the function.

While we are at it, also change dpu_encoder_get_wb() to also use explicit return rather than the goto.

---

Changes since v1: fix the typo (noticed by Stephen)

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +8 -8
index f435baa500f8..c682d4e02d1b 100644
@@ -1255,12 +1255,13 @@ static enum dpu_intf dpu_encoder_get_intf(const struct dpu_mdss_cfg *catalog,
 {
 	int i = 0;
 
-	if (type != INTF_WB) {
-		for (i = 0; i < catalog->intf_count; i++) {
-			if (catalog->intf[i].type == type
-				&& catalog->intf[i].controller_id == controller_id) {
-				return catalog->intf[i].id;
-			}
+	if (type == INTF_WB)
+		return INTF_MAX;
+
+	for (i = 0; i < catalog->intf_count; i++) {
+		if (catalog->intf[i].type == type
+		    && catalog->intf[i].controller_id == controller_id) {
+			return catalog->intf[i].id;
 		}
 	}
 
@@ -1273,14 +1274,13 @@ static enum dpu_wb dpu_encoder_get_wb(const struct dpu_mdss_cfg *catalog,
 	int i = 0;
 
 	if (type != INTF_WB)
-		goto end;
+		return WB_MAX;
 
 	for (i = 0; i < catalog->wb_count; i++) {
 		if (catalog->wb[i].id == controller_id)
 			return catalog->wb[i].id;
 	}
 
-end:
 	return WB_MAX;
 }
 
Signature · 1 line
2.35.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Dmitry Baryshkov

Remove extra nestting level from the dpu_encoder_get_intf(), replacing it with the explicit return in case the INTF_WB was passed to the function.

While we are at it, also change dpu_encoder_get_wb() to also use explicit return rather than the goto.

Quoted 48 lines

---

Changes since v1: fix the typo (noticed by Stephen)

---
  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +8 -8
index f435baa500f8..c682d4e02d1b 100644
@@ -1255,12 +1255,13 @@ static enum dpu_intf dpu_encoder_get_intf(const struct dpu_mdss_cfg *catalog,
  {
  	int i = 0;
 
-	if (type != INTF_WB) {
-		for (i = 0; i < catalog->intf_count; i++) {
-			if (catalog->intf[i].type == type
-				&& catalog->intf[i].controller_id == controller_id) {
-				return catalog->intf[i].id;
-			}
+	if (type == INTF_WB)
+		return INTF_MAX;
+
+	for (i = 0; i < catalog->intf_count; i++) {
+		if (catalog->intf[i].type == type
+		    && catalog->intf[i].controller_id == controller_id) {
+			return catalog->intf[i].id;
  		}
  	}
 
@@ -1273,14 +1274,13 @@ static enum dpu_wb dpu_encoder_get_wb(const struct dpu_mdss_cfg *catalog,
  	int i = 0;
 
  	if (type != INTF_WB)
-		goto end;
+		return WB_MAX;
 
  	for (i = 0; i < catalog->wb_count; i++) {
  		if (catalog->wb[i].id == controller_id)
  			return catalog->wb[i].id;
  	}
 
-end:
  	return WB_MAX;
  }