Skip to content

Commit

Permalink
[SCSI] use scmd_id(), scmd_channel() throughout code
Browse files Browse the repository at this point in the history
Wrap a highly common idiom.  Makes the code easier to read, helps pave
the way for sdev->{id,channel} removal, and adds a token that can easily
by grepped-for in the future.

There are a couple sdev_id() and scmd_printk() updates thrown in as well.

Rejections fixed up and
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
jgarzik authored and James Bottomley committed Oct 29, 2005
1 parent 017560f commit 422c0d6
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 90 deletions.
6 changes: 3 additions & 3 deletions drivers/scsi/53c700.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
* If a contingent allegiance condition exists, the device
* will refuse all tags, so send the request sense as untagged
* */
if((hostdata->tag_negotiated & (1<<SCp->device->id))
if((hostdata->tag_negotiated & (1<<scmd_id(SCp)))
&& (slot->tag != SCSI_NO_TAG && SCp->cmnd[0] != REQUEST_SENSE)) {
count += scsi_populate_tag_msg(SCp, &hostdata->msgout[count]);
}
Expand All @@ -1446,7 +1446,7 @@ NCR_700_start_command(struct scsi_cmnd *SCp)


script_patch_ID(hostdata->script,
Device_ID, 1<<SCp->device->id);
Device_ID, 1<<scmd_id(SCp));

script_patch_32_abs(hostdata->script, CommandAddress,
slot->pCmd);
Expand Down Expand Up @@ -2111,7 +2111,7 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type)
/* shift back to the default unqueued number of commands
* (the user can still raise this) */
scsi_deactivate_tcq(SDp, SDp->host->cmd_per_lun);
hostdata->tag_negotiated &= ~(1 << SDp->id);
hostdata->tag_negotiated &= ~(1 << sdev_id(SDp));
} else {
/* Here, we cleared the negotiation flag above, so this
* will force the driver to renegotiate */
Expand Down
12 changes: 6 additions & 6 deletions drivers/scsi/NCR5380.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,13 +1247,13 @@ static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd)
case WRITE:
case WRITE_6:
case WRITE_10:
hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
hostdata->time_write[scmd_id(cmd)] += (jiffies - hostdata->timebase);
hostdata->pendingw--;
break;
case READ:
case READ_6:
case READ_10:
hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
hostdata->time_read[scmd_id(cmd)] += (jiffies - hostdata->timebase);
hostdata->pendingr--;
break;
}
Expand Down Expand Up @@ -1385,7 +1385,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)
* the host and target ID's on the SCSI bus.
*/

NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id)));
NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << scmd_id(cmd))));

