Skip to content

Commit

Permalink
ide: pass number of ports to ide_host_{alloc,add}() (v2)
Browse files Browse the repository at this point in the history
Pass number of ports to ide_host_{alloc,add}() and then update
all users accordingly.

v2:
- drop no longer needed NULL initializers in buddha.c, cmd640.c and gayle.c
  (noticed by Sergei)

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <[email protected]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
  • Loading branch information
bzolnier committed May 17, 2009
1 parent 29e52cf commit dca3983
Show file tree
Hide file tree
Showing 28 changed files with 64 additions and 64 deletions.
5 changes: 2 additions & 3 deletions drivers/ide/at91_ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ irqreturn_t at91_irq_handler(int irq, void *dev_id)
static int __init at91_ide_probe(struct platform_device *pdev)
{
int ret;
hw_regs_t hw;
hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };
struct ide_host *host;
struct resource *res;
unsigned long tf_base = 0, ctl_base = 0;
Expand Down Expand Up @@ -307,7 +306,7 @@ static int __init at91_ide_probe(struct platform_device *pdev)
hw.irq = board->irq_pin;
hw.dev = &pdev->dev;

host = ide_host_alloc(&at91_ide_port_info, hws);
host = ide_host_alloc(&at91_ide_port_info, hws, 1);
if (!host) {
perr("failed to allocate ide host\n");
return -ENOMEM;
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/au1xxx-ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static int au_ide_probe(struct platform_device *dev)
struct resource *res;
struct ide_host *host;
int ret = 0;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
char *mode = "MWDMA2";
Expand Down Expand Up @@ -550,7 +550,7 @@ static int au_ide_probe(struct platform_device *dev)
hw.irq = ahwif->irq;
hw.dev = &dev->dev;

ret = ide_host_add(&au1xxx_port_info, hws, &host);
ret = ide_host_add(&au1xxx_port_info, hws, 1, &host);
if (ret)
goto out;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/buddha.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int __init buddha_init(void)

while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
unsigned long board;
hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
hw_regs_t hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS];

if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
buddha_num_hwifs = BUDDHA_NUM_HWIFS;
Expand Down Expand Up @@ -224,7 +224,7 @@ static int __init buddha_init(void)
hws[i] = &hw[i];
}

ide_host_add(&buddha_port_info, hws, NULL);
ide_host_add(&buddha_port_info, hws, i, NULL);
}

return 0;
Expand Down
5 changes: 3 additions & 2 deletions drivers/ide/cmd640.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ static int __init cmd640x_init(void)
int second_port_cmd640 = 0, rc;
const char *bus_type, *port2;
u8 b, cfr;
hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
hw_regs_t hw[2], *hws[2];

if (cmd640_vlb && probe_for_cmd640_vlb()) {
bus_type = "VLB";
Expand Down Expand Up @@ -822,7 +822,8 @@ static int __init cmd640x_init(void)
cmd640_dump_regs();
#endif

return ide_host_add(&cmd640_port_info, hws, NULL);
return ide_host_add(&cmd640_port_info, hws, second_port_cmd640 ? 2 : 1,
NULL);
}

module_param_named(probe_vlb, cmd640_vlb, bool, 0);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/cs5520.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static const struct ide_port_info cyrix_chipset __devinitdata = {
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
const struct ide_port_info *d = &cyrix_chipset;
hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
hw_regs_t hw[2], *hws[] = { NULL, NULL };

ide_setup_pci_noise(dev, d);

Expand All @@ -136,7 +136,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
hw[0].irq = 14;

return ide_host_add(d, hws, NULL);
return ide_host_add(d, hws, 2, NULL);
}

static const struct pci_device_id cs5520_pci_tbl[] = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/delkin_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
struct ide_host *host;
unsigned long base;
int rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

