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,202 +146,198 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -159,202 +146,198 @@ 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;
case BOARD_NCR53C400A: case BOARD_NCR53C400A:
ports = ncr_53c400a_ports; ports = ncr_53c400a_ports;
magic = ncr_53c400a_magic; magic = ncr_53c400a_magic;
break; break;
case BOARD_HP_C2502: case BOARD_HP_C2502:
ports = ncr_53c400a_ports; ports = ncr_53c400a_ports;
magic = hp_c2502_magic; magic = hp_c2502_magic;
break; break;
case BOARD_DTC3181E: case BOARD_DTC3181E:
ports = dtc_3181e_ports; ports = dtc_3181e_ports;
magic = ncr_53c400a_magic; magic = ncr_53c400a_magic;
break; break;
} }
#ifndef SCSI_G_NCR5380_MEM #ifndef SCSI_G_NCR5380_MEM
if (ports && magic) { if (ports && magic) {
/* wakeup sequence for the NCR53C400A and DTC3181E */ /* wakeup sequence for the NCR53C400A and DTC3181E */
/* Disable the adapter and look for a free io port */ /* Disable the adapter and look for a free io port */
magic_configure(-1, 0, magic); magic_configure(-1, 0, magic);
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;
if (overrides[current_override].NCR5380_map_name == ports[i])
break;
release_region(ports[i], region_size);
} else
for (i = 0; ports[i]; i++) {
if (!request_region(ports[i], region_size, "ncr53c80"))
continue;
if (inb(ports[i]) == 0xff)
break;
release_region(ports[i], region_size);
}
if (ports[i]) {
/* At this point we have our region reserved */
magic_configure(i, 0, magic); /* no IRQ yet */
outb(0xc0, ports[i] + 9);
if (inb(ports[i] + 9) != 0x80)
continue; continue;
overrides[current_override].NCR5380_map_name = ports[i]; if (card.NCR5380_map_name == ports[i])
port_idx = i; break;
} else release_region(ports[i], region_size);
continue; } else
} for (i = 0; ports[i]; i++) {
else if (!request_region(ports[i], region_size, "ncr53c80"))
{ continue;
/* Not a 53C400A style setup - just grab */ if (inb(ports[i]) == 0xff)
region_size = 8; break;
if (!request_region(overrides[current_override].NCR5380_map_name, release_region(ports[i], region_size);
region_size, "ncr5380")) }
continue; if (ports[i]) {
} /* At this point we have our region reserved */
magic_configure(i, 0, magic); /* no IRQ yet */
outb(0xc0, ports[i] + 9);
if (inb(ports[i] + 9) != 0x80)
return 0;
card.NCR5380_map_name = ports[i];
port_idx = i;
} else
return 0;
}
else
{
/* Not a 53C400A style setup - just grab */
region_size = 8;
if (!request_region(card.NCR5380_map_name,
region_size, "ncr5380"))
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));
if (instance == NULL) if (instance == NULL)
goto out_release; goto out_release;
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 */
/* /*
* 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;
hostdata->c400_blk_cnt = 1; hostdata->c400_blk_cnt = 1;
hostdata->c400_host_buf = 4; hostdata->c400_host_buf = 4;
break; break;
case BOARD_DTC3181E: case BOARD_DTC3181E:
hostdata->io_width = 2; /* 16-bit PDMA */ hostdata->io_width = 2; /* 16-bit PDMA */
/* fall through */ /* fall through */
case BOARD_NCR53C400A: case BOARD_NCR53C400A:
case BOARD_HP_C2502: case BOARD_HP_C2502:
hostdata->c400_ctl_status = 9; hostdata->c400_ctl_status = 9;
hostdata->c400_blk_cnt = 10; hostdata->c400_blk_cnt = 10;
hostdata->c400_host_buf = 8; hostdata->c400_host_buf = 8;
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;
hostdata->c400_host_buf = 0x104; hostdata->c400_host_buf = 0x104;
break; break;
case BOARD_DTC3181E: case BOARD_DTC3181E:
case BOARD_NCR53C400A: case BOARD_NCR53C400A:
case BOARD_HP_C2502: case BOARD_HP_C2502:
pr_err(DRV_MODULE_NAME ": unknown register offsets\n"); pr_err(DRV_MODULE_NAME ": unknown register offsets\n");
goto out_unregister; goto out_unregister;
} }
#endif #endif
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:
case BOARD_HP_C2502: case BOARD_HP_C2502:
NCR5380_write(hostdata->c400_ctl_status, CSR_BASE); NCR5380_write(hostdata->c400_ctl_status, CSR_BASE);
} }
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);
/* Compatibility with documented NCR5380 kernel parameters */ /* Compatibility with documented NCR5380 kernel parameters */
if (instance->irq == 255) if (instance->irq == 255)
instance->irq = NO_IRQ; instance->irq = NO_IRQ;
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,
0, "NCR5380", instance)) { 0, "NCR5380", instance)) {
printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
instance->irq = NO_IRQ; instance->irq = NO_IRQ;
}
}
if (instance->irq == NO_IRQ) {
printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
} }
}
++current_override; if (instance->irq == NO_IRQ) {
++count; printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
} }
return count;
return 1;
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