Commit 624f6025 authored by Finn Thain's avatar Finn Thain Committed by Greg Kroah-Hartman

scsi: NCR5380: Have NCR5380_select() return a bool

[ Upstream commit dad8261e ]

The return value is taken to mean "retry" or "don't retry". Change it to bool
to improve readability. Fix related comments. No functional change.
Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 873506e5
...@@ -904,20 +904,16 @@ static irqreturn_t __maybe_unused NCR5380_intr(int irq, void *dev_id) ...@@ -904,20 +904,16 @@ static irqreturn_t __maybe_unused NCR5380_intr(int irq, void *dev_id)
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
/* /**
* Function : int NCR5380_select(struct Scsi_Host *instance, * NCR5380_select - attempt arbitration and selection for a given command
* struct scsi_cmnd *cmd) * @instance: the Scsi_Host instance
* * @cmd: the scsi_cmnd to execute
* Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
* including ARBITRATION, SELECTION, and initial message out for
* IDENTIFY and queue messages.
* *
* Inputs : instance - instantiation of the 5380 driver on which this * This routine establishes an I_T_L nexus for a SCSI command. This involves
* target lives, cmd - SCSI command to execute. * ARBITRATION, SELECTION and MESSAGE OUT phases and an IDENTIFY message.
* *
* Returns cmd if selection failed but should be retried, * Returns true if the operation should be retried.
* NULL if selection failed and should not be retried, or * Returns false if it should not be retried.
* NULL if selection succeeded (hostdata->connected == cmd).
* *
* Side effects : * Side effects :
* If bus busy, arbitration failed, etc, NCR5380_select() will exit * If bus busy, arbitration failed, etc, NCR5380_select() will exit
...@@ -925,16 +921,15 @@ static irqreturn_t __maybe_unused NCR5380_intr(int irq, void *dev_id) ...@@ -925,16 +921,15 @@ static irqreturn_t __maybe_unused NCR5380_intr(int irq, void *dev_id)
* SELECT_ENABLE will be set appropriately, the NCR5380 * SELECT_ENABLE will be set appropriately, the NCR5380
* will cease to drive any SCSI bus signals. * will cease to drive any SCSI bus signals.
* *
* If successful : I_T_L or I_T_L_Q nexus will be established, * If successful : the I_T_L nexus will be established, and
* instance->connected will be set to cmd. * hostdata->connected will be set to cmd.
* SELECT interrupt will be disabled. * SELECT interrupt will be disabled.
* *
* If failed (no target) : cmd->scsi_done() will be called, and the * If failed (no target) : cmd->scsi_done() will be called, and the
* cmd->result host byte set to DID_BAD_TARGET. * cmd->result host byte set to DID_BAD_TARGET.
*/ */
static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
struct scsi_cmnd *cmd)
__releases(&hostdata->lock) __acquires(&hostdata->lock) __releases(&hostdata->lock) __acquires(&hostdata->lock)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
...@@ -942,6 +937,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -942,6 +937,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
unsigned char *data; unsigned char *data;
int len; int len;
int err; int err;
bool ret = true;
NCR5380_dprint(NDEBUG_ARBITRATION, instance); NCR5380_dprint(NDEBUG_ARBITRATION, instance);
dsprintk(NDEBUG_ARBITRATION, instance, "starting arbitration, id = %d\n", dsprintk(NDEBUG_ARBITRATION, instance, "starting arbitration, id = %d\n",
...@@ -950,7 +946,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -950,7 +946,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
/* /*
* Arbitration and selection phases are slow and involve dropping the * Arbitration and selection phases are slow and involve dropping the
* lock, so we have to watch out for EH. An exception handler may * lock, so we have to watch out for EH. An exception handler may
* change 'selecting' to NULL. This function will then return NULL * change 'selecting' to NULL. This function will then return false
* so that the caller will forget about 'cmd'. (During information * so that the caller will forget about 'cmd'. (During information
* transfer phases, EH may change 'connected' to NULL.) * transfer phases, EH may change 'connected' to NULL.)
*/ */
...@@ -986,7 +982,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -986,7 +982,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
if (!hostdata->selecting) { if (!hostdata->selecting) {
/* Command was aborted */ /* Command was aborted */
NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(MODE_REG, MR_BASE);
return NULL; return false;
} }
if (err < 0) { if (err < 0) {
NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(MODE_REG, MR_BASE);
...@@ -1035,7 +1031,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -1035,7 +1031,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
if (!hostdata->selecting) { if (!hostdata->selecting) {
NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
return NULL; return false;
} }
dsprintk(NDEBUG_ARBITRATION, instance, "won arbitration\n"); dsprintk(NDEBUG_ARBITRATION, instance, "won arbitration\n");
...@@ -1118,13 +1114,13 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -1118,13 +1114,13 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
/* Can't touch cmd if it has been reclaimed by the scsi ML */ /* Can't touch cmd if it has been reclaimed by the scsi ML */
if (!hostdata->selecting) if (!hostdata->selecting)
return NULL; return false;
cmd->result = DID_BAD_TARGET << 16; cmd->result = DID_BAD_TARGET << 16;
complete_cmd(instance, cmd); complete_cmd(instance, cmd);
dsprintk(NDEBUG_SELECTION, instance, dsprintk(NDEBUG_SELECTION, instance,
"target did not respond within 250ms\n"); "target did not respond within 250ms\n");
cmd = NULL; ret = false;
goto out; goto out;
} }
...@@ -1156,7 +1152,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -1156,7 +1152,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
} }
if (!hostdata->selecting) { if (!hostdata->selecting) {
do_abort(instance); do_abort(instance);
return NULL; return false;
} }
dsprintk(NDEBUG_SELECTION, instance, "target %d selected, going into MESSAGE OUT phase.\n", dsprintk(NDEBUG_SELECTION, instance, "target %d selected, going into MESSAGE OUT phase.\n",
...@@ -1172,7 +1168,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -1172,7 +1168,7 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
cmd->result = DID_ERROR << 16; cmd->result = DID_ERROR << 16;
complete_cmd(instance, cmd); complete_cmd(instance, cmd);
dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n"); dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n");
cmd = NULL; ret = false;
goto out; goto out;
} }
...@@ -1187,13 +1183,13 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, ...@@ -1187,13 +1183,13 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
initialize_SCp(cmd); initialize_SCp(cmd);
cmd = NULL; ret = false;
out: out:
if (!hostdata->selecting) if (!hostdata->selecting)
return NULL; return NULL;
hostdata->selecting = NULL; hostdata->selecting = NULL;
return cmd; return ret;
} }
/* /*
......
...@@ -275,7 +275,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id); ...@@ -275,7 +275,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id);
static void NCR5380_main(struct work_struct *work); static void NCR5380_main(struct work_struct *work);
static const char *NCR5380_info(struct Scsi_Host *instance); static const char *NCR5380_info(struct Scsi_Host *instance);
static void NCR5380_reselect(struct Scsi_Host *instance); static void NCR5380_reselect(struct Scsi_Host *instance);
static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *, struct scsi_cmnd *); static bool NCR5380_select(struct Scsi_Host *, struct scsi_cmnd *);
static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
static int NCR5380_poll_politely2(struct NCR5380_hostdata *, static int NCR5380_poll_politely2(struct NCR5380_hostdata *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment