Lines Matching refs:cmd
748 static inline int imm_send_command(Scsi_Cmnd * cmd) in imm_send_command() argument
750 int host_no = cmd->host->unique_id; in imm_send_command()
754 for (k = 0; k < cmd->cmd_len; k += 2) in imm_send_command()
755 if (!imm_out(host_no, &cmd->cmnd[k], 2)) in imm_send_command()
768 static int imm_completion(Scsi_Cmnd * cmd) in imm_completion() argument
775 int host_no = cmd->host->unique_id; in imm_completion()
782 v = cmd->cmnd[0]; in imm_completion()
812 if (((r & 0x88) != 0x88) || (cmd->SCp.this_residual <= 0)) { in imm_completion()
818 fast = (bulk && (cmd->SCp.this_residual >= IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 2; in imm_completion()
819 status = imm_out(host_no, cmd->SCp.ptr, fast); in imm_completion()
821 fast = (bulk && (cmd->SCp.this_residual >= IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 1; in imm_completion()
822 status = imm_in(host_no, cmd->SCp.ptr, fast); in imm_completion()
825 cmd->SCp.ptr += fast; in imm_completion()
826 cmd->SCp.this_residual -= fast; in imm_completion()
832 if (cmd->SCp.buffer && !cmd->SCp.this_residual) { in imm_completion()
834 if (cmd->SCp.buffers_residual--) { in imm_completion()
835 cmd->SCp.buffer++; in imm_completion()
836 cmd->SCp.this_residual = cmd->SCp.buffer->length; in imm_completion()
837 cmd->SCp.ptr = cmd->SCp.buffer->address; in imm_completion()
843 if (cmd->SCp.this_residual & 0x01) in imm_completion()
844 cmd->SCp.this_residual++; in imm_completion()
859 int imm_command(Scsi_Cmnd * cmd) in imm_command() argument
862 int host_no = cmd->host->unique_id; in imm_command()
874 imm_hosts[host_no].cur_cmd = cmd; in imm_command()
875 cmd->result = DID_ERROR << 16; /* default return code */ in imm_command()
876 cmd->SCp.phase = 0; in imm_command()
880 while (imm_engine(&imm_hosts[host_no], cmd)) in imm_command()
883 if (cmd->SCp.phase) /* Only disconnect if we have connected */ in imm_command()
884 imm_disconnect(cmd->host->unique_id); in imm_command()
888 return cmd->result; in imm_command()
899 Scsi_Cmnd *cmd = tmp->cur_cmd; in imm_interrupt() local
902 if (!cmd) { in imm_interrupt()
906 if (imm_engine(tmp, cmd)) { in imm_interrupt()
914 switch ((cmd->result >> 16) & 0xff) { in imm_interrupt()
918 printk("imm: no device at SCSI ID %i\n", cmd->target); in imm_interrupt()
942 printk("imm: bad return code (%02x)\n", (cmd->result >> 16) & 0xff); in imm_interrupt()
946 if (cmd->SCp.phase > 1) in imm_interrupt()
947 imm_disconnect(cmd->host->unique_id); in imm_interrupt()
948 if (cmd->SCp.phase > 0) in imm_interrupt()
949 imm_pb_release(cmd->host->unique_id); in imm_interrupt()
953 cmd->scsi_done(cmd); in imm_interrupt()
958 static int imm_engine(imm_struct * tmp, Scsi_Cmnd * cmd) in imm_engine() argument
960 int host_no = cmd->host->unique_id; in imm_engine()
971 switch (cmd->SCp.phase) { in imm_engine()
985 cmd->SCp.phase++; in imm_engine()
989 if (!imm_select(host_no, cmd->target)) { in imm_engine()
993 cmd->SCp.phase++; in imm_engine()
1001 if (!imm_send_command(cmd)) in imm_engine()
1003 cmd->SCp.phase++; in imm_engine()
1007 if (cmd->use_sg) { in imm_engine()
1009 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; in imm_engine()
1010 cmd->SCp.this_residual = cmd->SCp.buffer->length; in imm_engine()
1011 cmd->SCp.ptr = cmd->SCp.buffer->address; in imm_engine()
1014 cmd->SCp.buffer = NULL; in imm_engine()
1015 cmd->SCp.this_residual = cmd->request_bufflen; in imm_engine()
1016 cmd->SCp.ptr = cmd->request_buffer; in imm_engine()
1018 cmd->SCp.buffers_residual = cmd->use_sg; in imm_engine()
1019 cmd->SCp.phase++; in imm_engine()
1020 if (cmd->SCp.this_residual & 0x01) in imm_engine()
1021 cmd->SCp.this_residual++; in imm_engine()
1037 cmd->SCp.phase++; in imm_engine()
1047 retv = imm_completion(cmd); in imm_engine()
1053 cmd->SCp.phase++; in imm_engine()
1065 cmd->SCp.phase++; in imm_engine()
1080 cmd->result = (DID_OK << 16) + (l & STATUS_MASK); in imm_engine()
1097 int imm_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) in imm_queuecommand() argument
1099 int host_no = cmd->host->unique_id; in imm_queuecommand()
1107 imm_hosts[host_no].cur_cmd = cmd; in imm_queuecommand()
1108 cmd->scsi_done = done; in imm_queuecommand()
1109 cmd->result = DID_ERROR << 16; /* default return code */ in imm_queuecommand()
1110 cmd->SCp.phase = 0; /* bus free */ in imm_queuecommand()
1141 int imm_abort(Scsi_Cmnd * cmd) in imm_abort() argument
1143 int host_no = cmd->host->unique_id; in imm_abort()
1149 switch (cmd->SCp.phase) { in imm_abort()
1173 int imm_reset(Scsi_Cmnd * cmd) in imm_reset() argument
1175 int host_no = cmd->host->unique_id; in imm_reset()
1177 if (cmd->SCp.phase) in imm_reset()
1194 static char cmd[6] = in device_check() local
1219 status = imm_out(host_no, &cmd[l << 1], 2); in device_check()