Skip to contentSkip to conversation

staging: sm750fb: remove unnecessary goto

PATCH Superseded Haasham Khan 2 participants 4 messages Oct 25

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

PATCH 1/1 staging: sm750fb: remove unnecessary goto

The error path in hw_sm750_crtc_set_mode() jumps to a label that immediately returns ret. Return directly and remove the unnecessary label.

---
 drivers/staging/sm750fb/sm750_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/sm750fb/sm750_hw.c +1 -2
index c4358d3e5091..22f93277e91b 100644
@@ -272,7 +272,7 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 	ret = ddk750_set_mode_timing(&modparm, clock);
 	if (ret) {
 		dev_err(&sm750_dev->pdev->dev, "Set mode timing failed\n");
-		goto exit;
+		return ret;
 	}
 
 	if (crtc->channel != sm750_secondary) {
@@ -332,7 +332,6 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 		poke32(CRT_DISPLAY_CTRL, reg);
 	}
 
-exit:
 	return ret;
 }
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 23 lines · Haasham Khan

The error path in hw_sm750_crtc_set_mode() jumps to a label that immediately returns ret. Return directly and remove the unnecessary label.

---
 drivers/staging/sm750fb/sm750_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/sm750fb/sm750_hw.c +1 -1
index c4358d3e5091..22f93277e91b 100644
@@ -272,7 +272,7 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 	ret = ddk750_set_mode_timing(&modparm, clock);
 	if (ret) {
 		dev_err(&sm750_dev->pdev->dev, "Set mode timing failed\n");
-		goto exit;
+		return ret;
 	}
 
 	if (crtc->channel != sm750_secondary) {

drivers/staging/sm750fb/sm750_hw.c int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc, · line 335

Quoted 5 lines
drivers/staging/sm750fb/sm750_hw.c +0 -1
@@ -332,7 +332,6 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 		poke32(CRT_DISPLAY_CTRL, reg);
 	}
 
-exit:
 	return ret;

Change this to "return 0;"

regards,
dan carpenter

#2 lore raw

PATCH v2 1/1 staging: sm750fb: remove unnecessary goto

In reply to Haasham Khan

Return directly when setting the mode timing fails, rather than jumping to a label that only returns ret. Return 0 on the successful path.

---

Changes in v2:
- Return 0 on the successful path, as suggested by Dan Carpenter.

 drivers/staging/sm750fb/sm750_hw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/sm750_hw.c +2 -3
index c4358d3e5091..4dfa1cb6b352 100644
@@ -272,7 +272,7 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 	ret = ddk750_set_mode_timing(&modparm, clock);
 	if (ret) {
 		dev_err(&sm750_dev->pdev->dev, "Set mode timing failed\n");
-		goto exit;
+		return ret;
 	}
 
 	if (crtc->channel != sm750_secondary) {
@@ -332,8 +332,7 @@ int hw_sm750_crtc_set_mode(struct lynxfb_crtc *crtc,
 		poke32(CRT_DISPLAY_CTRL, reg);
 	}
 
-exit:
-	return ret;
+	return 0;
 }
 
 int hw_sm750_set_col_reg(struct lynxfb_crtc *crtc, ushort index, ushort red,
Signature · 1 line
2.53.0