[SCSI] gdth: PCI probe cleanups, prep for PCI hotplug API conversion

- Reduce uses of gdth_pci_str::pdev, preferring a local variable
  (or function arg) 'pdev' instead.

- Reduce uses of gdth_pcistr array, preferring local variable
  (or function arg) 'pcistr' instead.

- Eliminate lone use of gdth_pci_str::irq, using equivalent
  pdev->irq instead

- Eliminate assign-only gdth_pci_str::io_mm

Note:  If the indentation seems weird, that's because a line was
converted from spaces to tabs, when it was modified.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
Jeff Garzik 2008-02-15 21:35:26 -05:00 committed by James Bottomley
parent 4cac04dd63
commit 4c9c8d782c
2 changed files with 28 additions and 33 deletions

View File

@ -649,7 +649,6 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
/* GDT PCI controller found, resources are already in pdev */ /* GDT PCI controller found, resources are already in pdev */
pcistr[*cnt].pdev = pdev; pcistr[*cnt].pdev = pdev;
pcistr[*cnt].irq = pdev->irq;
base0 = pci_resource_flags(pdev, 0); base0 = pci_resource_flags(pdev, 0);
base1 = pci_resource_flags(pdev, 1); base1 = pci_resource_flags(pdev, 1);
base2 = pci_resource_flags(pdev, 2); base2 = pci_resource_flags(pdev, 2);
@ -664,7 +663,6 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
!(base1 & IORESOURCE_IO)) !(base1 & IORESOURCE_IO))
continue; continue;
pcistr[*cnt].dpmem = pci_resource_start(pdev, 2); pcistr[*cnt].dpmem = pci_resource_start(pdev, 2);
pcistr[*cnt].io_mm = pci_resource_start(pdev, 0);
pcistr[*cnt].io = pci_resource_start(pdev, 1); pcistr[*cnt].io = pci_resource_start(pdev, 1);
} }
TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
@ -909,7 +907,8 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
#endif /* CONFIG_ISA */ #endif /* CONFIG_ISA */
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) static int __init gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr,
gdth_ha_str *ha)
{ {
register gdt6_dpram_str __iomem *dp6_ptr; register gdt6_dpram_str __iomem *dp6_ptr;
register gdt6c_dpram_str __iomem *dp6c_ptr; register gdt6c_dpram_str __iomem *dp6c_ptr;
@ -921,14 +920,14 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
TRACE(("gdth_init_pci()\n")); TRACE(("gdth_init_pci()\n"));
if (pcistr->pdev->vendor == PCI_VENDOR_ID_INTEL) if (pdev->vendor == PCI_VENDOR_ID_INTEL)
ha->oem_id = OEM_ID_INTEL; ha->oem_id = OEM_ID_INTEL;
else else
ha->oem_id = OEM_ID_ICP; ha->oem_id = OEM_ID_ICP;
ha->brd_phys = (pcistr->pdev->bus->number << 8) | (pcistr->pdev->devfn & 0xf8); ha->brd_phys = (pdev->bus->number << 8) | (pdev->devfn & 0xf8);
ha->stype = (ulong32)pcistr->pdev->device; ha->stype = (ulong32)pdev->device;
ha->irq = pcistr->irq; ha->irq = pdev->irq;
ha->pdev = pcistr->pdev; ha->pdev = pdev;
if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */
TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
@ -956,8 +955,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
continue; continue;
} }
iounmap(ha->brd); iounmap(ha->brd);
pci_write_config_dword(pcistr->pdev, pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i);
PCI_BASE_ADDRESS_0, i);
ha->brd = ioremap(i, sizeof(gdt6_dpram_str)); ha->brd = ioremap(i, sizeof(gdt6_dpram_str));
if (ha->brd == NULL) { if (ha->brd == NULL) {
printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
@ -1066,8 +1064,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
continue; continue;
} }
iounmap(ha->brd); iounmap(ha->brd);
pci_write_config_dword(pcistr->pdev, pci_write_config_dword(pdev, PCI_BASE_ADDRESS_2, i);
PCI_BASE_ADDRESS_2, i);
ha->brd = ioremap(i, sizeof(gdt6c_dpram_str)); ha->brd = ioremap(i, sizeof(gdt6c_dpram_str));
if (ha->brd == NULL) { if (ha->brd == NULL) {
printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
@ -1159,16 +1156,16 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
} }
/* manipulate config. space to enable DPMEM, start RP controller */ /* manipulate config. space to enable DPMEM, start RP controller */
pci_read_config_word(pcistr->pdev, PCI_COMMAND, &command); pci_read_config_word(pdev, PCI_COMMAND, &command);
command |= 6; command |= 6;
pci_write_config_word(pcistr->pdev, PCI_COMMAND, command); pci_write_config_word(pdev, PCI_COMMAND, command);
if (pci_resource_start(pcistr->pdev, 8) == 1UL) if (pci_resource_start(pdev, 8) == 1UL)
pci_resource_start(pcistr->pdev, 8) = 0UL; pci_resource_start(pdev, 8) = 0UL;
i = 0xFEFF0001UL; i = 0xFEFF0001UL;
pci_write_config_dword(pcistr->pdev, PCI_ROM_ADDRESS, i); pci_write_config_dword(pdev, PCI_ROM_ADDRESS, i);
gdth_delay(1); gdth_delay(1);
pci_write_config_dword(pcistr->pdev, PCI_ROM_ADDRESS, pci_write_config_dword(pdev, PCI_ROM_ADDRESS,
pci_resource_start(pcistr->pdev, 8)); pci_resource_start(pdev, 8));
dp6m_ptr = ha->brd; dp6m_ptr = ha->brd;
@ -1195,8 +1192,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
continue; continue;
} }
iounmap(ha->brd); iounmap(ha->brd);
pci_write_config_dword(pcistr->pdev, pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i);
PCI_BASE_ADDRESS_0, i);
ha->brd = ioremap(i, sizeof(gdt6m_dpram_str)); ha->brd = ioremap(i, sizeof(gdt6m_dpram_str));
if (ha->brd == NULL) { if (ha->brd == NULL) {
printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
@ -4955,12 +4951,13 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot)
#endif /* CONFIG_EISA */ #endif /* CONFIG_EISA */
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) static int __init gdth_pci_probe_one(gdth_pci_str *pcistr)
{ {
struct Scsi_Host *shp; struct Scsi_Host *shp;
gdth_ha_str *ha; gdth_ha_str *ha;
dma_addr_t scratch_dma_handle = 0; dma_addr_t scratch_dma_handle = 0;
int error, i; int error, i;
struct pci_dev *pdev = pcistr->pdev;
shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str)); shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str));
if (!shp) if (!shp)
@ -4968,13 +4965,13 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr)
ha = shost_priv(shp); ha = shost_priv(shp);
error = -ENODEV; error = -ENODEV;
if (!gdth_init_pci(&pcistr[ctr],ha)) if (!gdth_init_pci(pdev, pcistr, ha))
goto out_host_put; goto out_host_put;
/* controller found and initialized */ /* controller found and initialized */
printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
pcistr[ctr].pdev->bus->number, pdev->bus->number,
PCI_SLOT(pcistr[ctr].pdev->devfn), PCI_SLOT(pdev->devfn),
ha->irq); ha->irq);
error = request_irq(ha->irq, gdth_interrupt, error = request_irq(ha->irq, gdth_interrupt,
@ -5019,7 +5016,7 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr)
ha->scratch_busy = FALSE; ha->scratch_busy = FALSE;
ha->req_first = NULL; ha->req_first = NULL;
ha->tid_cnt = pcistr[ctr].pdev->device >= 0x200 ? MAXID : MAX_HDRIVES; ha->tid_cnt = pdev->device >= 0x200 ? MAXID : MAX_HDRIVES;
if (max_ids > 0 && max_ids < ha->tid_cnt) if (max_ids > 0 && max_ids < ha->tid_cnt)
ha->tid_cnt = max_ids; ha->tid_cnt = max_ids;
for (i = 0; i < GDTH_MAXCMDS; ++i) for (i = 0; i < GDTH_MAXCMDS; ++i)
@ -5039,16 +5036,16 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr)
/* 64-bit DMA only supported from FW >= x.43 */ /* 64-bit DMA only supported from FW >= x.43 */
if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) || if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) ||
!ha->dma64_support) { !ha->dma64_support) {
if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
printk(KERN_WARNING "GDT-PCI %d: " printk(KERN_WARNING "GDT-PCI %d: "
"Unable to set 32-bit DMA\n", ha->hanum); "Unable to set 32-bit DMA\n", ha->hanum);
goto out_free_coal_stat; goto out_free_coal_stat;
} }
} else { } else {
shp->max_cmd_len = 16; shp->max_cmd_len = 16;
if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) { if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum); printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum);
} else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
printk(KERN_WARNING "GDT-PCI %d: " printk(KERN_WARNING "GDT-PCI %d: "
"Unable to set 64/32-bit DMA\n", ha->hanum); "Unable to set 64/32-bit DMA\n", ha->hanum);
goto out_free_coal_stat; goto out_free_coal_stat;
@ -5062,7 +5059,7 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr)
spin_lock_init(&ha->smp_lock); spin_lock_init(&ha->smp_lock);
gdth_enable_int(ha); gdth_enable_int(ha);
error = scsi_add_host(shp, &pcistr[ctr].pdev->dev); error = scsi_add_host(shp, &pdev->dev);
if (error) if (error)
goto out_free_coal_stat; goto out_free_coal_stat;
list_add_tail(&ha->list, &gdth_instances); list_add_tail(&ha->list, &gdth_instances);
@ -5193,7 +5190,7 @@ static int __init gdth_init(void)
printk("GDT-HA: Found %d PCI Storage RAID Controllers\n", cnt); printk("GDT-HA: Found %d PCI Storage RAID Controllers\n", cnt);
gdth_sort_pci(pcistr,cnt); gdth_sort_pci(pcistr,cnt);
for (ctr = 0; ctr < cnt; ++ctr) for (ctr = 0; ctr < cnt; ++ctr)
gdth_pci_probe_one(pcistr, ctr); gdth_pci_probe_one(&pcistr[ctr]);
} }
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */

View File

@ -839,8 +839,6 @@ typedef struct {
struct pci_dev *pdev; struct pci_dev *pdev;
ulong dpmem; /* DPRAM address */ ulong dpmem; /* DPRAM address */
ulong io; /* IO address */ ulong io; /* IO address */
ulong io_mm; /* IO address mem. mapped */
unchar irq; /* IRQ */
} gdth_pci_str; } gdth_pci_str;