rc = pci_enable_device(dev);
if (rc) {
Expand All @@ -99,7 +99,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
hw.irq = dev->irq;
hw.dev = &dev->dev;

rc = ide_host_add(&delkin_cb_port_info, hws, &host);
rc = ide_host_add(&delkin_cb_port_info, hws, 1, &host);
if (rc)
goto out_disable;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/falconide.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
static int __init falconide_init(void)
{
struct ide_host *host;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };
int rc;

if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
Expand All @@ -153,7 +153,7 @@ static int __init falconide_init(void)

falconide_setup_ports(&hw);

host = ide_host_alloc(&falconide_port_info, hws);
host = ide_host_alloc(&falconide_port_info, hws, 1);
if (host == NULL) {
rc = -ENOMEM;
goto err;
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/gayle.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int __init gayle_init(void)
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
int a4000, i, rc;
hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];

if (!MACH_IS_AMIGA)
return -ENODEV;
Expand Down Expand Up @@ -170,7 +170,7 @@ static int __init gayle_init(void)
hws[i] = &hw[i];
}

rc = ide_host_add(&gayle_port_info, hws, NULL);
rc = ide_host_add(&gayle_port_info, hws, i, NULL);
if (rc)
release_mem_region(res_start, res_n);

Expand Down
8 changes: 4 additions & 4 deletions drivers/ide/icside.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
{
void __iomem *base;
struct ide_host *host;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };
int ret;

base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
Expand All @@ -431,7 +431,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)

icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec);

host = ide_host_alloc(&icside_v5_port_info, hws);
host = ide_host_alloc(&icside_v5_port_info, hws, 1);
if (host == NULL)
return -ENODEV;

Expand Down Expand Up @@ -467,7 +467,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
struct ide_host *host;
unsigned int sel = 0;
int ret;
hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1], NULL, NULL };
hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1] };
struct ide_port_info d = icside_v6_port_info;

ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
Expand Down Expand Up @@ -507,7 +507,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec);
icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec);

host = ide_host_alloc(&d, hws);
host = ide_host_alloc(&d, hws, 2);
if (host == NULL)
return -ENODEV;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-4drives.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static const struct ide_port_info ide_4drives_port_info = {
static int __init ide_4drives_init(void)
{
unsigned long base = 0x1f0, ctl = 0x3f6;
hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw, &hw };

if (probe_4drives == 0)
return -ENODEV;
Expand All @@ -54,7 +54,7 @@ static int __init ide_4drives_init(void)
ide_std_init_ports(&hw, base, ctl);
hw.irq = 14;

return ide_host_add(&ide_4drives_port_info, hws, NULL);
return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
}

module_init(ide_4drives_init);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
struct ide_host *host;
ide_hwif_t *hwif;
int i, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

if (!request_region(io, 8, DRV_NAME)) {
printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
Expand All @@ -184,7 +184,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
hw.irq = irq;
hw.dev = &handle->dev;

rc = ide_host_add(&idecs_port_info, hws, &host);
rc = ide_host_add(&idecs_port_info, hws, 1, &host);
if (rc)
goto out_release;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)

static int __init ide_generic_init(void)
{
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };
unsigned long io_addr;
int i, rc = 0, primary = 0, secondary = 0;

