* [PATCH] staging: sm750fb: use proper error codes instead of -1 @ 2026-03-01 5:14 Soham Kute 2026-03-02 9:09 ` Dan Carpenter 0 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-01 5:14 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang, gregkh Cc: linux-fbdev, linux-staging, linux-kernel, Soham Kute Replace magic return value -1 with proper kernel error codes -EBUSY, -ETIMEDOUT and -EINVAL. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/ddk750_swi2c.c | 4 ++-- drivers/staging/sm750fb/sm750_accel.c | 6 +++--- drivers/staging/sm750fb/sm750_hw.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index 0ef8d4ff2ef9..d90a93ab8fdc 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -294,7 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) if (i < 0xff) return 0; else - return -1; + return -ETIMEDOUT; } /* @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) * range is only from [0..63] */ if ((clk_gpio > 31) || (data_gpio > 31)) - return -1; + return -EINVAL; if (sm750_get_chip_type() == SM750LE) return sm750le_i2c_init(clk_gpio, data_gpio); diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 046b9282b24a..fa593d4f31fe 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -97,7 +97,7 @@ int sm750_hw_fillrect(struct lynx_accel *accel, * got something error */ pr_debug("De engine always busy\n"); - return -1; + return -EBUSY; } write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */ @@ -264,7 +264,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, (sPitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */ if (accel->de_wait() != 0) - return -1; + return -EBUSY; write_dpr(accel, DE_SOURCE, ((sx << DE_SOURCE_X_K1_SHIFT) & DE_SOURCE_X_K1_MASK) | @@ -333,7 +333,7 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *pSrcbuf, ulBytesRemain = ulBytesPerScan & 3; if (accel->de_wait() != 0) - return -1; + return -EBUSY; /* * 2D Source Base. diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index ce46f240cbaf..e4b6b254335e 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -518,7 +518,7 @@ int hw_sm750le_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_de_wait(void) @@ -536,7 +536,7 @@ int hw_sm750_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_pan_display(struct lynxfb_crtc *crtc, -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH] staging: sm750fb: use proper error codes instead of -1 2026-03-01 5:14 [PATCH] staging: sm750fb: use proper error codes instead of -1 Soham Kute @ 2026-03-02 9:09 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 0 siblings, 2 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-02 9:09 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Sun, Mar 01, 2026 at 10:44:34AM +0530, Soham Kute wrote: > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > index 0ef8d4ff2ef9..d90a93ab8fdc 100644 > --- a/drivers/staging/sm750fb/ddk750_swi2c.c > +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > @@ -294,7 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) > if (i < 0xff) > return 0; > else > - return -1; > + return -ETIMEDOUT; The comment still says this returns -1. Actually could you do this one function at a time, and in each commit message please say "The callers propogate the error code back" or " None of the callers check the error code" or "The callers treat all non-zero error codes as failure and return -EINVAL" or whatever. > @@ -264,7 +264,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, > (sPitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */ > > if (accel->de_wait() != 0) Did you consider propagating the error code from accel->de_wait() instead? That feels like a better solution but I haven't looked at it at all. regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 0/6] staging: sm750fb: fix error return values 2026-03-02 9:09 ` Dan Carpenter @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 8:45 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute ` (5 more replies) 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 1 sibling, 6 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute This is v2 of the sm750fb error code fixes, split into one patch per function as requested by Dan Carpenter. Changes in v2: - Split into one patch per function - Propagate de_wait() error instead of hardcoding -EBUSY - Each commit message describes caller behavior Soham Kute (6): 11ca38f0ec63 staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout 28df828cc89b staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error 2378ece78154 staging: sm750fb: sm750_hw_copyarea: propagate de_wait() error 85139ac8c7fe staging: sm750fb: sm750_hw_imageblit: propagate de_wait() error 9c2430311e23 staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout 915599b01e9b staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 8:45 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute ` (4 subsequent siblings) 5 siblings, 0 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -ETIMEDOUT instead of -1 when the DE engine poll loop times out. The callers check for non-zero return value and propagate the error code back to their callers. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index ce46f240cbaf..e4b6b254335e 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -518,7 +518,7 @@ int hw_sm750le_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_de_wait(void) @@ -536,7 +536,7 @@ int hw_sm750_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_pan_display(struct lynxfb_crtc *crtc, -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute 2026-03-04 8:45 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 8:45 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute ` (3 subsequent siblings) 5 siblings, 0 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller treats all non-zero return values as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 046b9282b24a..1bd0502db039 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -90,14 +90,12 @@ int sm750_hw_fillrect(struct lynx_accel *accel, u32 color, u32 rop) { u32 de_ctrl; + int ret; - if (accel->de_wait() != 0) { - /* - * int time wait and always busy,seems hardware - * got something error - */ + ret = accel->de_wait(); + if (ret) { pr_debug("De engine always busy\n"); - return -1; + return ret; } write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */ -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: propagate de_wait() error 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute 2026-03-04 8:45 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 8:45 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 14:24 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute ` (2 subsequent siblings) 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller treats all non-zero return values as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 1bd0502db039..f2fde011e7ca 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -152,6 +152,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, unsigned int rop2) { unsigned int nDirection, de_ctrl; + int ret; nDirection = LEFT_TO_RIGHT; /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left */ @@ -261,8 +262,9 @@ int sm750_hw_copyarea(struct lynx_accel *accel, DE_WINDOW_WIDTH_DST_MASK) | (sPitch / 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) | -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: propagate de_wait() error 2026-03-04 8:45 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute @ 2026-03-04 14:24 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-04 14:24 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 02:15:42PM +0530, Soham Kute wrote: > Propagate the error from accel->de_wait() instead of returning -1. > The caller treats all non-zero return values as failure. > The caller just ignores errors. regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: propagate de_wait() error 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute ` (2 preceding siblings ...) 2026-03-04 8:45 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 14:25 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 8:45 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller treats all non-zero return values as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index f2fde011e7ca..7d11810864ae 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -325,15 +325,16 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *pSrcbuf, unsigned int ulBytesRemain; unsigned int de_ctrl = 0; unsigned char ajRemain[4]; - int i, j; + int i, j, ret; startBit &= 7; /* Just make sure the start bit is within legal range */ ulBytesPerScan = (width + startBit + 7) / 8; ul4BytesPerScan = ulBytesPerScan & ~3; ulBytesRemain = ulBytesPerScan & 3; - if (accel->de_wait() != 0) - return -1; + ret = accel->de_wait(); + if (ret) + return ret; /* * 2D Source Base. -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: propagate de_wait() error 2026-03-04 8:45 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute @ 2026-03-04 14:25 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-04 14:25 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 02:15:43PM +0530, Soham Kute wrote: > Propagate the error from accel->de_wait() instead of returning -1. > The caller treats all non-zero return values as failure. The caller ignores errors. regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute ` (3 preceding siblings ...) 2026-03-04 8:45 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 14:29 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -ETIMEDOUT instead of -1 when the I2C byte write times out. The callers check for non-zero return value and treat it as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index 0ef8d4ff2ef9..a17f758dda6c 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -294,7 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) if (i < 0xff) return 0; else - return -1; + return -ETIMEDOUT; } /* -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout 2026-03-04 8:45 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout Soham Kute @ 2026-03-04 14:29 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-04 14:29 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 02:15:44PM +0530, Soham Kute wrote: > Return -ETIMEDOUT instead of -1 when the I2C byte write times out. > The callers check for non-zero return value and treat it as failure. > "The callers either ignore errors or treat all non-zero returns as failure and return -1." > Signed-off-by: Soham Kute <officialsohamkute@gmail.com> > --- > drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > index 0ef8d4ff2ef9..a17f758dda6c 100644 > --- a/drivers/staging/sm750fb/ddk750_swi2c.c > +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > @@ -294,7 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) Need to update the comments at the start of the function as well. 234 /* 235 * This function writes one byte to the slave device 236 * 237 * Parameters: 238 * data - Data to be write to the slave device 239 * 240 * Return Value: 241 * 0 - Success 242 * -1 - Fail to write byte ^^^^^^^^^^^^^^^^^^^^^^^^^ 243 */ 244 static long sw_i2c_write_byte(unsigned char data) > if (i < 0xff) > return 0; > else > - return -1; > + return -ETIMEDOUT; I don't think -ETIMEDOUT is the correct error code. Maybe -EIO or -EINVAL. regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute ` (4 preceding siblings ...) 2026-03-04 8:45 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout Soham Kute @ 2026-03-04 8:45 ` Soham Kute 2026-03-04 14:30 ` Dan Carpenter 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 8:45 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -EINVAL instead of -1 when the GPIO pin number is out of range. The caller checks for non-zero return value as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index a17f758dda6c..d90a93ab8fdc 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) * range is only from [0..63] */ if ((clk_gpio > 31) || (data_gpio > 31)) - return -1; + return -EINVAL; if (sm750_get_chip_type() == SM750LE) return sm750le_i2c_init(clk_gpio, data_gpio); -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO 2026-03-04 8:45 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute @ 2026-03-04 14:30 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-04 14:30 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 02:15:45PM +0530, Soham Kute wrote: > Return -EINVAL instead of -1 when the GPIO pin number is out of > range. The caller checks for non-zero return value as failure. > The caller ignores errors. > Signed-off-by: Soham Kute <officialsohamkute@gmail.com> > --- > drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > index a17f758dda6c..d90a93ab8fdc 100644 > --- a/drivers/staging/sm750fb/ddk750_swi2c.c > +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) > * range is only from [0..63] > */ > if ((clk_gpio > 31) || (data_gpio > 31)) > - return -1; > + return -EINVAL; Need to update the comments for the function. regards, dan carpenter > > if (sm750_get_chip_type() == SM750LE) > return sm750le_i2c_init(clk_gpio, data_gpio); > -- > 2.34.1 ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout 2026-03-02 9:09 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-04 17:35 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute ` (5 more replies) 1 sibling, 6 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -ETIMEDOUT instead of -1 when the DE engine poll loop times out. The callers check for non-zero return value and propagate the error code back to their callers. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index ce46f240cbaf..e4b6b254335e 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -518,7 +518,7 @@ int hw_sm750le_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_de_wait(void) @@ -536,7 +536,7 @@ int hw_sm750_de_wait(void) return 0; } /* timeout error */ - return -1; + return -ETIMEDOUT; } int hw_sm750_pan_display(struct lynxfb_crtc *crtc, -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-05 5:34 ` Dan Carpenter 2026-03-04 17:35 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute ` (4 subsequent siblings) 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller treats all non-zero return values as failure. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 046b9282b24a..1bd0502db039 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -90,14 +90,12 @@ int sm750_hw_fillrect(struct lynx_accel *accel, u32 color, u32 rop) { u32 de_ctrl; + int ret; - if (accel->de_wait() != 0) { - /* - * int time wait and always busy,seems hardware - * got something error - */ + ret = accel->de_wait(); + if (ret) { pr_debug("De engine always busy\n"); - return -1; + return ret; } write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */ -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error 2026-03-04 17:35 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute @ 2026-03-05 5:34 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-05 5:34 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 11:05:25PM +0530, Soham Kute wrote: > Propagate the error from accel->de_wait() instead of returning -1. > The caller treats all non-zero return values as failure. No, the caller just ignores the errors. regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: propagate de_wait() error 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 17:35 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-04 17:35 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute ` (3 subsequent siblings) 5 siblings, 0 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller ignores the return value. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 1bd0502db039..f2fde011e7ca 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -152,6 +152,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, unsigned int rop2) { unsigned int nDirection, de_ctrl; + int ret; nDirection = LEFT_TO_RIGHT; /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left */ @@ -261,8 +262,9 @@ int sm750_hw_copyarea(struct lynx_accel *accel, DE_WINDOW_WIDTH_DST_MASK) | (sPitch / 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) | -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: propagate de_wait() error 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 17:35 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute 2026-03-04 17:35 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-04 17:35 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -EIO on failure Soham Kute ` (2 subsequent siblings) 5 siblings, 0 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Propagate the error from accel->de_wait() instead of returning -1. The caller ignores the return value. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/sm750_accel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index f2fde011e7ca..7d11810864ae 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -325,15 +325,16 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *pSrcbuf, unsigned int ulBytesRemain; unsigned int de_ctrl = 0; unsigned char ajRemain[4]; - int i, j; + int i, j, ret; startBit &= 7; /* Just make sure the start bit is within legal range */ ulBytesPerScan = (width + startBit + 7) / 8; ul4BytesPerScan = ulBytesPerScan & ~3; ulBytesRemain = ulBytesPerScan & 3; - if (accel->de_wait() != 0) - return -1; + ret = accel->de_wait(); + if (ret) + return ret; /* * 2D Source Base. -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -EIO on failure 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute ` (2 preceding siblings ...) 2026-03-04 17:35 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-04 17:35 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute 2026-03-05 5:33 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Dan Carpenter 5 siblings, 0 replies; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -EIO instead of -1 when the I2C byte write fails. The caller ignores the return value. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/ddk750_swi2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index 0ef8d4ff2ef9..c73943341f66 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -239,7 +239,7 @@ static void sw_i2c_stop(void) * * Return Value: * 0 - Success - * -1 - Fail to write byte + * -EIO - Fail to write byte */ static long sw_i2c_write_byte(unsigned char data) { @@ -294,7 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) if (i < 0xff) return 0; else - return -1; + return -EIO; } /* -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute ` (3 preceding siblings ...) 2026-03-04 17:35 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -EIO on failure Soham Kute @ 2026-03-04 17:35 ` Soham Kute 2026-03-05 5:48 ` Dan Carpenter 2026-03-05 5:33 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Dan Carpenter 5 siblings, 1 reply; 22+ messages in thread From: Soham Kute @ 2026-03-04 17:35 UTC (permalink / raw) To: sudipm.mukherjee, teddy.wang Cc: gregkh, linux-fbdev, linux-staging, linux-kernel, dan.carpenter, Soham Kute Return -EINVAL instead of -1 when the GPIO pin number is out of range. The caller ignores the return value. Signed-off-by: Soham Kute <officialsohamkute@gmail.com> --- drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index c73943341f66..46599be8d6b9 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -344,7 +344,7 @@ static unsigned char sw_i2c_read_byte(unsigned char ack) * data_gpio - The GPIO pin to be used as i2c SDA * * Return Value: - * -1 - Fail to initialize the i2c + * -EINVAL - Fail to initialize the i2c * 0 - Success */ static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) @@ -382,7 +382,7 @@ static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) * data_gpio - The GPIO pin to be used as i2c SDA * * Return Value: - * -1 - Fail to initialize the i2c + * -EINVAL - Fail to initialize the i2c * 0 - Success */ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) * range is only from [0..63] */ if ((clk_gpio > 31) || (data_gpio > 31)) - return -1; + return -EINVAL; if (sm750_get_chip_type() == SM750LE) return sm750le_i2c_init(clk_gpio, data_gpio); -- 2.34.1 ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO 2026-03-04 17:35 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute @ 2026-03-05 5:48 ` Dan Carpenter 0 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-05 5:48 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 11:05:29PM +0530, Soham Kute wrote: > Return -EINVAL instead of -1 when the GPIO pin number is out of > range. The caller ignores the return value. > > Signed-off-by: Soham Kute <officialsohamkute@gmail.com> > --- > drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > index c73943341f66..46599be8d6b9 100644 > --- a/drivers/staging/sm750fb/ddk750_swi2c.c > +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > @@ -344,7 +344,7 @@ static unsigned char sw_i2c_read_byte(unsigned char ack) > * data_gpio - The GPIO pin to be used as i2c SDA > * > * Return Value: > - * -1 - Fail to initialize the i2c > + * -EINVAL - Fail to initialize the i2c > * 0 - Success > */ > static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) This part needs to be done in the patch that changes sw_i2c_read_byte(). regards, dan carpenter > @@ -382,7 +382,7 @@ static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) > * data_gpio - The GPIO pin to be used as i2c SDA > * > * Return Value: > - * -1 - Fail to initialize the i2c > + * -EINVAL - Fail to initialize the i2c > * 0 - Success > */ > long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) > @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio) > * range is only from [0..63] > */ > if ((clk_gpio > 31) || (data_gpio > 31)) > - return -1; > + return -EINVAL; > > if (sm750_get_chip_type() == SM750LE) > return sm750le_i2c_init(clk_gpio, data_gpio); > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute ` (4 preceding siblings ...) 2026-03-04 17:35 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute @ 2026-03-05 5:33 ` Dan Carpenter 5 siblings, 0 replies; 22+ messages in thread From: Dan Carpenter @ 2026-03-05 5:33 UTC (permalink / raw) To: Soham Kute Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging, linux-kernel On Wed, Mar 04, 2026 at 11:05:24PM +0530, Soham Kute wrote: > Return -ETIMEDOUT instead of -1 when the DE engine poll loop > times out. The callers check for non-zero return value and > propagate the error code back to their callers. > They don't propagate the error back. The callers do: drivers/staging/sm750fb/sm750_accel.c 87 int sm750_hw_fillrect(struct lynx_accel *accel, 88 u32 base, u32 pitch, u32 Bpp, 89 u32 x, u32 y, u32 width, u32 height, 90 u32 color, u32 rop) 91 { 92 u32 de_ctrl; 93 94 if (accel->de_wait() != 0) { 95 /* 96 * int time wait and always busy,seems hardware 97 * got something error 98 */ 99 pr_debug("De engine always busy\n"); 100 return -1; 101 } They return -1. Propagating the errors means: ret = accel->de_wait(); if (ret) return ret; Also this is a v3 patch, it needs v3 in the subject and a little description of what changed. https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/ regards, dan carpenter ^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2026-03-05 5:48 UTC | newest] Thread overview: 22+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-01 5:14 [PATCH] staging: sm750fb: use proper error codes instead of -1 Soham Kute 2026-03-02 9:09 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH v2 0/6] staging: sm750fb: fix error return values Soham Kute 2026-03-04 8:45 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 8:45 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute 2026-03-04 8:45 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute 2026-03-04 14:24 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute 2026-03-04 14:25 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 14:29 ` Dan Carpenter 2026-03-04 8:45 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute 2026-03-04 14:30 ` Dan Carpenter 2026-03-04 17:35 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Soham Kute 2026-03-04 17:35 ` [PATCH 2/6] staging: sm750fb: sm750_hw_fillrect: propagate de_wait() error Soham Kute 2026-03-05 5:34 ` Dan Carpenter 2026-03-04 17:35 ` [PATCH 3/6] staging: sm750fb: sm750_hw_copyarea: " Soham Kute 2026-03-04 17:35 ` [PATCH 4/6] staging: sm750fb: sm750_hw_imageblit: " Soham Kute 2026-03-04 17:35 ` [PATCH 5/6] staging: sm750fb: sw_i2c_write_byte: return -EIO on failure Soham Kute 2026-03-04 17:35 ` [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO Soham Kute 2026-03-05 5:48 ` Dan Carpenter 2026-03-05 5:33 ` [PATCH 1/6] staging: sm750fb: hw_sm750le_de_wait: return -ETIMEDOUT on timeout Dan Carpenter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox