@@ -1070,24 +1070,28 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt)
*/
static int aha152x_device_reset(struct scsi_cmnd * SCpnt)
{
- struct Scsi_Host *shpnt = SCpnt->device->host;
+ struct scsi_device *sdev = SCpnt->device;
+ struct Scsi_Host *shpnt = sdev->host;
DECLARE_COMPLETION(done);
int ret, issued, disconnected;
- unsigned char old_cmd_len = SCpnt->cmd_len;
+ unsigned char old_cmd_len;
unsigned long flags;
unsigned long timeleft;
- if(CURRENT_SC==SCpnt) {
- scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n");
- return FAILED;
- }
-
DO_LOCK(flags);
- issued = remove_SC(&ISSUE_SC, SCpnt) == NULL;
- disconnected = issued && remove_SC(&DISCONNECTED_SC, SCpnt);
+ /* Look for the stuck command */
+ SCpnt = remove_lun_SC(&ISSUE_SC, sdev->id, sdev->lun);
+ if (SCpnt)
+ issued = 1;
+ else
+ SCpnt = remove_lun_SC(&DISCONNECTED_SC, sdev->id, sdev->lun);
+ if (!issued && SCpnt)
+ disconnected = 1;
DO_UNLOCK(flags);
-
- SCpnt->cmd_len = 0;
+ if (!SCpnt)
+ return FAILED;
+ old_cmd_len = SCpnt->cmd_len;
+ SCpnt->cmd_len = 0;
aha152x_internal_queue(SCpnt, &done, resetting);