[PATCH] staging: gpib: Change return type and error code of fluke_get_dma_residue

Everest K.C. posted 1 patch 1 month, 1 week ago
There is a newer version of this series
drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] staging: gpib: Change return type and error code of fluke_get_dma_residue
Posted by Everest K.C. 1 month, 1 week ago
fluke_get_dma_residue() returns unsigned int with -1 as error code.
This error cannot be caught.
Fix this by changing the return type of the function to int and 
returning the error code, that was captured.

Fixes: 55936779f496 ("staging: gpib: Add Fluke cda based cards GPIB driver")
Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
 drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index f9f149db222d..54fdbef20d84 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
 	return 0;
 }
 
-static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
+static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
 {
 	struct dma_tx_state state;
 	int result;
@@ -544,7 +544,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
 	result = dmaengine_pause(chan);
 	if (result < 0) {
 		pr_err("fluke_gpib: dma pause failed?\n");
-		return -1;
+		return result;
 	}
 	dmaengine_tx_status(chan, cookie, &state);
 	// hardware doesn't support resume, so dont call this
-- 
2.43.0
Re: [PATCH] staging: gpib: Change return type and error code of fluke_get_dma_residue
Posted by Dan Carpenter 1 month, 1 week ago
On Thu, Oct 17, 2024 at 02:20:22AM -0600, Everest K.C. wrote:
> fluke_get_dma_residue() returns unsigned int with -1 as error code.
> This error cannot be caught.
> Fix this by changing the return type of the function to int and 
> returning the error code, that was captured.
> 
> Fixes: 55936779f496 ("staging: gpib: Add Fluke cda based cards GPIB driver")
> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> ---

So like quite often we would merge a patch like this, because there's nothing
wrong with it and why not?  It's a step in the right direction.  But actually
in this case could you fix the caller as well?

Do it all in the same patch.  It's the one *whole* thing per patch rule.

regards,
dan carpenter
Re: [PATCH] staging: gpib: Change return type and error code of fluke_get_dma_residue
Posted by Everest K.C. 1 month, 1 week ago
On Thu, Oct 17, 2024 at 3:01 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> On Thu, Oct 17, 2024 at 02:20:22AM -0600, Everest K.C. wrote:
> > fluke_get_dma_residue() returns unsigned int with -1 as error code.
> > This error cannot be caught.
> > Fix this by changing the return type of the function to int and
> > returning the error code, that was captured.
> >
> > Fixes: 55936779f496 ("staging: gpib: Add Fluke cda based cards GPIB driver")
> > Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> > ---
>
> So like quite often we would merge a patch like this, because there's nothing
> wrong with it and why not?  It's a step in the right direction.  But actually
> in this case could you fix the caller as well?
I feel so dumb that I missed it. V2 is on the way.
> Do it all in the same patch.  It's the one *whole* thing per patch rule.
Noted.
> regards,
> dan carpenter
>
Thanks,
Everest K.C.