Skip to contentSkip to conversation

drm/arm: cleanup coding style in arm a bit

PATCH In review Bernard Zhao 2 participants 3 messages Apr 22, 2020 – Apr 24, 2020

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

PATCH 1/1 drm/arm: cleanup coding style in arm a bit

For the code logic, an alarm is thrown after failure, but the code continues to run and returns successfully, so to the caller the if check and return branch will never run.
The change is to make the code a bit more readable.

---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/arm/hdlcd_crtc.c +1 -3
index af67fefed38d..32bda13250f5 100644
@@ -160,9 +160,7 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	hdlcd_write(hdlcd, HDLCD_REG_H_SYNC, vm.hsync_len - 1);
 	hdlcd_write(hdlcd, HDLCD_REG_POLARITIES, polarities);
 
-	err = hdlcd_set_pxl_fmt(crtc);
-	if (err)
-		return;
+	hdlcd_set_pxl_fmt(crtc);
 
 	clk_set_rate(hdlcd->clk, m->crtc_clock * 1000);
 }
Signature · 1 line
2.26.2
maintainer
#1 lore raw

Hi Bernard,

Quoted 15 lines · Bernard Zhao

For the code logic, an alarm is thrown after failure, but the code continues to run and returns successfully, so to the caller the if check and return branch will never run.
The change is to make the code a bit more readable.

---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/arm/hdlcd_crtc.c +0 -0
index af67fefed38d..32bda13250f5 100644

drivers/gpu/drm/arm/hdlcd_crtc.c static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 163

Quoted 7 lines
drivers/gpu/drm/arm/hdlcd_crtc.c +1 -3
@@ -160,9 +160,7 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	hdlcd_write(hdlcd, HDLCD_REG_H_SYNC, vm.hsync_len - 1);
 	hdlcd_write(hdlcd, HDLCD_REG_POLARITIES, polarities);
 
-	err = hdlcd_set_pxl_fmt(crtc);
-	if (err)
-		return;
+	hdlcd_set_pxl_fmt(crtc);

I think you found a real bug. hdlcd_set_pxl_fmt() is not supposed to return zero if the format is not supported and here we would stop enabling the pixel clock.

Do you care to send a patch for fixing the bug, rather than this one?

Best regards,
Liviu

Quoted 6 lines
drivers/gpu/drm/arm/hdlcd_crtc.c +0 -0
 	clk_set_rate(hdlcd->clk, m->crtc_clock * 1000);
 }
Signature · 1 line
2.26.2
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
author
#2 lore raw

From: Liviu Dudau <[email protected]>
Date: 2020-04-23 20:50:07
To: Bernard Zhao <[email protected]>
Cc: Brian Starkey <[email protected]>,David Airlie <[email protected]>,Daniel Vetter <[email protected]>,[email protected],[email protected],[email protected]
Subject: Re: [PATCH] drm/arm: cleanup coding style in arm a bit>Hi Bernard,

Quoted 28 lines · Bernard Zhao
Quoted 15 lines

For the code logic, an alarm is thrown after failure, but the code continues to run and returns successfully, so to the caller the if check and return branch will never run.
The change is to make the code a bit more readable.

---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/arm/hdlcd_crtc.c +0 -0
index af67fefed38d..32bda13250f5 100644

drivers/gpu/drm/arm/hdlcd_crtc.c static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 163

Quoted 7 lines
drivers/gpu/drm/arm/hdlcd_crtc.c +1 -3
@@ -160,9 +160,7 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	hdlcd_write(hdlcd, HDLCD_REG_H_SYNC, vm.hsync_len - 1);
 	hdlcd_write(hdlcd, HDLCD_REG_POLARITIES, polarities);
 
-	err = hdlcd_set_pxl_fmt(crtc);
-	if (err)
-		return;
+	hdlcd_set_pxl_fmt(crtc);

I think you found a real bug. hdlcd_set_pxl_fmt() is not supposed to return zero if the format is not supported and here we would stop enabling the pixel clock.

Quoted 5 lines

Do you care to send a patch for fixing the bug, rather than this one?

Best regards,
Liviu

Sure, I do have a bit confusing about this code, I will resubmit a patch and try to fix it.

Regards,
Bernard

Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/arm/hdlcd_crtc.c +0 -0
 	clk_set_rate(hdlcd->clk, m->crtc_clock * 1000);
 }
Signature · 1 line
2.26.2
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
\ source code!  /
 ---------------
   ¯\_(ツ)_/¯