Skip to contentSkip to conversation

HCIL: more sfoo_printk()

PATCH New Jeff Garzik 1 participant 3 messages Oct 29, 2005

Subsystems (14)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 HCIL: more sfoo_printk()

commit bab4e339d19ea45eaea3ea252a545d9d0efcae9f

Author: Jeff Garzik <[email protected]>
Date:   Sat Oct 29 17:13:28 2005 -0400

[SCSI] more uses of sfoo_printk()

 drivers/scsi/NCR5380.c    |   11 ++++++++---
 drivers/scsi/NCR5380.h    |    8 ++++++++
 drivers/scsi/constants.c  |    3 +--
 drivers/scsi/eata.c       |   12 +++++-------
 drivers/scsi/scsi.c       |    2 +-
 drivers/scsi/scsi_error.c |    9 ++++-----
 drivers/scsi/sd.c         |    3 +--
 7 files changed, 28 insertions(+), 20 deletions(-)
drivers/scsi/NCR5380.c +8 -3
index cc9ecb3..9e2764f 100644
@@ -1120,7 +1120,8 @@ static void NCR5380_main(void *p)
 				   this is needed for Mustek scanners, that
 				   do not respond to commands immediately
 				   after a scan */
-				printk(KERN_DEBUG "scsi%d: device %d did not respond in time\n", instance->host_no, tmp->device->id);
+				scmd_printk(KERN_DEBUG, tmp,
+					"device did not respond in time\n");
 				LIST(tmp, hostdata->issue_queue);
 				tmp->host_scribble = (unsigned char *) hostdata->issue_queue;
 				hostdata->issue_queue = tmp;
@@ -2244,7 +2245,8 @@ static void NCR5380_information_transfer
 					/* The next command is still part of this process */
 					cmd->next_link->tag = cmd->tag;
 					cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
-					dprintk(NDEBUG_LINKED, ("scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, cmd->device->lun));
+					ddprintk(KERN_DEBUG, cmd,
+						"linked request done, calling scsi_done().\n");
 					collect_stats(hostdata, cmd);
 					cmd->scsi_done(cmd);
 					cmd = hostdata->connected;
@@ -2339,7 +2341,10 @@ static void NCR5380_information_transfer
 						    hostdata->disconnected_queue;
 						hostdata->connected = NULL;
 						hostdata->disconnected_queue = cmd;
-						dprintk(NDEBUG_QUEUES, ("scsi%d : command for target %d lun %d was moved from connected to" "  the disconnected_queue\n", instance->host_no, cmd->device->id, cmd->device->lun));
+						ddprintk(KERN_DEBUG, cmd,
+						"command for target was moved from connected to"
+						"  the disconnected_queue\n");
+
 						/* 
 						 * Restore phase bits to 0 so an interrupted selection, 
 						 * arbitration can resume.
drivers/scsi/NCR5380.h +8 -0
index c3462e3..298b2df 100644
@@ -289,6 +289,14 @@ struct NCR5380_hostdata {
 #define NCR5380_dprint(a,b)		do {} while(0)
 #define NCR5380_dprint_phase(a,b)	do {} while(0)
 
+#if 0
+#define ddprintk(prefix, scmd, fmt, a...) \
+	scmd_printk(prefix, scmd, fmt, ##a)
+#else
+#define ddprintk(prefix, scmd, fmt, a...) \
+	do {} while (0)
+#endif
+
 #if defined(AUTOPROBE_IRQ)
 static int NCR5380_probe_irq(struct Scsi_Host *instance, int possible);
 #endif
drivers/scsi/constants.c +1 -2
index 09bc815..8bd936b 100644
@@ -1389,8 +1389,7 @@ EXPORT_SYMBOL(scsi_print_msg);
 void scsi_print_command(struct scsi_cmnd *cmd)
 {
 	/* Assume appended output (i.e. not at start of line) */
-	sdev_printk("", cmd->device, "\n");
-	printk(KERN_INFO "        command: ");
+	scmd_printk(KERN_INFO, cmd, "command:\n\t");
 	scsi_print_cdb(cmd->cmnd, cmd->cmd_len, 0);
 }
 EXPORT_SYMBOL(scsi_print_command);
drivers/scsi/eata.c +5 -7
index b45a4c7..cd0fc64 100644
@@ -2455,20 +2455,18 @@ static irqreturn_t ihdlr(int irq, struct
 			status = DID_OK << 16;
 
 		if (tstatus == GOOD)
-			ha->target_redo[SCpnt->device->id][SCpnt->device->
-							      channel] = 0;
+			ha->target_redo[scmd_id(SCpnt)][scmd_channel(SCpnt)] = 0;
 
 		if (spp->target_status && SCpnt->device->type == TYPE_DISK &&
 		    (!(tstatus == CHECK_CONDITION && ha->iocount <= 1000 &&
 		       (SCpnt->sense_buffer[2] & 0xf) == NOT_READY)))
-			printk("%s: ihdlr, target %d.%d:%d, pid %ld, "
+			scmd_printk(KERN_INFO, SCpnt,
+				"ihdlr, pid %ld, "
 			       "target_status 0x%x, sense key 0x%x.\n",
-			       ha->board_name,
-			       SCpnt->device->channel, SCpnt->device->id,
-			       SCpnt->device->lun, SCpnt->pid,
+			       SCpnt->pid,
 			       spp->target_status, SCpnt->sense_buffer[2]);
 
-		ha->target_to[SCpnt->device->id][SCpnt->device->channel] = 0;
+		ha->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)] = 0;
 
 		if (ha->last_retried_pid == SCpnt->pid)
 			ha->retries = 0;
drivers/scsi/scsi.c +1 -1
index 0be60bb..4f86215 100644
@@ -806,7 +806,7 @@ static void scsi_softirq(struct softirq_
 		disposition = scsi_decide_disposition(cmd);
 		if (disposition != SUCCESS &&
 		    time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {
-			sdev_printk(KERN_ERR, cmd->device,
+			scmd_printk(KERN_ERR, cmd,
 				    "timing out command, waited %lus\n",
 				    wait_for/HZ);
 			disposition = SUCCESS;
drivers/scsi/scsi_error.c +4 -5
index 0c5b02d..4fddb9b 100644
@@ -1174,9 +1174,9 @@ static void scsi_eh_offline_sdevs(struct
 	struct scsi_cmnd *scmd, *next;
 
 	list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
-		sdev_printk(KERN_INFO, scmd->device,
-			    "scsi: Device offlined - not"
-			    " ready after error recovery\n");
+		scmd_printk(KERN_INFO, scmd,
+			    "Device offlined - not"
+		       	    " ready after error recovery\n");
 		scsi_device_set_state(scmd->device, SDEV_OFFLINE);
 		if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
 			/*
@@ -1338,8 +1338,7 @@ int scsi_decide_disposition(struct scsi_
 		return SUCCESS;
 
 	case RESERVATION_CONFLICT:
-		sdev_printk(KERN_INFO, scmd->device,
-			    "reservation conflict\n");
+		scmd_printk(KERN_INFO, scmd, "reservation conflict\n");
 		return SUCCESS; /* causes immediate i/o error */
 	default:
 		return FAILED;
drivers/scsi/sd.c +1 -2
index 9de8e18..fca6e0e 100644
@@ -1534,8 +1534,7 @@ static int sd_probe(struct device *dev)
 	if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)
 		goto out;
 
-	SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp,
-					"sd_attach\n"));
+	SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp, "sd_attach\n"));
 
 	error = -ENOMEM;
 	sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL);
