Commit d91f5afe authored by Ondrej Zary's avatar Ondrej Zary Committed by Martin K. Petersen

scsi: g_NCR5380: Reduce overrides[] from array to struct

Remove compile-time card type definition GENERIC_NCR5380_OVERRIDE.  Then
remove all code iterating the overrides[] array and reduce it to struct
card.
Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Acked-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c47946c2
...@@ -42,19 +42,12 @@ static int ncr_53c400a; ...@@ -42,19 +42,12 @@ static int ncr_53c400a;
static int dtc_3181e; static int dtc_3181e;
static int hp_c2502; static int hp_c2502;
static struct override { static struct card {
NCR5380_map_type NCR5380_map_name; NCR5380_map_type NCR5380_map_name;
int irq; int irq;
int dma; int dma;
int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ int board; /* Use NCR53c400, Ricoh, etc. extensions ? */
} overrides } card;
#ifdef GENERIC_NCR5380_OVERRIDE
[] __initdata = GENERIC_NCR5380_OVERRIDE;
#else
[1] __initdata = { { 0,},};
#endif
#define NO_OVERRIDES ARRAY_SIZE(overrides)
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
/* /*
...@@ -85,16 +78,13 @@ static void magic_configure(int idx, u8 irq, u8 magic[]) ...@@ -85,16 +78,13 @@ static void magic_configure(int idx, u8 irq, u8 magic[])
* @tpnt: the scsi template * @tpnt: the scsi template
* *
* Scan for the present of NCR5380, NCR53C400, NCR53C400A, DTC3181E * Scan for the present of NCR5380, NCR53C400, NCR53C400A, DTC3181E
* and DTC436(ISAPnP) controllers. If overrides have been set we use * and DTC436(ISAPnP) controllers.
* them.
* *
* Locks: none * Locks: none
*/ */
static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
{ {
static int current_override;
int count;
unsigned int *ports; unsigned int *ports;
u8 *magic = NULL; u8 *magic = NULL;
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
...@@ -124,28 +114,25 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -124,28 +114,25 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
#endif #endif
if (ncr_irq) if (ncr_irq)
overrides[0].irq = ncr_irq; card.irq = ncr_irq;
if (ncr_dma) if (ncr_dma)
overrides[0].dma = ncr_dma; card.dma = ncr_dma;
if (ncr_addr) if (ncr_addr)
overrides[0].NCR5380_map_name = (NCR5380_map_type) ncr_addr; card.NCR5380_map_name = (NCR5380_map_type) ncr_addr;
if (ncr_5380) if (ncr_5380)
overrides[0].board = BOARD_NCR5380; card.board = BOARD_NCR5380;
else if (ncr_53c400) else if (ncr_53c400)
overrides[0].board = BOARD_NCR53C400; card.board = BOARD_NCR53C400;
else if (ncr_53c400a) else if (ncr_53c400a)
overrides[0].board = BOARD_NCR53C400A; card.board = BOARD_NCR53C400A;
else if (dtc_3181e) else if (dtc_3181e)
overrides[0].board = BOARD_DTC3181E; card.board = BOARD_DTC3181E;
else if (hp_c2502) else if (hp_c2502)
overrides[0].board = BOARD_HP_C2502; card.board = BOARD_HP_C2502;
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
if (!current_override && isapnp_present()) { if (isapnp_present()) {
struct pnp_dev *dev = NULL; struct pnp_dev *dev = NULL;
count = 0;
while ((dev = pnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) { while ((dev = pnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) {
if (count >= NO_OVERRIDES)
break;
if (pnp_device_attach(dev) < 0) if (pnp_device_attach(dev) < 0)
continue; continue;
if (pnp_activate_dev(dev) < 0) { if (pnp_activate_dev(dev) < 0) {
...@@ -159,27 +146,26 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -159,27 +146,26 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
continue; continue;
} }
if (pnp_irq_valid(dev, 0)) if (pnp_irq_valid(dev, 0))
overrides[count].irq = pnp_irq(dev, 0); card.irq = pnp_irq(dev, 0);
else else
overrides[count].irq = NO_IRQ; card.irq = NO_IRQ;
if (pnp_dma_valid(dev, 0)) if (pnp_dma_valid(dev, 0))
overrides[count].dma = pnp_dma(dev, 0); card.dma = pnp_dma(dev, 0);
else else
overrides[count].dma = DMA_NONE; card.dma = DMA_NONE;
overrides[count].NCR5380_map_name = (NCR5380_map_type) pnp_port_start(dev, 0); card.NCR5380_map_name = (NCR5380_map_type) pnp_port_start(dev, 0);
overrides[count].board = BOARD_DTC3181E; card.board = BOARD_DTC3181E;
count++; break;
} }
} }
#endif #endif
for (count = 0; current_override < NO_OVERRIDES; ++current_override) { if (!(card.NCR5380_map_name))
if (!(overrides[current_override].NCR5380_map_name)) return 0;
continue;
ports = NULL; ports = NULL;
flags = 0; flags = 0;
switch (overrides[current_override].board) { switch (card.board) {
case BOARD_NCR5380: case BOARD_NCR5380:
flags = FLAG_NO_PSEUDO_DMA | FLAG_DMA_FIXUP; flags = FLAG_NO_PSEUDO_DMA | FLAG_DMA_FIXUP;
break; break;
...@@ -206,11 +192,11 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -206,11 +192,11 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
region_size = 16; region_size = 16;
if (overrides[current_override].NCR5380_map_name != PORT_AUTO) if (card.NCR5380_map_name != PORT_AUTO)
for (i = 0; ports[i]; i++) { for (i = 0; ports[i]; i++) {
if (!request_region(ports[i], region_size, "ncr53c80")) if (!request_region(ports[i], region_size, "ncr53c80"))
continue; continue;
if (overrides[current_override].NCR5380_map_name == ports[i]) if (card.NCR5380_map_name == ports[i])
break; break;
release_region(ports[i], region_size); release_region(ports[i], region_size);
} else } else
...@@ -226,29 +212,29 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -226,29 +212,29 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
magic_configure(i, 0, magic); /* no IRQ yet */ magic_configure(i, 0, magic); /* no IRQ yet */
outb(0xc0, ports[i] + 9); outb(0xc0, ports[i] + 9);
if (inb(ports[i] + 9) != 0x80) if (inb(ports[i] + 9) != 0x80)
continue; return 0;
overrides[current_override].NCR5380_map_name = ports[i]; card.NCR5380_map_name = ports[i];
port_idx = i; port_idx = i;
} else } else
continue; return 0;
} }
else else
{ {
/* Not a 53C400A style setup - just grab */ /* Not a 53C400A style setup - just grab */
region_size = 8; region_size = 8;
if (!request_region(overrides[current_override].NCR5380_map_name, if (!request_region(card.NCR5380_map_name,
region_size, "ncr5380")) region_size, "ncr5380"))
continue; return 0;
} }
#else #else
base = overrides[current_override].NCR5380_map_name; base = card.NCR5380_map_name;
iomem_size = NCR53C400_region_size; iomem_size = NCR53C400_region_size;
if (!request_mem_region(base, iomem_size, "ncr5380")) if (!request_mem_region(base, iomem_size, "ncr5380"))
continue; return 0;
iomem = ioremap(base, iomem_size); iomem = ioremap(base, iomem_size);
if (!iomem) { if (!iomem) {
release_mem_region(base, iomem_size); release_mem_region(base, iomem_size);
continue; return 0;
} }
#endif #endif
instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
...@@ -257,7 +243,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -257,7 +243,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
hostdata = shost_priv(instance); hostdata = shost_priv(instance);
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
instance->io_port = overrides[current_override].NCR5380_map_name; instance->io_port = card.NCR5380_map_name;
instance->n_io_port = region_size; instance->n_io_port = region_size;
hostdata->io_width = 1; /* 8-bit PDMA by default */ hostdata->io_width = 1; /* 8-bit PDMA by default */
...@@ -265,7 +251,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -265,7 +251,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
* On NCR53C400 boards, NCR5380 registers are mapped 8 past * On NCR53C400 boards, NCR5380 registers are mapped 8 past
* the base address. * the base address.
*/ */
switch (overrides[current_override].board) { switch (card.board) {
case BOARD_NCR53C400: case BOARD_NCR53C400:
instance->io_port += 8; instance->io_port += 8;
hostdata->c400_ctl_status = 0; hostdata->c400_ctl_status = 0;
...@@ -283,10 +269,10 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -283,10 +269,10 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
break; break;
} }
#else #else
instance->base = overrides[current_override].NCR5380_map_name; instance->base = card.NCR5380_map_name;
hostdata->iomem = iomem; hostdata->iomem = iomem;
hostdata->iomem_size = iomem_size; hostdata->iomem_size = iomem_size;
switch (overrides[current_override].board) { switch (card.board) {
case BOARD_NCR53C400: case BOARD_NCR53C400:
hostdata->c400_ctl_status = 0x100; hostdata->c400_ctl_status = 0x100;
hostdata->c400_blk_cnt = 0x101; hostdata->c400_blk_cnt = 0x101;
...@@ -303,7 +289,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -303,7 +289,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
if (NCR5380_init(instance, flags | FLAG_LATE_DMA_SETUP)) if (NCR5380_init(instance, flags | FLAG_LATE_DMA_SETUP))
goto out_unregister; goto out_unregister;
switch (overrides[current_override].board) { switch (card.board) {
case BOARD_NCR53C400: case BOARD_NCR53C400:
case BOARD_DTC3181E: case BOARD_DTC3181E:
case BOARD_NCR53C400A: case BOARD_NCR53C400A:
...@@ -313,8 +299,8 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -313,8 +299,8 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
NCR5380_maybe_reset_bus(instance); NCR5380_maybe_reset_bus(instance);
if (overrides[current_override].irq != IRQ_AUTO) if (card.irq != IRQ_AUTO)
instance->irq = overrides[current_override].irq; instance->irq = card.irq;
else else
instance->irq = NCR5380_probe_irq(instance, 0xffff); instance->irq = NCR5380_probe_irq(instance, 0xffff);
...@@ -325,7 +311,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -325,7 +311,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
if (instance->irq != NO_IRQ) { if (instance->irq != NO_IRQ) {
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
/* set IRQ for HP C2502 */ /* set IRQ for HP C2502 */
if (overrides[current_override].board == BOARD_HP_C2502) if (card.board == BOARD_HP_C2502)
magic_configure(port_idx, instance->irq, magic); magic_configure(port_idx, instance->irq, magic);
#endif #endif
if (request_irq(instance->irq, generic_NCR5380_intr, if (request_irq(instance->irq, generic_NCR5380_intr,
...@@ -340,21 +326,18 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -340,21 +326,18 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
} }
++current_override; return 1;
++count;
}
return count;
out_unregister: out_unregister:
scsi_unregister(instance); scsi_unregister(instance);
out_release: out_release:
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
release_region(overrides[current_override].NCR5380_map_name, region_size); release_region(card.NCR5380_map_name, region_size);
#else #else
iounmap(iomem); iounmap(iomem);
release_mem_region(base, iomem_size); release_mem_region(base, iomem_size);
#endif #endif
return count; return 0;
} }
/** /**
......
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