/*
* Raise ATN while SEL is true before BSY goes false from arbitration,
Expand Down Expand Up @@ -1430,7 +1430,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)

udelay(1);

dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, cmd->device->id));
dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, scmd_id(cmd)));

/*
* The SCSI specification calls for a 250 ms timeout for the actual
Expand Down Expand Up @@ -1483,7 +1483,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)

if (!(NCR5380_read(STATUS_REG) & SR_BSY)) {
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
if (hostdata->targets_present & (1 << cmd->device->id)) {
if (hostdata->targets_present & (1 << scmd_id(cmd))) {
printk(KERN_DEBUG "scsi%d : weirdness\n", instance->host_no);
if (hostdata->restart_select)
printk(KERN_DEBUG "\trestart select\n");
Expand All @@ -1499,7 +1499,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return 0;
}
hostdata->targets_present |= (1 << cmd->device->id);
hostdata->targets_present |= (1 << scmd_id(cmd));

/*
* Since we followed the SCSI spec, and raised ATN while SEL
Expand Down
16 changes: 8 additions & 8 deletions drivers/scsi/NCR53C9x.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ static void esp_release_dmabufs(struct NCR_ESP *esp, Scsi_Cmnd *sp)

static void esp_restore_pointers(struct NCR_ESP *esp, Scsi_Cmnd *sp)
{
struct esp_pointers *ep = &esp->data_pointers[sp->device->id];
struct esp_pointers *ep = &esp->data_pointers[scmd_id(sp)];

sp->SCp.ptr = ep->saved_ptr;
sp->SCp.buffer = ep->saved_buffer;
Expand All @@ -946,7 +946,7 @@ static void esp_restore_pointers(struct NCR_ESP *esp, Scsi_Cmnd *sp)

static void esp_save_pointers(struct NCR_ESP *esp, Scsi_Cmnd *sp)
{
struct esp_pointers *ep = &esp->data_pointers[sp->device->id];
struct esp_pointers *ep = &esp->data_pointers[scmd_id(sp)];

ep->saved_ptr = sp->SCp.ptr;
ep->saved_buffer = sp->SCp.buffer;
Expand Down Expand Up @@ -1693,13 +1693,13 @@ static inline void esp_connect(struct NCR_ESP *esp, struct ESP_regs *eregs,
if(esp->prev_soff != esp_dev->sync_max_offset ||
esp->prev_stp != esp_dev->sync_min_period ||
(esp->erev > esp100a &&
esp->prev_cfg3 != esp->config3[sp->device->id])) {
esp->prev_cfg3 != esp->config3[scmd_id(sp)])) {
esp->prev_soff = esp_dev->sync_max_offset;
esp_write(eregs->esp_soff, esp->prev_soff);
esp->prev_stp = esp_dev->sync_min_period;
esp_write(eregs->esp_stp, esp->prev_stp);
if(esp->erev > esp100a) {
esp->prev_cfg3 = esp->config3[sp->device->id];
esp->prev_cfg3 = esp->config3[scmd_id(sp)];
esp_write(eregs->esp_cfg3, esp->prev_cfg3);
}
}
Expand Down Expand Up @@ -2205,7 +2205,7 @@ static int esp_do_freebus(struct NCR_ESP *esp, struct ESP_regs *eregs)

if(SCptr->SCp.Status != GOOD &&
SCptr->SCp.Status != CONDITION_GOOD &&
((1<<SCptr->device->id) & esp->targets_present) &&
((1<<scmd_id(SCptr)) & esp->targets_present) &&
esp_dev->sync && esp_dev->sync_max_offset) {
/* SCSI standard says that the synchronous capabilities
* should be renegotiated at this point. Most likely
Expand Down Expand Up @@ -2597,7 +2597,7 @@ static int esp_select_complete(struct NCR_ESP *esp, struct ESP_regs *eregs)
*/
if(esp->ireg == (ESP_INTR_FDONE | ESP_INTR_BSERV)) {
/* target speaks... */
esp->targets_present |= (1<<SCptr->device->id);
esp->targets_present |= (1<<scmd_id(SCptr));

/* What if the target ignores the sdtr? */
if(esp->snip)
Expand Down Expand Up @@ -3064,7 +3064,7 @@ static int check_multibyte_msg(struct NCR_ESP *esp,
ESPSDTR(("soff=%2x stp=%2x cfg3=%2x\n",
esp_dev->sync_max_offset,
esp_dev->sync_min_period,
esp->config3[SCptr->device->id]));
esp->config3[scmd_id(SCptr)]));

esp->snip = 0;
} else if(esp_dev->sync_max_offset) {
Expand Down Expand Up @@ -3621,7 +3621,7 @@ void esp_slave_destroy(Scsi_Device *SDptr)
{
struct NCR_ESP *esp = (struct NCR_ESP *) SDptr->host->hostdata;

esp->targets_present &= ~(1 << SDptr->id);
esp->targets_present &= ~(1 << sdev_id(SDptr));
kfree(SDptr->hostdata);
SDptr->hostdata = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/NCR53c406a.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ static int NCR53c406a_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))

/* We are locked here already by the mid layer */
REG0;
outb(SCpnt->device->id, DEST_ID); /* set destination */
outb(scmd_id(SCpnt), DEST_ID); /* set destination */
outb(FLUSH_FIFO, CMD_REG); /* reset the fifos */

for (i = 0; i < SCpnt->cmd_len; i++) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/a100u2w.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ static int inia100_device_reset(struct scsi_cmnd * SCpnt)
{ /* I need Host Control Block Information */
ORC_HCS *pHCB;
pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
return orc_device_reset(pHCB, SCpnt, SCpnt->device->id);
return orc_device_reset(pHCB, SCpnt, scmd_id(SCpnt));

}