#1 lore raw

PATCH 2/3 HCIL: more {scmd,sdev}_{id,channel}

commit 2f3f6acc914150f0e671e3d3623d5e85bf95939b

Author: Jeff Garzik <[email protected]>
Date:   Sat Oct 29 17:27:37 2005 -0400
    [SCSI] more usage of scmd_{id,channel} and sdev_{id,channel}
 drivers/scsi/3w-xxxx.c                |   22 ++++++++++++--------
 drivers/scsi/BusLogic.c               |    6 ++---
 drivers/scsi/NCR5380.c                |    8 +++----
 drivers/scsi/NCR53C9x.c               |   12 +++++------
 drivers/scsi/advansys.c               |   23 +++++++++++----------
 drivers/scsi/aha152x.c                |    6 ++---
 drivers/scsi/aic7xxx/aic7xxx_osm.c    |    8 +++----
 drivers/scsi/dc395x.c                 |   24 +++++++++++-----------
 drivers/scsi/eata.c                   |    9 ++------
 drivers/scsi/g_NCR5380.c              |   10 ++++-----
 drivers/scsi/gdth_proc.c              |   12 +++++------
 drivers/scsi/in2000.c                 |   36 +++++++++++++++++-----------------
 drivers/scsi/initio.c                 |    2 -
 drivers/scsi/ipr.c                    |    3 +-
 drivers/scsi/libata-scsi.c            |    4 +--
 drivers/scsi/megaraid/mega_common.h   |    2 -
 drivers/scsi/megaraid/megaraid_mbox.c |    6 ++---
 drivers/scsi/megaraid/megaraid_sas.c  |    2 -
 drivers/scsi/megaraid/megaraid_sas.h  |    6 ++---
 drivers/scsi/ncr53c8xx.c              |    2 -
 drivers/scsi/nsp32.c                  |    4 +--
 drivers/scsi/pcmcia/nsp_cs.c          |    2 -
 drivers/scsi/psi240i.c                |    2 -
 drivers/scsi/qlogicfc.c               |    4 +--
 drivers/scsi/sym53c8xx_2/sym_glue.c   |   10 ++++-----
 25 files changed, 114 insertions(+), 111 deletions(-)
drivers/scsi/3w-xxxx.c +13 -9
index 283f6d2..2cec0d0 100644
@@ -1543,7 +1543,8 @@ static int tw_scsiop_inquiry_complete(TW
 	request_buffer[2] = 0;	       /* No ansi/iso compliance */
 	request_buffer[4] = 31;	       /* Additional length */
 	memcpy(&request_buffer[8], "3ware   ", 8);	 /* Vendor ID */
-	sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id);
+	sprintf(&request_buffer[16], "Logical Disk %-2d ",
+		scmd_id(tw_dev->srb[request_id]));
 	memcpy(&request_buffer[32], TW_DRIVER_VERSION, 3);
 	tw_transfer_internal(tw_dev, request_id, request_buffer,
 			     sizeof(request_buffer));
@@ -1555,10 +1556,10 @@ static int tw_scsiop_inquiry_complete(TW
 	}
 	is_unit_present = &(param->data[0]);
 
-	if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1;
+	if (is_unit_present[scmd_id(tw_dev->srb[request_id])] & TW_UNIT_ONLINE) {
+		tw_dev->is_unit_present[scmd_id(tw_dev->srb[request_id])] = 1;
 	} else {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0;
+		tw_dev->is_unit_present[scmd_id(tw_dev->srb[request_id])] = 0;
 		tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16);
 		return TW_ISR_DONT_RESULT;
 	}
