Skip to content

Commit

Permalink
[SCSI] mpt fusion: add use of shost_priv and remove all the typecasting
Browse files Browse the repository at this point in the history
The driver is currently typecasting to obtain the shost hostdata. The
driver is updated to use the shost_priv macro.

Signed-off-by: Eric Moore <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
Eric Moore authored and James Bottomley committed Oct 12, 2007
1 parent cce99c6 commit e7eae9f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 76 deletions.
10 changes: 5 additions & 5 deletions drivers/message/fusion/mptctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
if (ioctl->ioc->sh == NULL)
return -EPERM;

hd = (MPT_SCSI_HOST *) ioctl->ioc->sh->hostdata;
hd = shost_priv(ioctl->ioc->sh);
if (hd == NULL)
return -EPERM;

Expand Down Expand Up @@ -449,7 +449,7 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc)
MPT_SCSI_HOST * hd;
unsigned long flags;

hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
hd = shost_priv(ioc->sh);
if (hd == NULL)
return;

Expand Down Expand Up @@ -2026,7 +2026,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
case MPI_FUNCTION_SCSI_TASK_MGMT:
{
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 - "
"SCSI driver not loaded or SCSI host not found. \n",
ioc->name, __FILE__, __LINE__);
Expand Down Expand Up @@ -2466,7 +2466,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
karg.soft_resets = 0;
karg.timeouts = 0;
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)) {
karg.hard_resets = hd->hard_resets;
Expand Down Expand Up @@ -2683,7 +2683,7 @@ mptctl_hp_targetinfo(unsigned long arg)
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)
karg.select_timeouts = hd->sel_timeout[karg.hdr.id];

Expand Down
17 changes: 7 additions & 10 deletions drivers/message/fusion/mptfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,15 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
int ready;
MPT_ADAPTER *ioc;

hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
hd = shost_priv(SCpnt->device->host);
ioc = hd->ioc;
spin_lock_irqsave(shost->host_lock, flags);
while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
spin_unlock_irqrestore(shost->host_lock, flags);
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"mptfc_block_error_handler.%d: %d:%d, port status is "
"DID_IMM_RETRY, deferring %s recovery.\n",
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
ioc->name, ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun, caller));
msleep(1000);
spin_lock_irqsave(shost->host_lock, flags);
Expand All @@ -216,16 +215,14 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, failing recovery, "
"port state %d, vdevice %p.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
ioc->name, ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun, ready,
SCpnt->device->hostdata));
return FAILED;
}
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, executing recovery.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
ioc->name, ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun));
return (*func)(SCpnt);
}
Expand Down Expand Up @@ -615,7 +612,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
if (!rport || fc_remote_port_chkready(rport))
return -ENXIO;

hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
hd = shost_priv(sdev->host);
ioc = hd->ioc;

vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
Expand Down Expand Up @@ -1279,7 +1276,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)

spin_unlock_irqrestore(&ioc->FreeQlock, flags);

hd = (MPT_SCSI_HOST *) sh->hostdata;
hd = shost_priv(sh);
hd->ioc = ioc;

/* SCSI needs scsi_cmnd lookup table!
Expand Down Expand Up @@ -1386,7 +1383,7 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
ioc->name, event));

if (ioc->sh == NULL ||
((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL))
((hd = shost_priv(ioc->sh)) == NULL))
return 1;

switch (event) {
Expand Down
14 changes: 7 additions & 7 deletions drivers/message/fusion/mptsas.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ static void
mptsas_target_reset_queue(MPT_ADAPTER *ioc,
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;
struct mptsas_target_reset_event *target_reset_list;
u8 id, channel;
Expand Down Expand Up @@ -622,7 +622,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,
static void
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 mptsas_target_reset_event *target_reset_list;
struct mptsas_hotplug_event *ev;
Expand Down Expand Up @@ -739,7 +739,7 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)

if (!ioc->sh || !ioc->sh->hostdata)
goto out;
hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
hd = shost_priv(ioc->sh);
if (!hd->ioc)
goto out;

Expand Down Expand Up @@ -839,7 +839,7 @@ static int
mptsas_target_alloc(struct scsi_target *starget)
{
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;
u8 id, channel;
struct sas_rphy *rphy;
Expand Down Expand Up @@ -908,7 +908,7 @@ static void
mptsas_target_destroy(struct scsi_target *starget)
{
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 mptsas_portinfo *p;
int i;
Expand Down Expand Up @@ -941,7 +941,7 @@ static int
mptsas_slave_alloc(struct scsi_device *sdev)
{
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 mptsas_portinfo *p;
VirtDevice *vdevice;
Expand Down Expand Up @@ -3215,7 +3215,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
sh->sg_tablesize = numSGE;
}

hd = (MPT_SCSI_HOST *) sh->hostdata;
hd = shost_priv(sh);
hd->ioc = ioc;

/* SCSI needs scsi_cmnd lookup table!
Expand Down
Loading

0 comments on commit e7eae9f

Please sign in to comment.