Skip to contentSkip to conversation

staging: sm750fb: improve error handling in de_wait path

PATCH Superseded Hungyu Lin 2 participants 5 messages Apr 9 – Apr 27

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

v2 cover staging: sm750fb: improve error handling in de_wait path

This series improves error handling in the sm750fb driver.

The de_wait() helpers previously returned -1 on timeout, and callers discarded the error code by always returning -1. This series replaces -1 with -ETIMEDOUT and propagates the error code to improve error reporting.

Patch 1 replaces -1 with -ETIMEDOUT in de_wait() helpers. Patch 2 propagates error codes from de_wait().

v2:
- Restore the removed comment in sm750_accel.c as requested

Hungyu Lin (2):
staging: sm750fb: return -ETIMEDOUT on timeout in de_wait functions
staging: sm750fb: propagate error codes from de_wait()

 drivers/staging/sm750fb/sm750_accel.c | 20 +++++++++++++-------
 drivers/staging/sm750fb/sm750_hw.c    |  4 ++--
 2 files changed, 15 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/2 staging: sm750fb: return -ETIMEDOUT on timeout in de_wait functions

The hw_sm750le_de_wait() and hw_sm750_de_wait() functions return -1 when a timeout occurs. Replace these with -ETIMEDOUT to use a proper errno value and better describe the error condition.

All callers check the return value as non-zero, so this change does not alter existing behavior.

---
 drivers/staging/sm750fb/sm750_hw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/sm750fb/sm750_hw.c +2 -2
index a2798d428663..3809401baa3a 100644
@@ -502,7 +502,7 @@ int hw_sm750le_de_wait(void)
 			return 0;
 	}
 	/* timeout error */
-	return -1;
+	return -ETIMEDOUT;
 }
 
 int hw_sm750_de_wait(void)
@@ -520,7 +520,7 @@ int hw_sm750_de_wait(void)
 			return 0;
 	}
 	/* timeout error */
-	return -1;
+	return -ETIMEDOUT;
 }
 
 int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/2] staging: sm750fb: return -ETIMEDOUT on timeout in de_wait functions

Quoted 26 lines · Hungyu Lin

The hw_sm750le_de_wait() and hw_sm750_de_wait() functions return -1 when a timeout occurs. Replace these with -ETIMEDOUT to use a proper errno value and better describe the error condition.

All callers check the return value as non-zero, so this change does not alter existing behavior.

---
 drivers/staging/sm750fb/sm750_hw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/sm750fb/sm750_hw.c +1 -1
index a2798d428663..3809401baa3a 100644
@@ -502,7 +502,7 @@ int hw_sm750le_de_wait(void)
 			return 0;
 	}
 	/* timeout error */
-	return -1;
+	return -ETIMEDOUT;
 }
 
 int hw_sm750_de_wait(void)

drivers/staging/sm750fb/sm750_hw.c int hw_sm750_de_wait(void) · line 523

Quoted 5 lines
drivers/staging/sm750fb/sm750_hw.c +1 -1
@@ -520,7 +520,7 @@ int hw_sm750_de_wait(void)
 			return 0;
 	}
 	/* timeout error */
-	return -1;
+	return -ETIMEDOUT;

The comment should be removed at the same time, now that the code itself documents it properly, right?

thanks,

greg k-h

author
#3 lore raw

PATCH v2 2/2 staging: sm750fb: propagate error codes from de_wait()

In reply to Hungyu Lin

The sm750 acceleration functions currently return -1 when de_wait() fails, discarding the original error code.

Since de_wait() now returns proper errno values, propagate the error code instead of returning -1.

---
 drivers/staging/sm750fb/sm750_accel.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/staging/sm750fb/sm750_accel.c +13 -7
index 0f94d859e91c..688ec262a8ed 100644
@@ -90,14 +90,16 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
 		      u32 color, u32 rop)
 {
 	u32 de_ctrl;
+	int ret;
 
-	if (accel->de_wait() != 0) {
+	ret = accel->de_wait();
+	if (ret) {
 		/*
-		 * int time wait and always busy,seems hardware
+		 * int time wait and always busy, seems hardware
 		 * got something error
 		 */
 		pr_debug("De engine always busy\n");
-		return -1;
+		return ret;
 	}
 
 	write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */
@@ -154,6 +156,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 		      unsigned int rop2)
 {
 	unsigned int direction, de_ctrl;
+	int ret;
 
 	direction = LEFT_TO_RIGHT;
 	/* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left */
@@ -263,8 +266,9 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 		   DE_WINDOW_WIDTH_DST_MASK) |
 		  (source_pitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */
 
-	if (accel->de_wait() != 0)
-		return -1;
+	ret = accel->de_wait();
+	if (ret)
+		return ret;
 
 	write_dpr(accel, DE_SOURCE,
 		  ((sx << DE_SOURCE_X_K1_SHIFT) & DE_SOURCE_X_K1_MASK) |
@@ -326,14 +330,16 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
 	unsigned int de_ctrl = 0;
 	unsigned char remain[4];
 	int i, j;
+	int ret;
 
 	start_bit &= 7; /* Just make sure the start bit is within legal range */
 	bytes_per_scan = (width + start_bit + 7) / 8;
 	words_per_scan = bytes_per_scan & ~3;
 	bytes_remain = bytes_per_scan & 3;
 
-	if (accel->de_wait() != 0)
-		return -1;
+	ret = accel->de_wait();
+	if (ret)
+		return ret;
 
 	/*
 	 * 2D Source Base.
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v2 2/2] staging: sm750fb: propagate error codes from de_wait()

Quoted 5 lines · Hungyu Lin

The sm750 acceleration functions currently return -1 when de_wait() fails, discarding the original error code.

Since de_wait() now returns proper errno values, propagate the error code instead of returning -1.

You can use the full 72 columns for a changelog text.

Quoted 12 lines
---
 drivers/staging/sm750fb/sm750_accel.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/staging/sm750fb/sm750_accel.c +0 -0
index 0f94d859e91c..688ec262a8ed 100644
@@ -90,14 +90,16 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
 		      u32 color, u32 rop)

drivers/staging/sm750fb/sm750_accel.c int sm750_hw_fillrect(struct lynx_accel *accel, · line 98

Quoted 10 lines
drivers/staging/sm750fb/sm750_accel.c +4 -2
 {
 	u32 de_ctrl;
+	int ret;
 
-	if (accel->de_wait() != 0) {
+	ret = accel->de_wait();
+	if (ret) {
 		/*
-		 * int time wait and always busy,seems hardware
+		 * int time wait and always busy, seems hardware

Nice fix, but not part of this change to make :(

thanks,

greg k-h