Commit e7eae9f6 authored by Eric Moore's avatar Eric Moore Committed by James Bottomley

[SCSI] mpt fusion: add use of shost_priv and remove all the typecasting

The driver is currently typecasting to obtain the shost hostdata. The
driver is updated to use the shost_priv macro.
Signed-off-by: default avatarEric Moore <Eric.Moore@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent cce99c69
...@@ -348,7 +348,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) ...@@ -348,7 +348,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
if (ioctl->ioc->sh == NULL) if (ioctl->ioc->sh == NULL)
return -EPERM; return -EPERM;
hd = (MPT_SCSI_HOST *) ioctl->ioc->sh->hostdata; hd = shost_priv(ioctl->ioc->sh);
if (hd == NULL) if (hd == NULL)
return -EPERM; return -EPERM;
...@@ -449,7 +449,7 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc) ...@@ -449,7 +449,7 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc)
MPT_SCSI_HOST * hd; MPT_SCSI_HOST * hd;
unsigned long flags; unsigned long flags;
hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; hd = shost_priv(ioc->sh);
if (hd == NULL) if (hd == NULL)
return; return;
...@@ -2026,7 +2026,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) ...@@ -2026,7 +2026,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
case MPI_FUNCTION_SCSI_TASK_MGMT: case MPI_FUNCTION_SCSI_TASK_MGMT:
{ {
MPT_SCSI_HOST *hd = NULL; MPT_SCSI_HOST *hd = NULL;
if ((ioc->sh == NULL) || ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) { if ((ioc->sh == NULL) || ((hd = shost_priv(ioc->sh)) == NULL)) {
printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - "
"SCSI driver not loaded or SCSI host not found. \n", "SCSI driver not loaded or SCSI host not found. \n",
ioc->name, __FILE__, __LINE__); ioc->name, __FILE__, __LINE__);
...@@ -2466,7 +2466,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) ...@@ -2466,7 +2466,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
karg.soft_resets = 0; karg.soft_resets = 0;
karg.timeouts = 0; karg.timeouts = 0;
if (ioc->sh != NULL) { if (ioc->sh != NULL) {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
if (hd && (cim_rev == 1)) { if (hd && (cim_rev == 1)) {
karg.hard_resets = hd->hard_resets; karg.hard_resets = hd->hard_resets;
...@@ -2683,7 +2683,7 @@ mptctl_hp_targetinfo(unsigned long arg) ...@@ -2683,7 +2683,7 @@ mptctl_hp_targetinfo(unsigned long arg)
pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma);
} }
} }
hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; hd = shost_priv(ioc->sh);
if (hd != NULL) if (hd != NULL)
karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; karg.select_timeouts = hd->sel_timeout[karg.hdr.id];
......
...@@ -196,7 +196,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt, ...@@ -196,7 +196,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
int ready; int ready;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; hd = shost_priv(SCpnt->device->host);
ioc = hd->ioc; ioc = hd->ioc;
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) { while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
...@@ -204,8 +204,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt, ...@@ -204,8 +204,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"mptfc_block_error_handler.%d: %d:%d, port status is " "mptfc_block_error_handler.%d: %d:%d, port status is "
"DID_IMM_RETRY, deferring %s recovery.\n", "DID_IMM_RETRY, deferring %s recovery.\n",
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ioc->name, ioc->sh->host_no,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun, caller)); SCpnt->device->id, SCpnt->device->lun, caller));
msleep(1000); msleep(1000);
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
...@@ -216,16 +215,14 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt, ...@@ -216,16 +215,14 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, failing recovery, " "%s.%d: %d:%d, failing recovery, "
"port state %d, vdevice %p.\n", caller, "port state %d, vdevice %p.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ioc->name, ioc->sh->host_no,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun, ready, SCpnt->device->id, SCpnt->device->lun, ready,
SCpnt->device->hostdata)); SCpnt->device->hostdata));
return FAILED; return FAILED;
} }
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, executing recovery.\n", caller, "%s.%d: %d:%d, executing recovery.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ioc->name, ioc->sh->host_no,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun)); SCpnt->device->id, SCpnt->device->lun));
return (*func)(SCpnt); return (*func)(SCpnt);
} }
...@@ -615,7 +612,7 @@ mptfc_slave_alloc(struct scsi_device *sdev) ...@@ -615,7 +612,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
if (!rport || fc_remote_port_chkready(rport)) if (!rport || fc_remote_port_chkready(rport))
return -ENXIO; return -ENXIO;
hd = (MPT_SCSI_HOST *)sdev->host->hostdata; hd = shost_priv(sdev->host);
ioc = hd->ioc; ioc = hd->ioc;
vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
...@@ -1279,7 +1276,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1279,7 +1276,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
spin_unlock_irqrestore(&ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
hd = (MPT_SCSI_HOST *) sh->hostdata; hd = shost_priv(sh);
hd->ioc = ioc; hd->ioc = ioc;
/* SCSI needs scsi_cmnd lookup table! /* SCSI needs scsi_cmnd lookup table!
...@@ -1386,7 +1383,7 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) ...@@ -1386,7 +1383,7 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
ioc->name, event)); ioc->name, event));
if (ioc->sh == NULL || if (ioc->sh == NULL ||
((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) ((hd = shost_priv(ioc->sh)) == NULL))
return 1; return 1;
switch (event) { switch (event) {
......
...@@ -575,7 +575,7 @@ static void ...@@ -575,7 +575,7 @@ static void
mptsas_target_reset_queue(MPT_ADAPTER *ioc, mptsas_target_reset_queue(MPT_ADAPTER *ioc,
EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
VirtTarget *vtarget = NULL; VirtTarget *vtarget = NULL;
struct mptsas_target_reset_event *target_reset_list; struct mptsas_target_reset_event *target_reset_list;
u8 id, channel; u8 id, channel;
...@@ -622,7 +622,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc, ...@@ -622,7 +622,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,
static void static void
mptsas_dev_reset_complete(MPT_ADAPTER *ioc) mptsas_dev_reset_complete(MPT_ADAPTER *ioc)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
struct list_head *head = &hd->target_reset_list; struct list_head *head = &hd->target_reset_list;
struct mptsas_target_reset_event *target_reset_list; struct mptsas_target_reset_event *target_reset_list;
struct mptsas_hotplug_event *ev; struct mptsas_hotplug_event *ev;
...@@ -739,7 +739,7 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) ...@@ -739,7 +739,7 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
if (!ioc->sh || !ioc->sh->hostdata) if (!ioc->sh || !ioc->sh->hostdata)
goto out; goto out;
hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; hd = shost_priv(ioc->sh);
if (!hd->ioc) if (!hd->ioc)
goto out; goto out;
...@@ -839,7 +839,7 @@ static int ...@@ -839,7 +839,7 @@ static int
mptsas_target_alloc(struct scsi_target *starget) mptsas_target_alloc(struct scsi_target *starget)
{ {
struct Scsi_Host *host = dev_to_shost(&starget->dev); struct Scsi_Host *host = dev_to_shost(&starget->dev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
VirtTarget *vtarget; VirtTarget *vtarget;
u8 id, channel; u8 id, channel;
struct sas_rphy *rphy; struct sas_rphy *rphy;
...@@ -908,7 +908,7 @@ static void ...@@ -908,7 +908,7 @@ static void
mptsas_target_destroy(struct scsi_target *starget) mptsas_target_destroy(struct scsi_target *starget)
{ {
struct Scsi_Host *host = dev_to_shost(&starget->dev); struct Scsi_Host *host = dev_to_shost(&starget->dev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
struct sas_rphy *rphy; struct sas_rphy *rphy;
struct mptsas_portinfo *p; struct mptsas_portinfo *p;
int i; int i;
...@@ -941,7 +941,7 @@ static int ...@@ -941,7 +941,7 @@ static int
mptsas_slave_alloc(struct scsi_device *sdev) mptsas_slave_alloc(struct scsi_device *sdev)
{ {
struct Scsi_Host *host = sdev->host; struct Scsi_Host *host = sdev->host;
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
struct sas_rphy *rphy; struct sas_rphy *rphy;
struct mptsas_portinfo *p; struct mptsas_portinfo *p;
VirtDevice *vdevice; VirtDevice *vdevice;
...@@ -3215,7 +3215,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -3215,7 +3215,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
sh->sg_tablesize = numSGE; sh->sg_tablesize = numSGE;
} }
hd = (MPT_SCSI_HOST *) sh->hostdata; hd = shost_priv(sh);
hd->ioc = ioc; hd->ioc = ioc;
/* SCSI needs scsi_cmnd lookup table! /* SCSI needs scsi_cmnd lookup table!
......
...@@ -647,8 +647,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) ...@@ -647,8 +647,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
VirtDevice *vdevice; VirtDevice *vdevice;
VirtTarget *vtarget; VirtTarget *vtarget;
hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; hd = shost_priv(ioc->sh);
req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
req_idx_MR = (mr != NULL) ? req_idx_MR = (mr != NULL) ?
le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx; le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx;
...@@ -1105,7 +1104,7 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI ...@@ -1105,7 +1104,7 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
return; return;
if (sc->device->host == NULL) if (sc->device->host == NULL)
return; return;
if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) if ((hd = shost_priv(sc->device->host)) == NULL)
return; return;
ioc = hd->ioc; ioc = hd->ioc;
if (time - hd->last_queue_full > 10 * HZ) { if (time - hd->last_queue_full > 10 * HZ) {
...@@ -1137,7 +1136,7 @@ mptscsih_remove(struct pci_dev *pdev) ...@@ -1137,7 +1136,7 @@ mptscsih_remove(struct pci_dev *pdev)
scsi_remove_host(host); scsi_remove_host(host);
if((hd = (MPT_SCSI_HOST *)host->hostdata) == NULL) if((hd = shost_priv(host)) == NULL)
return; return;
mptscsih_shutdown(pdev); mptscsih_shutdown(pdev);
...@@ -1174,15 +1173,6 @@ mptscsih_remove(struct pci_dev *pdev) ...@@ -1174,15 +1173,6 @@ mptscsih_remove(struct pci_dev *pdev)
void void
mptscsih_shutdown(struct pci_dev *pdev) mptscsih_shutdown(struct pci_dev *pdev)
{ {
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
struct Scsi_Host *host = ioc->sh;
MPT_SCSI_HOST *hd;
if(!host)
return;
hd = (MPT_SCSI_HOST *)host->hostdata;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -1228,7 +1218,7 @@ mptscsih_info(struct Scsi_Host *SChost) ...@@ -1228,7 +1218,7 @@ mptscsih_info(struct Scsi_Host *SChost)
MPT_SCSI_HOST *h; MPT_SCSI_HOST *h;
int size = 0; int size = 0;
h = (MPT_SCSI_HOST *)SChost->hostdata; h = shost_priv(SChost);
if (h) { if (h) {
if (h->info_kbuf == NULL) if (h->info_kbuf == NULL)
...@@ -1322,7 +1312,7 @@ int ...@@ -1322,7 +1312,7 @@ int
mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
int length, int func) int length, int func)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
int size = 0; int size = 0;
...@@ -1371,7 +1361,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) ...@@ -1371,7 +1361,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
int ii; int ii;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; hd = shost_priv(SCpnt->device->host);
ioc = hd->ioc; ioc = hd->ioc;
lun = SCpnt->device->lun; lun = SCpnt->device->lun;
SCpnt->scsi_done = done; SCpnt->scsi_done = done;
...@@ -1807,7 +1797,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) ...@@ -1807,7 +1797,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
/* If we can't locate our host adapter structure, return FAILED status. /* If we can't locate our host adapter structure, return FAILED status.
*/ */
if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { if ((hd = shost_priv(SCpnt->device->host)) == NULL) {
SCpnt->result = DID_RESET << 16; SCpnt->result = DID_RESET << 16;
SCpnt->scsi_done(SCpnt); SCpnt->scsi_done(SCpnt);
printk(KERN_ERR MYNAM ": task abort: " printk(KERN_ERR MYNAM ": task abort: "
...@@ -1913,7 +1903,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) ...@@ -1913,7 +1903,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
/* If we can't locate our host adapter structure, return FAILED status. /* If we can't locate our host adapter structure, return FAILED status.
*/ */
if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ if ((hd = shost_priv(SCpnt->device->host)) == NULL){
printk(KERN_ERR MYNAM ": target reset: " printk(KERN_ERR MYNAM ": target reset: "
"Can't locate host! (sc=%p)\n", SCpnt); "Can't locate host! (sc=%p)\n", SCpnt);
return FAILED; return FAILED;
...@@ -1976,7 +1966,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) ...@@ -1976,7 +1966,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
/* If we can't locate our host adapter structure, return FAILED status. /* If we can't locate our host adapter structure, return FAILED status.
*/ */
if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ if ((hd = shost_priv(SCpnt->device->host)) == NULL){
printk(KERN_ERR MYNAM ": bus reset: " printk(KERN_ERR MYNAM ": bus reset: "
"Can't locate host! (sc=%p)\n", SCpnt); "Can't locate host! (sc=%p)\n", SCpnt);
return FAILED; return FAILED;
...@@ -2020,7 +2010,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) ...@@ -2020,7 +2010,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
/* If we can't locate the host to reset, then we failed. */ /* If we can't locate the host to reset, then we failed. */
if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ if ((hd = shost_priv(SCpnt->device->host)) == NULL){
printk(KERN_ERR MYNAM ": host reset: " printk(KERN_ERR MYNAM ": host reset: "
"Can't locate host! (sc=%p)\n", SCpnt); "Can't locate host! (sc=%p)\n", SCpnt);
return FAILED; return FAILED;
...@@ -2186,7 +2176,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m ...@@ -2186,7 +2176,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
return 1; return 1;
} }
hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; hd = shost_priv(ioc->sh);
pScsiTmReply = (SCSITaskMgmtReply_t*)mr; pScsiTmReply = (SCSITaskMgmtReply_t*)mr;
pScsiTmReq = (SCSITaskMgmt_t*)mf; pScsiTmReq = (SCSITaskMgmt_t*)mf;
tmType = pScsiTmReq->TaskType; tmType = pScsiTmReq->TaskType;
...@@ -2380,7 +2370,7 @@ void ...@@ -2380,7 +2370,7 @@ void
mptscsih_slave_destroy(struct scsi_device *sdev) mptscsih_slave_destroy(struct scsi_device *sdev)
{ {
struct Scsi_Host *host = sdev->host; struct Scsi_Host *host = sdev->host;
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
VirtTarget *vtarget; VirtTarget *vtarget;
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
...@@ -2407,7 +2397,7 @@ mptscsih_slave_destroy(struct scsi_device *sdev) ...@@ -2407,7 +2397,7 @@ mptscsih_slave_destroy(struct scsi_device *sdev)
int int
mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; MPT_SCSI_HOST *hd = shost_priv(sdev->host);
VirtTarget *vtarget; VirtTarget *vtarget;
struct scsi_target *starget; struct scsi_target *starget;
int max_depth; int max_depth;
...@@ -2452,7 +2442,7 @@ mptscsih_slave_configure(struct scsi_device *sdev) ...@@ -2452,7 +2442,7 @@ mptscsih_slave_configure(struct scsi_device *sdev)
VirtTarget *vtarget; VirtTarget *vtarget;
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; MPT_SCSI_HOST *hd = shost_priv(sh);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
starget = scsi_target(sdev); starget = scsi_target(sdev);
...@@ -2567,7 +2557,7 @@ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc) ...@@ -2567,7 +2557,7 @@ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
MPT_SCSI_HOST *hd; MPT_SCSI_HOST *hd;
int i; int i;
hd = (MPT_SCSI_HOST *) sc->device->host->hostdata; hd = shost_priv(sc->device->host);
for (i = 0; i < hd->ioc->req_depth; i++) { for (i = 0; i < hd->ioc->req_depth; i++) {
if (hd->ScsiLookup[i] == sc) { if (hd->ScsiLookup[i] == sc) {
...@@ -2595,10 +2585,10 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) ...@@ -2595,10 +2585,10 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
* before all scsi hosts have been attached, then an alt_ioc * before all scsi hosts have been attached, then an alt_ioc
* may have a NULL sh pointer. * may have a NULL sh pointer.
*/ */
if ((ioc->sh == NULL) || (ioc->sh->hostdata == NULL)) if (ioc->sh == NULL || shost_priv(ioc->sh) == NULL)
return 0; return 0;
else else
hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; hd = shost_priv(ioc->sh);
if (reset_phase == MPT_IOC_SETUP_RESET) { if (reset_phase == MPT_IOC_SETUP_RESET) {
dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name)); dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name));
...@@ -2691,7 +2681,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) ...@@ -2691,7 +2681,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
ioc->name, event)); ioc->name, event));
if (ioc->sh == NULL || if (ioc->sh == NULL ||
((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) ((hd = shost_priv(ioc->sh)) == NULL))
return 1; return 1;
switch (event) { switch (event) {
...@@ -2770,7 +2760,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) ...@@ -2770,7 +2760,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
int completionCode; int completionCode;
u16 req_idx; u16 req_idx;
hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; hd = shost_priv(ioc->sh);
if ((mf == NULL) || if ((mf == NULL) ||
(mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) {
...@@ -3254,7 +3244,7 @@ static ssize_t ...@@ -3254,7 +3244,7 @@ static ssize_t
mptscsih_version_fw_show(struct class_device *cdev, char *buf) mptscsih_version_fw_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
...@@ -3269,7 +3259,7 @@ static ssize_t ...@@ -3269,7 +3259,7 @@ static ssize_t
mptscsih_version_bios_show(struct class_device *cdev, char *buf) mptscsih_version_bios_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
...@@ -3284,7 +3274,7 @@ static ssize_t ...@@ -3284,7 +3274,7 @@ static ssize_t
mptscsih_version_mpi_show(struct class_device *cdev, char *buf) mptscsih_version_mpi_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
...@@ -3295,7 +3285,7 @@ static ssize_t ...@@ -3295,7 +3285,7 @@ static ssize_t
mptscsih_version_product_show(struct class_device *cdev, char *buf) mptscsih_version_product_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
...@@ -3307,7 +3297,7 @@ static ssize_t ...@@ -3307,7 +3297,7 @@ static ssize_t
mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02xh\n", return snprintf(buf, PAGE_SIZE, "%02xh\n",
...@@ -3320,7 +3310,7 @@ static ssize_t ...@@ -3320,7 +3310,7 @@ static ssize_t
mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
...@@ -3332,7 +3322,7 @@ static ssize_t ...@@ -3332,7 +3322,7 @@ static ssize_t
mptscsih_board_name_show(struct class_device *cdev, char *buf) mptscsih_board_name_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
...@@ -3343,7 +3333,7 @@ static ssize_t ...@@ -3343,7 +3333,7 @@ static ssize_t
mptscsih_board_assembly_show(struct class_device *cdev, char *buf) mptscsih_board_assembly_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
...@@ -3355,7 +3345,7 @@ static ssize_t ...@@ -3355,7 +3345,7 @@ static ssize_t
mptscsih_board_tracer_show(struct class_device *cdev, char *buf) mptscsih_board_tracer_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
...@@ -3367,7 +3357,7 @@ static ssize_t ...@@ -3367,7 +3357,7 @@ static ssize_t
mptscsih_io_delay_show(struct class_device *cdev, char *buf) mptscsih_io_delay_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
...@@ -3379,7 +3369,7 @@ static ssize_t ...@@ -3379,7 +3369,7 @@ static ssize_t
mptscsih_device_delay_show(struct class_device *cdev, char *buf) mptscsih_device_delay_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
...@@ -3391,7 +3381,7 @@ static ssize_t ...@@ -3391,7 +3381,7 @@ static ssize_t
mptscsih_debug_level_show(struct class_device *cdev, char *buf) mptscsih_debug_level_show(struct class_device *cdev, char *buf)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
...@@ -3401,7 +3391,7 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf, ...@@ -3401,7 +3391,7 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
size_t count) size_t count)
{ {
struct Scsi_Host *host = class_to_shost(cdev); struct Scsi_Host *host = class_to_shost(cdev);
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
int val = 0; int val = 0;
......
...@@ -397,7 +397,7 @@ mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) ...@@ -397,7 +397,7 @@ mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id)
static int mptspi_target_alloc(struct scsi_target *starget) static int mptspi_target_alloc(struct scsi_target *starget)
{ {
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(shost);
VirtTarget *vtarget; VirtTarget *vtarget;
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
...@@ -514,7 +514,7 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, ...@@ -514,7 +514,7 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget,
struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0) struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0)
{ {
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(shost);
struct _MPT_ADAPTER *ioc = hd->ioc; struct _MPT_ADAPTER *ioc = hd->ioc;
struct _CONFIG_PAGE_SCSI_DEVICE_0 *pg0; struct _CONFIG_PAGE_SCSI_DEVICE_0 *pg0;
dma_addr_t pg0_dma; dma_addr_t pg0_dma;
...@@ -702,7 +702,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, ...@@ -702,7 +702,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
static int mptspi_slave_alloc(struct scsi_device *sdev) static int mptspi_slave_alloc(struct scsi_device *sdev)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; MPT_SCSI_HOST *hd = shost_priv(sdev->host);
VirtTarget *vtarget; VirtTarget *vtarget;
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
...@@ -735,8 +735,7 @@ static int mptspi_slave_alloc(struct scsi_device *sdev) ...@@ -735,8 +735,7 @@ static int mptspi_slave_alloc(struct scsi_device *sdev)
static int mptspi_slave_configure(struct scsi_device *sdev) static int mptspi_slave_configure(struct scsi_device *sdev)
{ {
struct _MPT_SCSI_HOST *hd = struct _MPT_SCSI_HOST *hd = shost_priv(sdev->host);
(struct _MPT_SCSI_HOST *)sdev->host->hostdata;
VirtTarget *vtarget = scsi_target(sdev)->hostdata; VirtTarget *vtarget = scsi_target(sdev)->hostdata;
int ret; int ret;
...@@ -764,7 +763,7 @@ static int mptspi_slave_configure(struct scsi_device *sdev) ...@@ -764,7 +763,7 @@ static int mptspi_slave_configure(struct scsi_device *sdev)
static int static int
mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
{ {
struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host);
VirtDevice *vdevice = SCpnt->device->hostdata; VirtDevice *vdevice = SCpnt->device->hostdata;
MPT_ADAPTER *ioc = hd->ioc; MPT_ADAPTER *ioc = hd->ioc;
...@@ -839,7 +838,7 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, ...@@ -839,7 +838,7 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget,
struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1) struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1)
{ {
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(shost);
struct _MPT_ADAPTER *ioc = hd->ioc; struct _MPT_ADAPTER *ioc = hd->ioc;
struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1; struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1;
dma_addr_t pg1_dma; dma_addr_t pg1_dma;
...@@ -1027,7 +1026,7 @@ static void mptspi_write_qas(struct scsi_target *starget, int qas) ...@@ -1027,7 +1026,7 @@ static void mptspi_write_qas(struct scsi_target *starget, int qas)
{ {
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(shost);
VirtTarget *vtarget = starget->hostdata; VirtTarget *vtarget = starget->hostdata;
u32 nego; u32 nego;
...@@ -1137,7 +1136,7 @@ static int ...@@ -1137,7 +1136,7 @@ static int
mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
{ {
u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
if (hd && event == MPI_EVENT_INTEGRATED_RAID) { if (hd && event == MPI_EVENT_INTEGRATED_RAID) {
int reason int reason
...@@ -1267,7 +1266,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd) ...@@ -1267,7 +1266,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd)
static int static int
mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
{ {
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
int rc; int rc;
rc = mptscsih_ioc_reset(ioc, reset_phase); rc = mptscsih_ioc_reset(ioc, reset_phase);
...@@ -1286,7 +1285,7 @@ static int ...@@ -1286,7 +1285,7 @@ static int
mptspi_resume(struct pci_dev *pdev) mptspi_resume(struct pci_dev *pdev)
{ {
MPT_ADAPTER *ioc = pci_get_drvdata(pdev); MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
int rc; int rc;
rc = mptscsih_resume(pdev); rc = mptscsih_resume(pdev);
...@@ -1441,7 +1440,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1441,7 +1440,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
spin_unlock_irqrestore(&ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
hd = (MPT_SCSI_HOST *) sh->hostdata; hd = shost_priv(sh);
hd->ioc = ioc; hd->ioc = ioc;
/* SCSI needs scsi_cmnd lookup table! /* SCSI needs scsi_cmnd lookup table!
......
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