Skip to contentSkip to conversation

staging: gpib: Change return type of fluke_get_dma_residue

PATCH In review Kees Bakker 2 participants 3 messages Oct 17, 2024 – Oct 19, 2024 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: gpib: Change return type of fluke_get_dma_residue

The function fluke_get_dma_residue returns an error as a negative value. So the return type must not be unsigned.

---
 drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/gpib/eastwood/fluke_gpib.c +2 -2
index f9f149db222d..77bbe2b587b1 100644
@@ -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;
@@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
 	dmaengine_tx_status(chan, cookie, &state);
 	// hardware doesn't support resume, so dont call this
 	// method unless the dma transfer is done.
-	return state.residue;
+	return (int)state.residue;
 }
 
 static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
Signature · 1 line
2.47.0
maintainer
#1 lore raw
Quoted 22 lines · Kees Bakker

The function fluke_get_dma_residue returns an error as a negative value. So the return type must not be unsigned.

---
 drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/gpib/eastwood/fluke_gpib.c +1 -1
index f9f149db222d..77bbe2b587b1 100644
@@ -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;

drivers/staging/gpib/eastwood/fluke_gpib.c static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co · line 552

Quoted 5 lines
drivers/staging/gpib/eastwood/fluke_gpib.c +1 -1
@@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
 	dmaengine_tx_status(chan, cookie, &state);
 	// hardware doesn't support resume, so dont call this
 	// method unless the dma transfer is done.
-	return state.residue;
+	return (int)state.residue;

Then why isn't residue an int? Shouldn't that be also changed?

thanks,

greg k-h

#2 lore raw

Op 19-10-2024 om 09:59 schreef Greg KH:

Quoted 17 lines · Kees Bakker
Quoted 16 lines

The function fluke_get_dma_residue returns an error as a negative value. So the return type must not be unsigned.

---
  drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/gpib/eastwood/fluke_gpib.c +0 -0
index f9f149db222d..77bbe2b587b1 100644
@@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
  	return 0;
  }
 
Quoted 12 lines

drivers/staging/gpib/eastwood/fluke_gpib.c static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co · line 552

Quoted 11 lines
drivers/staging/gpib/eastwood/fluke_gpib.c +2 -2
-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;
@@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
  	dmaengine_tx_status(chan, cookie, &state);
  	// hardware doesn't support resume, so dont call this
  	// method unless the dma transfer is done.
-	return state.residue;
+	return (int)state.residue;

Then why isn't residue an int? Shouldn't that be also changed?

Good catch. I need to resend a patch.

Quoted 4 lines

thanks,

greg k-h