Expand Down Expand Up @@ -133,7 +133,7 @@ static int __init ide_generic_init(void)
#else
hw.irq = legacy_irqs[i];
#endif
rc = ide_host_add(&ide_generic_port_info, hws, NULL);
rc = ide_host_add(&ide_generic_port_info, hws, 1, NULL);
if (rc) {
release_region(io_addr + 0x206, 1);
release_region(io_addr, 8);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static const struct ide_port_info h8300_port_info = {

static int __init h8300_ide_init(void)
{
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");

Expand All @@ -96,7 +96,7 @@ static int __init h8300_ide_init(void)

hw_setup(&hw);

return ide_host_add(&h8300_port_info, hws, NULL);
return ide_host_add(&h8300_port_info, hws, 1, NULL);

out_busy:
printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,

int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
{
hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
hw_regs_t hw[2], *hws[] = { NULL, NULL };

memset(&hw, 0, sizeof(hw));

Expand All @@ -52,6 +52,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
(d->host_flags & IDE_HFLAG_SINGLE))
return -ENOENT;

return ide_host_add(d, hws, NULL);
return ide_host_add(d, hws, 2, NULL);
}
EXPORT_SYMBOL_GPL(ide_legacy_device_add);
4 changes: 2 additions & 2 deletions drivers/ide/ide-pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
struct ide_host *host;
unsigned long base, ctl;
int rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");

Expand All @@ -64,7 +64,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
ide_std_init_ports(&hw, base, ctl);
hw.irq = pnp_irq(dev, 0);

rc = ide_host_add(&ide_pnp_port_info, hws, &host);
rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host);
if (rc)
goto out;

Expand Down
9 changes: 5 additions & 4 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
return -ENOMEM;
}

struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws,
unsigned int n_ports)
{
struct ide_host *host;
struct device *dev = hws[0] ? hws[0]->dev : NULL;
Expand All @@ -1272,7 +1273,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
if (host == NULL)
return NULL;

for (i = 0; i < MAX_HOST_PORTS; i++) {
for (i = 0; i < n_ports; i++) {
ide_hwif_t *hwif;
int idx;

Expand Down Expand Up @@ -1443,12 +1444,12 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
EXPORT_SYMBOL_GPL(ide_host_register);

int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
struct ide_host **hostp)
unsigned int n_ports, struct ide_host **hostp)
{
struct ide_host *host;
int rc;

host = ide_host_alloc(d, hws);
host = ide_host_alloc(d, hws, n_ports);
if (host == NULL)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
struct pata_platform_info *pdata;
struct ide_host *host;
int ret = 0, mmio = 0;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };
struct ide_port_info d = platform_ide_port_info;

pdata = pdev->dev.platform_data;
Expand Down Expand Up @@ -98,7 +98,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
if (mmio)
d.host_flags |= IDE_HFLAG_MMIO;

ret = ide_host_add(&d, hws, &host);
ret = ide_host_add(&d, hws, 1, &host);
if (ret)
goto out;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/macide.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static int __init macide_init(void)
ide_ack_intr_t *ack_intr;
unsigned long base;
int irq;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

if (!MACH_IS_MAC)
return -ENODEV;
Expand Down Expand Up @@ -126,7 +126,7 @@ static int __init macide_init(void)

macide_setup_ports(&hw, base, irq, ack_intr);

return ide_host_add(&macide_port_info, hws, NULL);
return ide_host_add(&macide_port_info, hws, 1, NULL);
}

module_init(macide_init);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/palm_bk3710.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
void __iomem *base;
unsigned long rate, mem_size;
int i, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
hw_regs_t hw, *hws[] = { &hw };

clk = clk_get(&pdev->dev, "IDECLK");
if (IS_ERR(clk))
Expand Down Expand Up @@ -369,7 +369,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
ATA_UDMA5;

/* Register the IDE interface with Linux */
rc = ide_host_add(&palm_bk3710_port_info, hws, NULL);
rc = ide_host_add(&palm_bk3710_port_info, hws, 1, NULL);
if (rc)
goto out;

Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/pmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
const int *bidp;
struct ide_host *host;
ide_hwif_t *hwif;
hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
hw_regs_t *hws[] = { hw };
struct ide_port_info d = pmac_port_info;
int rc;

Expand Down Expand Up @@ -1077,7 +1077,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
/* Make sure we have sane timings */
sanitize_timings(pmif);

host = ide_host_alloc(&d, hws);
host = ide_host_alloc(&d, hws, 1);
if (host == NULL)
return -ENOMEM;
hwif = host->ports[0];
Expand Down
Loading

0 comments on commit dca3983

Please sign in to comment.