More correctly handle residuals according to the guidelines.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1944 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Richard Sharpe
2010-08-09 14:48:20 +00:00
parent c45aa9a60f
commit f9eda93575
+13 -13
View File
@@ -1182,26 +1182,26 @@ static int scst_local_targ_xmit_response(struct scst_cmd *scst_cmd)
* This might have to change to use the two status flags * This might have to change to use the two status flags
*/ */
if (scst_cmd_get_is_send_status(scst_cmd)) { if (scst_cmd_get_is_send_status(scst_cmd)) {
int resid = 0; int resid = 0, out_resid = 0;
/* /*
* Calculate the residual ... * Calculate the residual ...
*/ */
switch (tgt_specific->cmnd->sc_data_direction) { if (likely(!scst_get_resid(scst_cmd, &resid, &out_resid))) {
case DMA_TO_DEVICE: TRACE_DBG("No residuals for request %p",
resid = (signed)scst_cmd_get_bufflen(scst_cmd) - tgt_specific->cmnd);
scsi_bufflen(tgt_specific->cmnd); } else {
break; if (out_resid != 0)
case DMA_FROM_DEVICE: PRINT_ERROR("Unable to return OUT residual %d "
resid = (signed)scsi_bufflen(tgt_specific->cmnd) - "(op %02x)", out_resid,
scst_cmd_get_resp_data_len(scst_cmd); tgt_specific->cmnd->cmnd[0]);
break;
default:
resid = 0;
break;
} }
scsi_set_resid(tgt_specific->cmnd, resid); scsi_set_resid(tgt_specific->cmnd, resid);
/*
* It seems like there is no way to set out_resid ...
*/
(void)scst_local_send_resp(tgt_specific->cmnd, scst_cmd, (void)scst_local_send_resp(tgt_specific->cmnd, scst_cmd,
tgt_specific->done, tgt_specific->done,
scst_cmd_get_status(scst_cmd)); scst_cmd_get_status(scst_cmd));