Skip to content

Commit 350767f

Browse files
Finn Thainmartinkpetersen
authored andcommitted
scsi: NCR5380: Call scsi_set_resid() on command completion
Most NCR5380 drivers calculate the residual for every data transfer. (A few drivers just set it to zero.) Pass this quantity back to the scsi mid-layer on command completion. Cc: Michael Schmitz <[email protected]> Cc: Ondrej Zary <[email protected]> Link: https://lore.kernel.org/r/1f26ead9dd0dc053fcd27979d69a7ca74b6589b4.1573875417.git.fthain@telegraphics.com.au Reviewed-and-tested-by: Michael Schmitz <[email protected]> Tested-by: Ondrej Zary <[email protected]> Signed-off-by: Finn Thain <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent aa5334c commit 350767f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/scsi/NCR5380.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ static inline void advance_sg_buffer(struct scsi_cmnd *cmd)
172172
}
173173
}
174174

175+
static inline void set_resid_from_SCp(struct scsi_cmnd *cmd)
176+
{
177+
int resid = cmd->SCp.this_residual;
178+
struct scatterlist *s = cmd->SCp.buffer;
179+
180+
if (s)
181+
while (!sg_is_last(s)) {
182+
s = sg_next(s);
183+
resid += s->length;
184+
}
185+
scsi_set_resid(cmd, resid);
186+
}
187+
175188
/**
176189
* NCR5380_poll_politely2 - wait for two chip register values
177190
* @hostdata: host private data
@@ -1803,6 +1816,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
18031816
cmd->result |= cmd->SCp.Status;
18041817
cmd->result |= cmd->SCp.Message << 8;
18051818

1819+
set_resid_from_SCp(cmd);
1820+
18061821
if (cmd->cmnd[0] == REQUEST_SENSE)
18071822
complete_cmd(instance, cmd);
18081823
else {

0 commit comments

Comments
 (0)