Skip to content

Commit 8bca214

Browse files
Finn Thainmartinkpetersen
authored andcommitted
scsi: esp_scsi: Eliminate ESP_FLAG_DOING_SLOWCMD
The concept of a 'slow command' as it appears in esp_scsi is confusing because it could refer to an ESP command or a SCSI command. It turns out that it refers to a particular ESP select command which the driver also tracks as 'ESP_SELECT_MSGOUT'. For readability, it is better to use the terminology from the datasheets. The global ESP_FLAG_DOING_SLOWCMD flag is redundant anyway, as it can be inferred from esp->select_state. Remove the ESP_FLAG_DOING_SLOWCMD cruft and just use a boolean local variable. Tested-by: Stan Johnson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Tested-by: Michael Schmitz <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 87c58ef commit 8bca214

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

drivers/scsi/esp_scsi.c

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,6 @@ static void esp_restore_pointers(struct esp *esp, struct esp_cmd_entry *ent)
482482
spriv->tot_residue = ent->saved_tot_residue;
483483
}
484484

485-
static void esp_check_command_len(struct esp *esp, struct scsi_cmnd *cmd)
486-
{
487-
if (cmd->cmd_len == 6 ||
488-
cmd->cmd_len == 10 ||
489-
cmd->cmd_len == 12) {
490-
esp->flags &= ~ESP_FLAG_DOING_SLOWCMD;
491-
} else {
492-
esp->flags |= ESP_FLAG_DOING_SLOWCMD;
493-
}
494-
}
495-
496485
static void esp_write_tgt_config3(struct esp *esp, int tgt)
497486
{
498487
if (esp->rev > ESP100A) {
@@ -739,6 +728,7 @@ static void esp_maybe_execute_command(struct esp *esp)
739728
struct scsi_device *dev;
740729
struct scsi_cmnd *cmd;
741730
struct esp_cmd_entry *ent;
731+
bool select_and_stop = false;
742732
int tgt, lun, i;
743733
u32 val, start_cmd;
744734
u8 *p;
@@ -769,7 +759,8 @@ static void esp_maybe_execute_command(struct esp *esp)
769759
esp_map_dma(esp, cmd);
770760
esp_save_pointers(esp, ent);
771761

772-
esp_check_command_len(esp, cmd);
762+
if (!(cmd->cmd_len == 6 || cmd->cmd_len == 10 || cmd->cmd_len == 12))
763+
select_and_stop = true;
773764

774765
p = esp->command_block;
775766

@@ -810,9 +801,9 @@ static void esp_maybe_execute_command(struct esp *esp)
810801
tp->flags &= ~ESP_TGT_CHECK_NEGO;
811802
}
812803

813-
/* Process it like a slow command. */
814-
if (tp->flags & (ESP_TGT_NEGO_WIDE | ESP_TGT_NEGO_SYNC))
815-
esp->flags |= ESP_FLAG_DOING_SLOWCMD;
804+
/* If there are multiple message bytes, use Select and Stop */
805+
if (esp->msg_out_len)
806+
select_and_stop = true;
816807
}
817808

818809
build_identify:
@@ -822,23 +813,10 @@ static void esp_maybe_execute_command(struct esp *esp)
822813
/* ESP100 lacks select w/atn3 command, use select
823814
* and stop instead.
824815
*/
825-
esp->flags |= ESP_FLAG_DOING_SLOWCMD;
816+
select_and_stop = true;
826817
}
827818

828-
if (!(esp->flags & ESP_FLAG_DOING_SLOWCMD)) {
829-
start_cmd = ESP_CMD_SELA;
830-
if (ent->tag[0]) {
831-
*p++ = ent->tag[0];
832-
*p++ = ent->tag[1];
833-
834-
start_cmd = ESP_CMD_SA3;
835-
}
836-
837-
for (i = 0; i < cmd->cmd_len; i++)
838-
*p++ = cmd->cmnd[i];
839-
840-
esp->select_state = ESP_SELECT_BASIC;
841-
} else {
819+
if (select_and_stop) {
842820
esp->cmd_bytes_left = cmd->cmd_len;
843821
esp->cmd_bytes_ptr = &cmd->cmnd[0];
844822

@@ -853,6 +831,19 @@ static void esp_maybe_execute_command(struct esp *esp)
853831

854832
start_cmd = ESP_CMD_SELAS;
855833
esp->select_state = ESP_SELECT_MSGOUT;
834+
} else {
835+
start_cmd = ESP_CMD_SELA;
836+
if (ent->tag[0]) {
837+
*p++ = ent->tag[0];
838+
*p++ = ent->tag[1];
839+
840+
start_cmd = ESP_CMD_SA3;
841+
}
842+
843+
for (i = 0; i < cmd->cmd_len; i++)
844+
*p++ = cmd->cmnd[i];
845+
846+
esp->select_state = ESP_SELECT_BASIC;
856847
}
857848
val = tgt;
858849
if (esp->rev == FASHME)
@@ -1260,7 +1251,6 @@ static int esp_finish_select(struct esp *esp)
12601251
esp_unmap_dma(esp, cmd);
12611252
esp_free_lun_tag(ent, cmd->device->hostdata);
12621253
tp->flags &= ~(ESP_TGT_NEGO_SYNC | ESP_TGT_NEGO_WIDE);
1263-
esp->flags &= ~ESP_FLAG_DOING_SLOWCMD;
12641254
esp->cmd_bytes_ptr = NULL;
12651255
esp->cmd_bytes_left = 0;
12661256
} else {
@@ -1308,9 +1298,8 @@ static int esp_finish_select(struct esp *esp)
13081298
esp_flush_fifo(esp);
13091299
}
13101300

1311-
/* If we are doing a slow command, negotiation, etc.
1312-
* we'll do the right thing as we transition to the
1313-
* next phase.
1301+
/* If we are doing a Select And Stop command, negotiation, etc.
1302+
* we'll do the right thing as we transition to the next phase.
13141303
*/
13151304
esp_event(esp, ESP_EVENT_CHECK_PHASE);
13161305
return 0;

drivers/scsi/esp_scsi.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ struct esp {
473473
u32 flags;
474474
#define ESP_FLAG_DIFFERENTIAL 0x00000001
475475
#define ESP_FLAG_RESETTING 0x00000002
476-
#define ESP_FLAG_DOING_SLOWCMD 0x00000004
477476
#define ESP_FLAG_WIDE_CAPABLE 0x00000008
478477
#define ESP_FLAG_QUICKIRQ_CHECK 0x00000010
479478
#define ESP_FLAG_DISABLE_SYNC 0x00000020
@@ -516,7 +515,7 @@ struct esp {
516515
u32 min_period;
517516
u32 radelay;
518517

519-
/* Slow command state. */
518+
/* ESP_CMD_SELAS command state */
520519
u8 *cmd_bytes_ptr;
521520
int cmd_bytes_left;
522521

0 commit comments

Comments
 (0)