Expand Down
8 changes: 4 additions & 4 deletions drivers/scsi/aacraid/aachba.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
* Test does not apply to ID 16, the pseudo id for the controller
* itself.
*/
if (scsicmd->device->id != host->this_id) {
if (scmd_id(scsicmd) != host->this_id) {
if ((scsicmd->device->channel == 0) ){
if( (scsicmd->device->id >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)){
scsicmd->result = DID_NO_CONNECT << 16;
Expand Down Expand Up @@ -1559,7 +1559,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
* Set the Vendor, Product, and Revision Level
* see: <vendor>.c i.e. aac.c
*/
if (scsicmd->device->id == host->this_id) {
if (scmd_id(scsicmd) == host->this_id) {
setinqstr(dev, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *)));
inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */
aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
Expand Down Expand Up @@ -1949,7 +1949,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
* the channel is 2
*/
} else if ((dev->raid_scsi_mode) &&
(scsicmd->device->channel == 2)) {
(scmd_channel(scsicmd) == 2)) {
scsicmd->result = DID_OK << 16 |
COMMAND_COMPLETE << 8;
} else {
Expand Down Expand Up @@ -1993,7 +1993,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
* the channel is 2
*/
} else if ((dev->raid_scsi_mode) &&
(scsicmd->device->channel == 2)) {
(scmd_channel(scsicmd) == 2)) {
scsicmd->result = DID_OK << 16 |
COMMAND_COMPLETE << 8;
} else {
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/aha1740.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
{
unchar direction;
unchar *cmd = (unchar *) SCpnt->cmnd;
unchar target = SCpnt->device->id;
unchar target = scmd_id(SCpnt);
struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host);
unsigned long flags;
void *buff = SCpnt->request_buffer;
Expand Down
11 changes: 6 additions & 5 deletions drivers/scsi/aic7xxx/aic79xx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)

/******************************** Macros **************************************/
#define BUILD_SCSIID(ahd, cmd) \
((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id)
(((scmd_id(cmd) << TID_SHIFT) & TID) | (ahd)->our_id)

/*
* Return a string describing the driver.
Expand Down Expand Up @@ -685,7 +685,7 @@ ahd_linux_bus_reset(struct scsi_cmnd *cmd)
ahd_name(ahd), cmd);
#endif
ahd_lock(ahd, &s);
found = ahd_reset_channel(ahd, cmd->device->channel + 'A',
found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
/*initiate reset*/TRUE);
ahd_unlock(ahd, &s);

Expand Down Expand Up @@ -2110,8 +2110,9 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)

/* Any SCB for this device will do for a target reset */
LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
if (ahd_match_scb(ahd, pending_scb, cmd->device->id,
cmd->device->channel + 'A',
if (ahd_match_scb(ahd, pending_scb,
scmd_id(cmd),
scmd_channel(cmd) + 'A',
CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_INITIATOR) == 0)
break;
Expand Down Expand Up @@ -2198,7 +2199,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
if (last_phase != P_BUSFREE
&& (SCB_GET_TAG(pending_scb) == active_scbptr
|| (flag == SCB_DEVICE_RESET
&& SCSIID_TARGET(ahd, saved_scsiid) == cmd->device->id))) {
&& SCSIID_TARGET(ahd, saved_scsiid) == scmd_id(cmd)))) {

/*
* We're active on the bus, so assert ATN
Expand Down
10 changes: 5 additions & 5 deletions drivers/scsi/aic7xxx/aic7xxx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
u_int channel;

ahc = *((struct ahc_softc **)sdev->host->hostdata);
channel = sdev->channel;
channel = sdev_channel(sdev);

bh = scsi_bios_ptable(bdev);
if (bh) {
Expand Down Expand Up @@ -759,7 +759,7 @@ ahc_linux_bus_reset(struct scsi_cmnd *cmd)
ahc = *(struct ahc_softc **)cmd->device->host->hostdata;

ahc_lock(ahc, &flags);
found = ahc_reset_channel(ahc, cmd->device->channel + 'A',
found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
/*initiate reset*/TRUE);
ahc_unlock(ahc, &flags);

Expand Down Expand Up @@ -2172,8 +2172,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)

/* Any SCB for this device will do for a target reset */
LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
if (ahc_match_scb(ahc, pending_scb, cmd->device->id,
cmd->device->channel + 'A',
if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
scmd_channel(cmd) + 'A',
CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_INITIATOR) == 0)
break;
Expand Down Expand Up @@ -2260,7 +2260,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
if (last_phase != P_BUSFREE
&& (pending_scb->hscb->tag == active_scb_index
|| (flag == SCB_DEVICE_RESET
&& SCSIID_TARGET(ahc, saved_scsiid) == cmd->device->id))) {
&& SCSIID_TARGET(ahc, saved_scsiid) == scmd_id(cmd)))) {

/*
* We're active on the bus, so assert ATN
Expand Down
22 changes: 11 additions & 11 deletions drivers/scsi/atp870u.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,10 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p,
struct atp_unit *dev;
struct Scsi_Host *host;

c = req_p->device->channel;
c = scmd_channel(req_p);
req_p->sense_buffer[0]=0;
req_p->resid = 0;
if (req_p->device->channel > 1) {
if (scmd_channel(req_p) > 1) {
req_p->result = 0x00040000;
done(req_p);
#ifdef ED_DBGP
Expand All @@ -639,7 +639,7 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p,


m = 1;
m = m << req_p->device->id;
m = m << scmd_id(req_p);

/*
* Fake a timeout for missing targets
Expand Down Expand Up @@ -757,9 +757,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
dev->quhd[c] = 0;
}
workreq = dev->quereq[c][dev->quhd[c]];
if (dev->id[c][workreq->device->id].curr_req == 0) {
dev->id[c][workreq->device->id].curr_req = workreq;
dev->last_cmd[c] = workreq->device->id;
if (dev->id[c][scmd_id(workreq)].curr_req == 0) {
dev->id[c][scmd_id(workreq)].curr_req = workreq;
dev->last_cmd[c] = scmd_id(workreq);
goto cmd_subp;
}
dev->quhd[c] = j;
Expand All @@ -786,16 +786,16 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
oktosend:
#ifdef ED_DBGP
printk("OK to Send\n");
printk("CDB");
scmd_printk(KERN_DEBUG, workreq, "CDB");
for(i=0;i<workreq->cmd_len;i++) {
printk(" %x",workreq->cmnd[i]);
}
printk("\nChannel = %d ID = %d LUN = %d\n",c,workreq->device->id,workreq->device->lun);
printk("\n");
#endif
if (dev->dev_id == ATP885_DEVID) {
j = inb(dev->baseport + 0x29) & 0xfe;
outb(j, dev->baseport + 0x29);
dev->r1f[c][workreq->device->id] = 0;
dev->r1f[c][scmd_id(workreq)] = 0;
}

if (workreq->cmnd[0] == READ_CAPACITY) {
Expand All @@ -809,7 +809,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)

tmport = workport + 0x1b;
j = 0;
target_id = workreq->device->id;
target_id = scmd_id(workreq);

/*
* Wide ?
Expand Down Expand Up @@ -3108,7 +3108,7 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt)
host = SCpnt->device->host;

dev = (struct atp_unit *)&host->hostdata;
c=SCpnt->device->channel;
c = scmd_channel(SCpnt);
printk(" atp870u: abort Channel = %x \n", c);
printk("working=%x last_cmd=%x ", dev->working[c], dev->last_cmd[c]);
printk(" quhdu=%x quendu=%x ", dev->quhd[c], dev->quend[c]);
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/fd_mcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs)
outb(0x40 | FIFO_COUNT, Interrupt_Cntl_port);

outb(0x82, SCSI_Cntl_port); /* Bus Enable + Select */
outb(adapter_mask | (1 << current_SC->device->id), SCSI_Data_NoACK_port);
outb(adapter_mask | (1 << scmd_id(current_SC)), SCSI_Data_NoACK_port);

/* Stop arbitration and enable parity */
outb(0x10 | PARITY_MASK, TMC_Cntl_port);
Expand All @@ -683,7 +683,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id, struct pt_regs *regs)
status = inb(SCSI_Status_port);
if (!(status & 0x01)) {
/* Try again, for slow devices */
if (fd_mcs_select(shpnt, current_SC->device->id)) {
if (fd_mcs_select(shpnt, scmd_id(current_SC))) {
#if EVERY_ACCESS
printk(" SFAIL ");
#endif
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/fdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id,
outb(0x40 | FIFO_COUNT, port_base + Interrupt_Cntl);

outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */
outb(adapter_mask | (1 << current_SC->device->id), port_base + SCSI_Data_NoACK);
outb(adapter_mask | (1 << scmd_id(current_SC)), port_base + SCSI_Data_NoACK);

/* Stop arbitration and enable parity */
outb(0x10 | PARITY_MASK, port_base + TMC_Cntl);
Expand All @@ -1166,7 +1166,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id,
status = inb(port_base + SCSI_Status);
if (!(status & 0x01)) {
/* Try again, for slow devices */
if (fdomain_select( current_SC->device->id )) {
if (fdomain_select( scmd_id(current_SC) )) {
#if EVERY_ACCESS
printk( " SFAIL " );
#endif
Expand Down
Loading

0 comments on commit 422c0d6

Please sign in to comment.