@@ -1609,7 +1610,8 @@ static int tw_scsiop_mode_sense(TW_Devic
 
 	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
 	memset(param, 0, sizeof(TW_Sector));
-	param->table_id = TW_UNIT_INFORMATION_TABLE_BASE + tw_dev->srb[request_id]->device->id;
+	param->table_id = TW_UNIT_INFORMATION_TABLE_BASE +
+		scmd_id(tw_dev->srb[request_id]);
 	param->parameter_id = 7; /* unit flags */
 	param->parameter_size_bytes = 1;
 	param_value = tw_dev->alignment_physical_address[request_id];
@@ -1686,7 +1688,8 @@ static int tw_scsiop_read_capacity(TW_De
 	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id);
+	command_packet->unit__hostid =
+		TW_UNITHOST_IN(0, scmd_id(tw_dev->srb[request_id]));
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.block_count = 1;
@@ -1699,7 +1702,7 @@ static int tw_scsiop_read_capacity(TW_De
 	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
 	memset(param, 0, sizeof(TW_Sector));
 	param->table_id = TW_UNIT_INFORMATION_TABLE_BASE + 
-	tw_dev->srb[request_id]->device->id;
+		scmd_id(tw_dev->srb[request_id]);
 	param->parameter_id = 4;	/* unitcapacity parameter */
 	param->parameter_size_bytes = 4;
 	param_value = tw_dev->alignment_physical_address[request_id];
@@ -1799,7 +1802,7 @@ static int tw_scsiop_read_write(TW_Devic
 
 	command_packet->size = 3;
 	command_packet->request_id = request_id;
-	command_packet->unit__hostid = TW_UNITHOST_IN(0, srb->device->id);
+	command_packet->unit__hostid = TW_UNITHOST_IN(0, scmd_id(srb));
 	command_packet->status = 0;
 	command_packet->flags = 0;
 
@@ -1904,7 +1907,8 @@ static int tw_scsiop_synchronize_cache(T
 	command_packet->opcode__sgloffset = TW_OPSGL_IN(0, TW_OP_FLUSH_CACHE);
 	command_packet->size = 2;
 	command_packet->request_id = request_id;
-	command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id);
+	command_packet->unit__hostid =
+		TW_UNITHOST_IN(0, scmd_id(tw_dev->srb[request_id]));
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
drivers/scsi/BusLogic.c +3 -3
index 9d6040b..77deafa 100644
@@ -2139,7 +2139,7 @@ static void __init BusLogic_InitializeHo
 static int BusLogic_SlaveConfigure(struct scsi_device *Device)
 {
 	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Device->host->hostdata;
-	int TargetID = Device->id;
+	int TargetID = sdev_id(Device);
 	int QueueDepth = HostAdapter->QueueDepth[TargetID];
 
 	if (HostAdapter->TargetFlags[TargetID].TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) {
@@ -2744,7 +2744,7 @@ static int BusLogic_host_reset(struct sc
 {
 	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) SCpnt->device->host->hostdata;
 
-	unsigned int id = SCpnt->device->id;
+	unsigned int id = scmd_id(SCpnt);
 	struct BusLogic_TargetStatistics *stats = &HostAdapter->TargetStatistics[id];
 	int rc;
 
@@ -2960,7 +2960,7 @@ static int BusLogic_AbortCommand(struct 
 {
 	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
 
-	int TargetID = Command->device->id;
+	int TargetID = scmd_id(Command);
 	struct BusLogic_CCB *CCB;
 	BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsRequested);
 	/*
drivers/scsi/NCR5380.c +4 -4
index 9e2764f..511c7f2 100644
@@ -976,15 +976,15 @@ static int NCR5380_queue_command(Scsi_Cm
 		case WRITE:
 		case WRITE_6:
 		case WRITE_10:
-			hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;
+			hostdata->time_write[scmd_id(cmd)] -= (jiffies - hostdata->timebase);
+			hostdata->bytes_write[scmd_id(cmd)] += cmd->request_bufflen;
 			hostdata->pendingw++;
 			break;
 		case READ:
 		case READ_6:
 		case READ_10:
-			hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;
+			hostdata->time_read[scmd_id(cmd)] -= (jiffies - hostdata->timebase);
+			hostdata->bytes_read[scmd_id(cmd)] += cmd->request_bufflen;
 			hostdata->pendingr++;
 			break;
 	}
drivers/scsi/NCR53C9x.c +6 -6
index 26146a4..1173698 100644
@@ -871,7 +871,7 @@ static int esp_host_info(struct NCR_ESP 
 
 	shost_for_each_device(sdev, esp->ehost) {
 		struct esp_device *esp_dev = sdev->hostdata;
-		uint id = sdev->id;
+		uint id = sdev_id(sdev);
 
 		if (!(esp->targets_present & (1 << id)))
 			continue;
@@ -3050,10 +3050,10 @@ static int check_multibyte_msg(struct NC
 				else
 					bit = ESP_CONFIG3_FSCSI;
 				if(period < 50)
-					esp->config3[SCptr->device->id] |= bit;
+					esp->config3[scmd_id(SCptr)] |= bit;
 				else
-					esp->config3[SCptr->device->id] &= ~bit;
-				esp->prev_cfg3 = esp->config3[SCptr->device->id];
+					esp->config3[scmd_id(SCptr)] &= ~bit;
+				esp->prev_cfg3 = esp->config3[scmd_id(SCptr)];
 				esp_write(eregs->esp_cfg3, esp->prev_cfg3);
 			}
 			esp->prev_soff = esp_dev->sync_min_period;
@@ -3083,8 +3083,8 @@ static int check_multibyte_msg(struct NC
 					bit = ESP_CONFIG3_FAST;
 				else
 					bit = ESP_CONFIG3_FSCSI;
-				esp->config3[SCptr->device->id] &= ~bit;
-				esp->prev_cfg3 = esp->config3[SCptr->device->id];
+				esp->config3[scmd_id(SCptr)] &= ~bit;
+				esp->prev_cfg3 = esp->config3[scmd_id(SCptr)];
 				esp_write(eregs->esp_cfg3, esp->prev_cfg3);
 			}
 		}
drivers/scsi/advansys.c +12 -11
index 37ec541..e70de4c 100644
@@ -3523,7 +3523,7 @@ typedef struct {
 typedef struct scsi_cmnd     REQ, *REQP;
 #define REQPNEXT(reqp)       ((REQP) ((reqp)->host_scribble))
 #define REQPNEXTP(reqp)      ((REQP *) &((reqp)->host_scribble))
-#define REQPTID(reqp)        ((reqp)->device->id)
+#define REQPTID(reqp)        (scmd_id(reqp))
 #define REQPTIME(reqp)       ((reqp)->SCp.this_residual)
 #define REQTIMESTAMP()       (jiffies)
 
@@ -6243,7 +6243,7 @@ asc_execute_scsi_cmnd(struct scsi_cmnd *
         (ulong) scp, (ulong) scp->scsi_done);
 
     boardp = ASC_BOARDP(scp->device->host);
-    device = boardp->device[scp->device->id];
+    device = boardp->device[scmd_id(scp)];
 
     if (ASC_NARROW_BOARD(boardp)) {
         /*
@@ -6278,7 +6278,7 @@ asc_execute_scsi_cmnd(struct scsi_cmnd *
              * Increment monotonically increasing per device successful
              * request counter. Wrapping doesn't matter.
              */
-            boardp->reqcnt[scp->device->id]++;
+            boardp->reqcnt[scmd_id(scp)]++;
             asc_enqueue(&boardp->active, scp, ASC_BACK);
             ASC_DBG(1,
                 "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
@@ -6358,7 +6358,7 @@ asc_execute_scsi_cmnd(struct scsi_cmnd *
              * Increment monotonically increasing per device successful
              * request counter. Wrapping doesn't matter.
              */
-            boardp->reqcnt[scp->device->id]++;
+            boardp->reqcnt[scmd_id(scp)]++;
             asc_enqueue(&boardp->active, scp, ASC_BACK);
             ASC_DBG(1,
                 "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
@@ -6451,8 +6451,8 @@ asc_build_req(asc_board_t *boardp, struc
      * started request.
      *
      */
-    if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
-        (boardp->reqcnt[scp->device->id] % 255) == 0) {
+    if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scmd_id(scp)] > 0) &&
+        (boardp->reqcnt[scmd_id(scp)] % 255) == 0) {
         asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
     } else {
         asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
@@ -6962,10 +6962,10 @@ asc_isr_callback(ASC_DVC_VAR *asc_dvc_va
      * current request finished normally, then set the bit for the target
      * to indicate that a device is present.
      */
-    if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
+    if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scmd_id(scp))) == 0 &&
         qdonep->d3.done_stat == QD_NO_ERROR &&
         qdonep->d3.host_stat == QHSTA_NO_ERROR) {
-        boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
+        boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scmd_id(scp));
     }
 
     /*
@@ -7141,10 +7141,10 @@ adv_isr_callback(ADV_DVC_VAR *adv_dvc_va
      * current request finished normally, then set the bit for the target
      * to indicate that a device is present.
      */
-    if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
+    if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scmd_id(scp))) == 0 &&
         scsiqp->done_status == QD_NO_ERROR &&
         scsiqp->host_status == QHSTA_NO_ERROR) {
-        boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
+        boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scmd_id(scp));
     }
 
     /*
@@ -7384,7 +7384,8 @@ asc_dequeue_list(asc_queue_t *ascq, REQP
         {
             REQP reqp;
             for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
-                REQTIMESTAT("asc_dequeue_list", ascq, reqp, reqp->device->id);
+                REQTIMESTAT("asc_dequeue_list", ascq, reqp,
+			    scmd_id(reqp));
             }
         }
 #endif /* ADVANSYS_STATS */
drivers/scsi/aha152x.c +3 -3
index 9b7caf5..692dc56 100644
@@ -586,8 +586,8 @@ struct aha152x_scdata {
 
 #define DATA_LEN		(HOSTDATA(shpnt)->data_len)
 
-#define SYNCRATE		(HOSTDATA(shpnt)->syncrate[CURRENT_SC->device->id])
-#define SYNCNEG			(HOSTDATA(shpnt)->syncneg[CURRENT_SC->device->id])
+#define SYNCRATE		(HOSTDATA(shpnt)->syncrate[scmd_id(CURRENT_SC)])
+#define SYNCNEG			(HOSTDATA(shpnt)->syncneg[scmd_id(CURRENT_SC)])
 
 #define DELAY			(HOSTDATA(shpnt)->delay)
 #define EXT_TRANS		(HOSTDATA(shpnt)->ext_trans)
@@ -1660,7 +1660,7 @@ static void busfree_run(struct Scsi_Host
 		/* clear selection timeout */
 		SETPORT(SSTAT1, SELTO);
 
-		SETPORT(SCSIID, (shpnt->this_id << OID_) | CURRENT_SC->device->id);
+		SETPORT(SCSIID, (shpnt->this_id << OID_) | scmd_id(CURRENT_SC));
 		SETPORT(SXFRCTL1, (PARITY ? ENSPCHK : 0 ) | ENSTIMER);
 		SETPORT(SCSISEQ, ENSELO | ENAUTOATNO | (DISCONNECTED_SC ? ENRESELI : 0));
 	} else {
drivers/scsi/aic7xxx/aic7xxx_osm.c +4 -4
index 1861407..df364dd 100644
@@ -798,9 +798,9 @@ struct scsi_host_template aic7xxx_driver
 
 /******************************** Macros **************************************/
 #define BUILD_SCSIID(ahc, cmd)						    \
-	((((cmd)->device->id << TID_SHIFT) & TID)			    \
-	| (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \
-	| (((cmd)->device->channel == 0) ? 0 : TWIN_CHNLB))
+	(((scmd_id(cmd) << TID_SHIFT) & TID)			    \
+	| ((scmd_channel(cmd) == 0) ? (ahc)->our_id : (ahc)->our_id_b) \
+	| ((scmd_channel(cmd) == 0) ? 0 : TWIN_CHNLB))
 
 /******************************** Bus DMA *************************************/
 int
@@ -1440,7 +1440,7 @@ ahc_linux_run_command(struct ahc_softc *
 	    && (ahc->features & AHC_SCB_BTT) == 0) {
 		int target_offset;
 
-		target_offset = cmd->device->id + cmd->device->channel * 8;
+		target_offset = scmd_id(cmd) + scmd_channel(cmd) * 8;
 		untagged_q = &(ahc->untagged_queues[target_offset]);
 		if (!TAILQ_EMPTY(untagged_q))
 			/* if we're already executing an untagged command
drivers/scsi/dc395x.c +12 -12
index c44af57..be4342b 100644
@@ -1647,7 +1647,7 @@ static u8 start_scsi(struct AdapterCtlBl
 /*polling:*/
 	/* Send CDB ..command block ......... */
 	dprintkdbg(DBG_KG, "start_scsi: (pid#%li) <%02i-%i> cmnd=0x%02x tag=%i\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun,
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun,
 		srb->cmd->cmnd[0], srb->tag_number);
 	if (srb->flag & AUTO_REQSENSE) {
 		DC395x_write8(acb, TRM_S1040_SCSI_FIFO, REQUEST_SENSE);
@@ -2102,7 +2102,7 @@ static void data_out_phase0(struct Adapt
 	u16 scsi_status = *pscsi_status;
 	u32 d_left_counter = 0;
 	dprintkdbg(DBG_0, "data_out_phase0: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 
 	/*
 	 * KG: We need to drain the buffers before we draw any conclusions!
@@ -2232,7 +2232,7 @@ static void data_out_phase1(struct Adapt
 		u16 *pscsi_status)
 {
 	dprintkdbg(DBG_0, "data_out_phase1: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 	clear_fifo(acb, "data_out_phase1");
 	/* do prepare before transfer when data out phase */
 	data_io_transfer(acb, srb, XFERDATAOUT);
@@ -2245,7 +2245,7 @@ static void data_in_phase0(struct Adapte
 	u16 scsi_status = *pscsi_status;
 	u32 d_left_counter = 0;
 	dprintkdbg(DBG_0, "data_in_phase0: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 
 	/*
 	 * KG: DataIn is much more tricky than DataOut. When the device is finished
@@ -2419,7 +2419,7 @@ static void data_in_phase1(struct Adapte
 		u16 *pscsi_status)
 {
 	dprintkdbg(DBG_0, "data_in_phase1: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 	data_io_transfer(acb, srb, XFERDATAIN);
 }
 
@@ -2431,7 +2431,7 @@ static void data_io_transfer(struct Adap
 	u8 bval;
 	dprintkdbg(DBG_0,
 		"data_io_transfer: (pid#%li) <%02i-%i> %c len=%i, sg=(%i/%i)\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun,
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun,
 		((io_dir & DMACMD_DIR) ? 'r' : 'w'),
 		srb->total_xfer_length, srb->sg_index, srb->sg_count);
 	if (srb == acb->tmp_srb)
@@ -2589,7 +2589,7 @@ static void status_phase0(struct Adapter
 		u16 *pscsi_status)
 {
 	dprintkdbg(DBG_0, "status_phase0: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 	srb->target_status = DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
 	srb->end_message = DC395x_read8(acb, TRM_S1040_SCSI_FIFO);	/* get message */
 	srb->state = SRB_COMPLETED;
@@ -2603,7 +2603,7 @@ static void status_phase1(struct Adapter
 		u16 *pscsi_status)
 {
 	dprintkdbg(DBG_0, "status_phase1: (pid#%li) <%02i-%i>\n",
-		srb->cmd->pid, srb->cmd->device->id, srb->cmd->device->lun);
+		srb->cmd->pid, scmd_id(srb->cmd), srb->cmd->device->lun);
 	srb->state = SRB_STATUS;
 	DC395x_write16(acb, TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
 	DC395x_write8(acb, TRM_S1040_SCSI_COMMAND, SCMD_COMP);
@@ -3515,7 +3515,7 @@ static void srb_done(struct AdapterCtlBl
 		if (srb->total_xfer_length)
 			dprintkdbg(DBG_KG, "srb_done: (pid#%li) <%02i-%i> "
 				"cmnd=0x%02x Missed %i bytes\n",
-				cmd->pid, cmd->device->id, cmd->device->lun,
+				cmd->pid, scmd_id(cmd), cmd->device->lun,
 				cmd->cmnd[0], srb->total_xfer_length);
 	}
 
@@ -3694,7 +3694,7 @@ static void request_sense(struct Adapter
 {
 	struct scsi_cmnd *cmd = srb->cmd;
 	dprintkdbg(DBG_1, "request_sense: (pid#%li) <%02i-%i>\n",
-		cmd->pid, cmd->device->id, cmd->device->lun);
+		cmd->pid, scmd_id(cmd), cmd->device->lun);
 
 	srb->flag |= AUTO_REQSENSE;
 	srb->adapter_status = 0;
@@ -3922,7 +3922,7 @@ static int dc395x_slave_alloc(struct scs
 	struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)scsi_device->host->hostdata;
 	struct DeviceCtlBlk *dcb;
 
-	dcb = device_alloc(acb, scsi_device->id, scsi_device->lun);
+	dcb = device_alloc(acb, sdev_id(scsi_device), scsi_device->lun);
 	if (!dcb)
 		return -ENOMEM;
 	adapter_add_device(acb, dcb);
@@ -3940,7 +3940,7 @@ static int dc395x_slave_alloc(struct scs
 static void dc395x_slave_destroy(struct scsi_device *scsi_device)
 {
 	struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)scsi_device->host->hostdata;
-	struct DeviceCtlBlk *dcb = find_dcb(acb, scsi_device->id, scsi_device->lun);
+	struct DeviceCtlBlk *dcb = find_dcb(acb, sdev_id(scsi_device), scsi_device->lun);
 	if (dcb)
 		adapter_remove_and_free_device(acb, dcb);
 }
drivers/scsi/eata.c +3 -6
index cd0fc64..f7b2f63 100644
@@ -2440,9 +2440,7 @@ static irqreturn_t ihdlr(int irq, struct
 
 		/* If there was a bus reset, redo operation on each target */
 		else if (tstatus != GOOD && SCpnt->device->type == TYPE_DISK
-			 && ha->target_redo[SCpnt->device->id][SCpnt->
-								  device->
-								  channel])
+			 && ha->target_redo[scmd_id(SCpnt)][scmd_channel(SCpnt)])
 			status = DID_BUS_BUSY << 16;
 
 		/* Works around a flaw in scsi.c */
@@ -2475,12 +2473,11 @@ static irqreturn_t ihdlr(int irq, struct
 	case ASST:		/* Selection Time Out */
 	case 0x02:		/* Command Time Out   */
 
-		if (ha->target_to[SCpnt->device->id][SCpnt->device->channel] > 1)
+		if (ha->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)] > 1)
 			status = DID_ERROR << 16;
 		else {
 			status = DID_TIME_OUT << 16;
-			ha->target_to[SCpnt->device->id][SCpnt->device->
-							    channel]++;
+			ha->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)]++;
 		}
 
 		break;
drivers/scsi/g_NCR5380.c +5 -5
index a3aa729..de3b6d0 100644
@@ -834,12 +834,12 @@ static int generic_NCR5380_proc_info(str
 	if (hostdata->pendingr || hostdata->pendingw)
 		PRINTP("\n");
 	shost_for_each_device(dev, scsi_ptr) {
-		unsigned long br = hostdata->bytes_read[dev->id];
-		unsigned long bw = hostdata->bytes_write[dev->id];
-		long tr = hostdata->time_read[dev->id] / HZ;
-		long tw = hostdata->time_write[dev->id] / HZ;
+		unsigned long br = hostdata->bytes_read[sdev_id(dev)];
+		unsigned long bw = hostdata->bytes_write[sdev_id(dev)];
+		long tr = hostdata->time_read[sdev_id(dev)] / HZ;
+		long tw = hostdata->time_write[sdev_id(dev)] / HZ;
 
-		PRINTP("  T:%d %s " ANDP dev->id ANDP(dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int) dev->type] : "Unknown");
+		PRINTP("  T:%d %s " ANDP sdev_id(dev) ANDP(dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int) dev->type] : "Unknown");
 		for (i = 0; i < 8; i++)
 			if (dev->vendor[i] >= 0x20)
 				*(buffer + (len++)) = dev->vendor[i];
drivers/scsi/gdth_proc.c +6 -6
index 1bd02f8..dc8863b 100644
@@ -951,8 +951,8 @@ static void gdth_wait_completion(int han
     for (i = 0; i < GDTH_MAXCMDS; ++i) {
         scp = ha->cmd_tab[i].cmnd;
 
-        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
-        t = scp->device->id;
+        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scmd_channel(scp);
+        t = scmd_id(scp);
         if (!SPECIAL_SCP(scp) && t == (unchar)id && 
             b == (unchar)busnum) {
             scp->SCp.have_data_in = 0;
@@ -976,8 +976,8 @@ static void gdth_stop_timeout(int hanum,
     spin_lock_irqsave(&ha->smp_lock, flags);
 
     for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
-        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
-        t = scp->device->id;
+        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scmd_channel(scp);
+        t = scmd_id(scp);
         if (t == (unchar)id && b == (unchar)busnum) {
             TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
             scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0);
@@ -997,8 +997,8 @@ static void gdth_start_timeout(int hanum
     spin_lock_irqsave(&ha->smp_lock, flags);
 
     for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
-        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
-        t = scp->device->id;
+        b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scmd_channel(scp);
+        t = scmd_id(scp);
         if (t == (unchar)id && b == (unchar)busnum) {
             TRACE2(("gdth_start_timeout(): update_timeout()\n"));
             gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual);
drivers/scsi/in2000.c +18 -18
index fe387b5..e6e49c0 100644
@@ -493,7 +493,7 @@ static void in2000_execute(struct Scsi_H
 		hostdata->input_Q = (Scsi_Cmnd *) cmd->host_scribble;
 
 #ifdef PROC_STATISTICS
-	hostdata->cmd_cnt[cmd->device->id]++;
+	hostdata->cmd_cnt[scmd_id(cmd)]++;
 #endif
 
 /*
@@ -501,9 +501,9 @@ static void in2000_execute(struct Scsi_H
  */
 
 	if (is_dir_out(cmd))
-		write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id);
+		write_3393(hostdata, WD_DESTINATION_ID, scmd_id(cmd));
 	else
-		write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
+		write_3393(hostdata, WD_DESTINATION_ID, scmd_id(cmd) | DSTID_DPD);
 
 /* Now we need to figure out whether or not this command is a good
  * candidate for disconnect/reselect. We guess to the best of our
@@ -584,11 +584,11 @@ static void in2000_execute(struct Scsi_H
  * unless we don't want to even _try_ synchronous transfers: In this
  * case we set SS_SET to make the defaults final.
  */
-		if (hostdata->sync_stat[cmd->device->id] == SS_UNSET) {
-			if (hostdata->sync_off & (1 << cmd->device->id))
-				hostdata->sync_stat[cmd->device->id] = SS_SET;
+		if (hostdata->sync_stat[scmd_id(cmd)] == SS_UNSET) {
+			if (hostdata->sync_off & (1 << scmd_id(cmd)))
+				hostdata->sync_stat[scmd_id(cmd)] = SS_SET;
 			else
-				hostdata->sync_stat[cmd->device->id] = SS_FIRST;
+				hostdata->sync_stat[scmd_id(cmd)] = SS_FIRST;
 		}
 		hostdata->state = S_SELECTING;
 		write_3393_count(hostdata, 0);	/* this guarantees a DATA_PHASE interrupt */
@@ -769,7 +769,7 @@ static void transfer_bytes(Scsi_Cmnd * c
 
 /* Set up hardware registers */
 
-	write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, hostdata->sync_xfer[cmd->device->id]);
+	write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, hostdata->sync_xfer[scmd_id(cmd)]);
 	write_3393_count(hostdata, cmd->SCp.this_residual);
 	write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_BUS);
 	write1_io(0, IO_FIFO_WRITE);	/* zero counter, assume write */
@@ -1224,8 +1224,8 @@ static irqreturn_t in2000_intr(int irqnu
 #ifdef SYNC_DEBUG
 			    printk("-REJ-");
 #endif
-			if (hostdata->sync_stat[cmd->device->id] == SS_WAITING)
-				hostdata->sync_stat[cmd->device->id] = SS_SET;
+			if (hostdata->sync_stat[scmd_id(cmd)] == SS_WAITING)
+				hostdata->sync_stat[scmd_id(cmd)] = SS_SET;
 			write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
 			hostdata->state = S_CONNECTED;
 			break;
@@ -1245,7 +1245,7 @@ static irqreturn_t in2000_intr(int irqnu
 				switch (ucp[2]) {	/* what's the EXTENDED code? */
 				case EXTENDED_SDTR:
 					id = calc_sync_xfer(ucp[3], ucp[4]);
-					if (hostdata->sync_stat[cmd->device->id] != SS_WAITING) {
+					if (hostdata->sync_stat[scmd_id(cmd)] != SS_WAITING) {
 
 /* A device has sent an unsolicited SDTR message; rather than go
  * through the effort of decoding it and then figuring out what
@@ -1263,14 +1263,14 @@ static irqreturn_t in2000_intr(int irqnu
 						hostdata->outgoing_msg[3] = hostdata->default_sx_per / 4;
 						hostdata->outgoing_msg[4] = 0;
 						hostdata->outgoing_len = 5;
-						hostdata->sync_xfer[cmd->device->id] = calc_sync_xfer(hostdata->default_sx_per / 4, 0);
+						hostdata->sync_xfer[scmd_id(cmd)] = calc_sync_xfer(hostdata->default_sx_per / 4, 0);
 					} else {
-						hostdata->sync_xfer[cmd->device->id] = id;
+						hostdata->sync_xfer[scmd_id(cmd)] = id;
 					}
 #ifdef SYNC_DEBUG
-					printk("sync_xfer=%02x", hostdata->sync_xfer[cmd->device->id]);
+					printk("sync_xfer=%02x", hostdata->sync_xfer[scmd_id(cmd)]);
 #endif
-					hostdata->sync_stat[cmd->device->id] = SS_SET;
+					hostdata->sync_stat[scmd_id(cmd)] = SS_SET;
 					write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
 					hostdata->state = S_CONNECTED;
 					break;
@@ -1465,7 +1465,7 @@ static irqreturn_t in2000_intr(int irqnu
 			hostdata->state = S_UNCONNECTED;
 
 #ifdef PROC_STATISTICS
-			hostdata->disc_done_cnt[cmd->device->id]++;
+			hostdata->disc_done_cnt[scmd_id(cmd)]++;
 #endif
 
 			break;
@@ -1562,9 +1562,9 @@ static irqreturn_t in2000_intr(int irqnu
 		 */
 
 		if (is_dir_out(cmd))
-			write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id);
+			write_3393(hostdata, WD_DESTINATION_ID, scmd_id(cmd));
 		else
-			write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
+			write_3393(hostdata, WD_DESTINATION_ID, scmd_id(cmd) | DSTID_DPD);
 		if (hostdata->level2 >= L2_RESELECT) {
 			write_3393_count(hostdata, 0);	/* we want a DATA_PHASE interrupt */
 			write_3393(hostdata, WD_COMMAND_PHASE, 0x45);
drivers/scsi/initio.c +1 -1
index ea6f3c0..c1404fb 100644
@@ -3019,7 +3019,7 @@ static int i91u_biosparam(struct scsi_de
 	TCS *pTcb;
 
 	pHcb = (HCS *) sdev->host->base;
-	pTcb = &pHcb->HCS_Tcs[sdev->id];
+	pTcb = &pHcb->HCS_Tcs[sdev_id(sdev)];
 
 	if (pTcb->TCS_DrvHead) {
 		info_array[0] = pTcb->TCS_DrvHead;
drivers/scsi/ipr.c +2 -1
index babd483..91746e7 100644
@@ -3758,7 +3758,8 @@ static void ipr_erp_start(struct ipr_ioa
 		 * will give CC/UA the next command.
 		 */
 		if (!res->resetting_device)
-			scsi_report_bus_reset(ioa_cfg->host, scsi_cmd->device->channel);
+			scsi_report_bus_reset(ioa_cfg->host,
+					      scmd_channel(scsi_cmd));
 		scsi_cmd->result |= (DID_ERROR << 16);
 		res->needs_sync_complete = 1;
 		break;
drivers/scsi/libata-scsi.c +2 -2
index 5885888..43efa56 100644
@@ -342,12 +342,12 @@ int ata_scsi_slave_config(struct scsi_de
 
 	blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
 
-	if (sdev->id < ATA_MAX_DEVICES) {
+	if (sdev_id(sdev) < ATA_MAX_DEVICES) {
 		struct ata_port *ap;
 		struct ata_device *dev;
 
 		ap = (struct ata_port *) &sdev->host->hostdata[0];
-		dev = &ap->device[sdev->id];
+		dev = &ap->device[sdev_id(sdev)];
 
 		/* TODO: 1024 is an arbitrary number, not the
 		 * hardware maximum.  This should be increased to
drivers/scsi/megaraid/mega_common.h +1 -1
index 69df1a9..7fb6788 100644
@@ -223,7 +223,7 @@ typedef struct {
 	(SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
 
 #define MRAID_IS_LOGICAL_SDEV(adp, sdev)	\
-	(sdev->channel == (adp)->max_channel) ? 1 : 0
+	(sdev_channel(sdev) == (adp)->max_channel) ? 1 : 0
 
 #define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical)	\
 	/*								\
drivers/scsi/megaraid/megaraid_mbox.c +3 -3
index d47be8e..8236fd4 100644
@@ -4165,15 +4165,15 @@ megaraid_sysfs_show_ldnum(struct device 
 
 			for (i = 0; i < MAX_LOGICAL_DRIVES_40LD; i++) {
 
-				mapped_sdev_id = sdev->id;
+				mapped_sdev_id = sdev_id(sdev);
 
-				if (sdev->id > adapter->init_id) {
+				if (sdev_id(sdev) > adapter->init_id) {
 					mapped_sdev_id -= 1;
 				}
 
 				if (raid_dev->curr_ldmap[i] == mapped_sdev_id) {
 
-					scsi_id = sdev->id;
+					scsi_id = sdev_id(sdev);
 
 					logical_drv = i;
 
drivers/scsi/megaraid/megaraid_sas.c +1 -1
index 4245d05..87a6103 100644
@@ -581,7 +581,7 @@ static inline struct megasas_cmd *megasa
 	 */
 	if (logical_cmd) {
 
-		if (scp->device->id >= MEGASAS_MAX_LD) {
+		if (scmd_id(scp) >= MEGASAS_MAX_LD) {
 			scp->result = DID_BAD_TARGET << 16;
 			return NULL;
 		}
drivers/scsi/megaraid/megaraid_sas.h +3 -3
index eaec9d5..3b5cf42 100644
@@ -1059,11 +1059,11 @@ struct megasas_instance {
 };
 
 #define MEGASAS_IS_LOGICAL(scp)						\
-	(scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
+	(scmd_channel(scp) < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
 
 #define MEGASAS_DEV_INDEX(inst, scp)					\
-	((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + 	\
-	scp->device->id
+	((scmd_channel(scp) % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
+	scmd_id(scp)
 
 struct megasas_cmd {
 
drivers/scsi/ncr53c8xx.c +1 -1
index 2434709..858101b 100644
@@ -4245,7 +4245,7 @@ void ncr_complete (struct ncb *np, struc
 		**	Allocate the lcb if not yet.
 		*/
 		if (!lp)
-			ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun);
+			ncr_alloc_lcb (np, scmd_id(cmd), cmd->device->lun);
 
 		tp->bytes     += cp->data_len;
 		tp->transfers ++;
drivers/scsi/nsp32.c +2 -2
index e4ff4f0..cd6920f 100644
@@ -961,7 +961,7 @@ static int nsp32_queuecommand(struct scs
 	nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,
 		  "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x "
 		  "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x",
-		  SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len,
+		  scmd_id(SCpnt), SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len,
 		  SCpnt->use_sg, SCpnt->request_buffer, SCpnt->request_bufflen);
 
 	if (data->CurrentSC != NULL) {
@@ -1074,7 +1074,7 @@ static int nsp32_queuecommand(struct scs
 
 	nsp32_dbg(NSP32_DEBUG_TARGETFLAG,
 		  "target: %d sync_flag: 0x%x syncreg: 0x%x ackwidth: 0x%x",
-		  SCpnt->device->id, target->sync_flag, target->syncreg,
+		  scmd_id(SCpnt), target->sync_flag, target->syncreg,
 		  target->ackwidth);
 
 	/* Selection */
drivers/scsi/pcmcia/nsp_cs.c +1 -1
index 3d2f710..2fe9532 100644
@@ -1051,7 +1051,7 @@ static irqreturn_t nspintr(int irq, void
 	}
 
 	tmpSC    = data->CurrentSC;
-	target   = tmpSC->device->id;
+	target   = scmd_id(tmpSC);
 	lun      = tmpSC->device->lun;
 	sync_neg = &(data->Sync[target].SyncNegotiation);
 
drivers/scsi/psi240i.c +1 -1
index 4322c95..df19d7e 100644
@@ -394,7 +394,7 @@ static int Psi240i_QueueCommand (Scsi_Cm
 	{
 	UCHAR		   *cdb = (UCHAR *)SCpnt->cmnd;					// Pointer to SCSI CDB
 	PADAPTER240I	padapter = HOSTDATA (SCpnt->device->host); 			// Pointer to adapter control structure
-	POUR_DEVICE 		pdev	 = &padapter->device [SCpnt->device->id];// Pointer to device information
+	POUR_DEVICE 		pdev	 = &padapter->device [scmd_id(SCpnt)];// Pointer to device information
 	UCHAR			rc;											// command return code
 
 	SCpnt->scsi_done = done;
drivers/scsi/qlogicfc.c +2 -2
index a4b3b3f..56110e3 100644
@@ -1325,9 +1325,9 @@ static int isp2x00_queuecommand(Scsi_Cmn
 		cmd->control_flags = cpu_to_le16(CFLAG_READ);
 
 	if (Cmnd->device->tagged_supported) {
-		if ((jiffies - hostdata->tag_ages[Cmnd->device->id]) > (2 * ISP_TIMEOUT)) {
+		if ((jiffies - hostdata->tag_ages[scmd_id(Cmnd)]) > (2 * ISP_TIMEOUT)) {
 			cmd->control_flags |= cpu_to_le16(CFLAG_ORDERED_TAG);
-			hostdata->tag_ages[Cmnd->device->id] = jiffies;
+			hostdata->tag_ages[scmd_id(Cmnd)] = jiffies;
 		} else
 			switch (Cmnd->tag) {
 			case HEAD_OF_QUEUE_TAG:
drivers/scsi/sym53c8xx_2/sym_glue.c +5 -5
index d76766c..5c2a086 100644
@@ -357,7 +357,7 @@ void sym_set_cam_result_error(struct sym
 			 * condition otherwise the device will always return
 			 * BUSY.  Use a big stick.
 			 */
-			sym_reset_scsi_target(np, cmd->device->id);
+			sym_reset_scsi_target(np, scmd_id(cmd));
 			cam_status = DID_ERROR;
 		}
 	} else if (cp->host_status == HS_COMPLETE) 	/* Bad SCSI status */
@@ -470,7 +470,7 @@ static int sym_queue_command(struct sym_
 	 *  Minimal checkings, so that we will not 
 	 *  go outside our tables.
 	 */
-	if (sdev->id == np->myaddr) {
+	if (sdev_id(sdev) == np->myaddr) {
 		sym_xpt_done2(np, cmd, DID_NO_CONNECT);
 		return 0;
 	}
@@ -804,7 +804,7 @@ prepare:
 		sts = sym_abort_scsiio(np, cmd, 1);
 		break;
 	case SYM_EH_DEVICE_RESET:
-		sts = sym_reset_scsi_target(np, cmd->device->id);
+		sts = sym_reset_scsi_target(np, scmd_id(cmd));
 		break;
 	case SYM_EH_BUS_RESET:
 		sym_reset_scsi_bus(np, 1);
@@ -1015,7 +1015,7 @@ static int sym53c8xx_slave_alloc(struct 
 static int sym53c8xx_slave_configure(struct scsi_device *device)
 {
 	struct sym_hcb *np = sym_get_hcb(device->host);
-	struct sym_tcb *tp = &np->target[device->id];
+	struct sym_tcb *tp = &np->target[sdev_id(device)];
 	struct sym_lcb *lp;
 	int reqtags, depth_to_use;
 
@@ -1023,7 +1023,7 @@ static int sym53c8xx_slave_configure(str
 	 *  Allocate the LCB if not yet.
 	 *  If it fail, we may well be in the sh*t. :)
 	 */
-	lp = sym_alloc_lcb(np, device->id, device->lun);
+	lp = sym_alloc_lcb(np, sdev_id(device), device->lun);
 	if (!lp)
 		return -ENOMEM;
 
#2 lore raw

PATCH 3/3 HCIL accraid updates

In reply to Jeff Garzik

commit 5ffa5fea1a50cdc3196e5f0c4e18b1aceb88125f

Author: Jeff Garzik <[email protected]>
Date:   Sat Oct 29 17:32:26 2005 -0400

[SCSI] aacraid: use scmd_id(), begin elimination of ID_LUN_TO_CONTAINER()

- begin elimination of ID_LUN_TO_CONTAINER(), which takes "id" and "lun" arguments, but only uses the "id" argument. This eliminates needless references to sdev->lun, which are always compiled out.

- begin using wrappers scmd_id(), sdev_id()

 drivers/scsi/aacraid/aachba.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/aacraid/aachba.c +4 -4
index 2a128a1..8b797d6 100644
@@ -908,7 +908,7 @@ static void io_callback(void *context, s
 	scsicmd = (struct scsi_cmnd *) context;
 
 	dev = (struct aac_dev *)scsicmd->device->host->hostdata;
-	cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
+	cid = scmd_id(scsicmd);
 
 	if (nblank(dprintk(x))) {
 		u64 lba;
@@ -1353,7 +1353,7 @@ static void synchronize_callback(void *c
 	else {
 		struct scsi_device *sdev = cmd->device;
 		struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
-		u32 cid = ID_LUN_TO_CONTAINER(sdev->id, sdev->lun);
+		u32 cid = sdev_id(sdev);
 		printk(KERN_WARNING 
 		     "synchronize_callback: synchronize failed, status = %d\n",
 		     le32_to_cpu(synchronizereply->status));
@@ -1547,7 +1547,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsi
 	{
 		struct inquiry_data inq_data;
 
-		dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->device->id));
+		dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scmd_id(scsicmd)));
 		memset(&inq_data, 0, sizeof (struct inquiry_data));
 
 		inq_data.inqd_ver = 2;	/* claim compliance to SCSI-2 */
@@ -1774,7 +1774,7 @@ static int query_disk(struct aac_dev *de
 	if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
 		return -EFAULT;
 	if (qd.cnum == -1)
-		qd.cnum = ID_LUN_TO_CONTAINER(qd.id, qd.lun);
+		qd.cnum = qd.id;
 	else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) 
 	{
 		if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)