Skip to content

Commit

Permalink
[SCSI] mpt fusion: removing references to hd->ioc
Browse files Browse the repository at this point in the history
Cleaning up code by accesing the ioc pointer directly instead of via hd->ioc.  In the future, most data members of struct MPT_SCSI_HOST will be either deleted or moved to struct MPT_ADAPTER.

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 a69de50 commit e80b002
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 162 deletions.
17 changes: 10 additions & 7 deletions drivers/message/fusion/mptfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
unsigned long flags;
int ready;
MPT_ADAPTER *ioc;

hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
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 (hd->ioc, printk(MYIOC_s_DEBUG_FMT
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,
Expand All @@ -211,7 +213,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
spin_unlock_irqrestore(shost->host_lock, flags);

if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
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,
Expand All @@ -220,7 +222,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
SCpnt->device->hostdata));
return FAILED;
}
dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
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,
Expand Down Expand Up @@ -605,7 +607,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
VirtDevice *vdevice;
struct scsi_target *starget;
struct fc_rport *rport;

MPT_ADAPTER *ioc;

starget = scsi_target(sdev);
rport = starget_to_rport(starget);
Expand All @@ -614,11 +616,12 @@ mptfc_slave_alloc(struct scsi_device *sdev)
return -ENXIO;

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

vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
if (!vdevice) {
printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
hd->ioc->name, sizeof(VirtDevice));
ioc->name, sizeof(VirtDevice));
return -ENOMEM;
}

Expand All @@ -627,7 +630,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
vtarget = starget->hostdata;

if (vtarget->num_luns == 0) {
vtarget->ioc_id = hd->ioc->id;
vtarget->ioc_id = ioc->id;
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
}

Expand All @@ -637,7 +640,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
vtarget->num_luns++;


mptfc_dump_lun_info(hd->ioc, rport, sdev, vtarget);
mptfc_dump_lun_info(ioc, rport, sdev, vtarget);

return 0;
}
Expand Down
37 changes: 20 additions & 17 deletions drivers/message/fusion/mptsas.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,14 @@ mptsas_target_alloc(struct scsi_target *starget)
struct sas_rphy *rphy;
struct mptsas_portinfo *p;
int i;
MPT_ADAPTER *ioc = hd->ioc;

vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
if (!vtarget)
return -ENOMEM;

vtarget->starget = starget;
vtarget->ioc_id = hd->ioc->id;
vtarget->ioc_id = ioc->id;
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
id = starget->id;
channel = 0;
Expand All @@ -861,15 +862,15 @@ mptsas_target_alloc(struct scsi_target *starget)
* RAID volumes placed beyond the last expected port.
*/
if (starget->channel == MPTSAS_RAID_CHANNEL) {
for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
if (id == hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID)
channel = hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus;
for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
if (id == ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID)
channel = ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus;
goto out;
}

rphy = dev_to_rphy(starget->dev.parent);
mutex_lock(&hd->ioc->sas_topology_mutex);
list_for_each_entry(p, &hd->ioc->sas_topology, list) {
mutex_lock(&ioc->sas_topology_mutex);
list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address)
Expand All @@ -881,18 +882,18 @@ mptsas_target_alloc(struct scsi_target *starget)
/*
* Exposing hidden raid components
*/
if (mptscsih_is_phys_disk(hd->ioc, channel, id)) {
id = mptscsih_raid_id_to_num(hd->ioc,
if (mptscsih_is_phys_disk(ioc, channel, id)) {
id = mptscsih_raid_id_to_num(ioc,
channel, id);
vtarget->tflags |=
MPT_TARGET_FLAGS_RAID_COMPONENT;
p->phy_info[i].attached.phys_disk_num = id;
}
mutex_unlock(&hd->ioc->sas_topology_mutex);
mutex_unlock(&ioc->sas_topology_mutex);
goto out;
}
}
mutex_unlock(&hd->ioc->sas_topology_mutex);
mutex_unlock(&ioc->sas_topology_mutex);

kfree(vtarget);
return -ENXIO;
Expand All @@ -912,6 +913,7 @@ mptsas_target_destroy(struct scsi_target *starget)
struct sas_rphy *rphy;
struct mptsas_portinfo *p;
int i;
MPT_ADAPTER *ioc = hd->ioc;

if (!starget->hostdata)
return;
Expand All @@ -920,7 +922,7 @@ mptsas_target_destroy(struct scsi_target *starget)
goto out;

rphy = dev_to_rphy(starget->dev.parent);
list_for_each_entry(p, &hd->ioc->sas_topology, list) {
list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address)
Expand All @@ -946,11 +948,12 @@ mptsas_slave_alloc(struct scsi_device *sdev)
VirtDevice *vdevice;
struct scsi_target *starget;
int i;
MPT_ADAPTER *ioc = hd->ioc;

vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
if (!vdevice) {
printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n",
hd->ioc->name, sizeof(VirtDevice));
ioc->name, sizeof(VirtDevice));
return -ENOMEM;
}
starget = scsi_target(sdev);
Expand All @@ -960,8 +963,8 @@ mptsas_slave_alloc(struct scsi_device *sdev)
goto out;

rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
mutex_lock(&hd->ioc->sas_topology_mutex);
list_for_each_entry(p, &hd->ioc->sas_topology, list) {
mutex_lock(&ioc->sas_topology_mutex);
list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address)
Expand All @@ -970,15 +973,15 @@ mptsas_slave_alloc(struct scsi_device *sdev)
/*
* Exposing hidden raid components
*/
if (mptscsih_is_phys_disk(hd->ioc,
if (mptscsih_is_phys_disk(ioc,
p->phy_info[i].attached.channel,
p->phy_info[i].attached.id))
sdev->no_uld_attach = 1;
mutex_unlock(&hd->ioc->sas_topology_mutex);
mutex_unlock(&ioc->sas_topology_mutex);
goto out;
}
}
mutex_unlock(&hd->ioc->sas_topology_mutex);
mutex_unlock(&ioc->sas_topology_mutex);

kfree(vdevice);
return -ENXIO;
Expand Down
Loading

0 comments on commit e80b002

Please sign in to comment.