diff options
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 804c3ef245f9..1c0c5570dec8 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -289,7 +289,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
289 | } | 289 | } |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * ide_hwif_configure - configure an IDE interface | 292 | * ide_hw_configure - configure a hw_regs_t instance |
293 | * @dev: PCI device holding interface | 293 | * @dev: PCI device holding interface |
294 | * @d: IDE port info | 294 | * @d: IDE port info |
295 | * @port: port number | 295 | * @port: port number |
@@ -300,23 +300,20 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
300 | * is done per interface port rather than per PCI device. There may be | 300 | * is done per interface port rather than per PCI device. There may be |
301 | * more than one port per device. | 301 | * more than one port per device. |
302 | * | 302 | * |
303 | * Returns the new hardware interface structure, or NULL on a failure | 303 | * Returns zero on success or an error code. |
304 | */ | 304 | */ |
305 | 305 | ||
306 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | 306 | static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, |
307 | const struct ide_port_info *d, | 307 | unsigned int port, int irq, hw_regs_t *hw) |
308 | unsigned int port, int irq, | ||
309 | hw_regs_t *hw) | ||
310 | { | 308 | { |
311 | unsigned long ctl = 0, base = 0; | 309 | unsigned long ctl = 0, base = 0; |
312 | ide_hwif_t *hwif; | ||
313 | 310 | ||
314 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 311 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
315 | if (ide_pci_check_iomem(dev, d, 2 * port) || | 312 | if (ide_pci_check_iomem(dev, d, 2 * port) || |
316 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { | 313 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { |
317 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " | 314 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " |
318 | "as MEM for port %d!\n", d->name, port); | 315 | "as MEM for port %d!\n", d->name, port); |
319 | return NULL; | 316 | return -EINVAL; |
320 | } | 317 | } |
321 | 318 | ||
322 | ctl = pci_resource_start(dev, 2*port+1); | 319 | ctl = pci_resource_start(dev, 2*port+1); |
@@ -330,7 +327,7 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
330 | if (!base || !ctl) { | 327 | if (!base || !ctl) { |
331 | printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", | 328 | printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", |
332 | d->name, port); | 329 | d->name, port); |
333 | return NULL; | 330 | return -EINVAL; |
334 | } | 331 | } |
335 | 332 | ||
336 | memset(hw, 0, sizeof(*hw)); | 333 | memset(hw, 0, sizeof(*hw)); |
@@ -339,13 +336,7 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
339 | hw->chipset = d->chipset ? d->chipset : ide_pci; | 336 | hw->chipset = d->chipset ? d->chipset : ide_pci; |
340 | ide_std_init_ports(hw, base, ctl | 2); | 337 | ide_std_init_ports(hw, base, ctl | 2); |
341 | 338 | ||
342 | hwif = ide_find_port_slot(d); | 339 | return 0; |
343 | if (hwif == NULL) | ||
344 | return NULL; | ||
345 | |||
346 | hwif->chipset = hw->chipset; | ||
347 | |||
348 | return hwif; | ||
349 | } | 340 | } |
350 | 341 | ||
351 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 342 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
@@ -443,7 +434,6 @@ out: | |||
443 | * @dev: PCI device | 434 | * @dev: PCI device |
444 | * @d: IDE port info | 435 | * @d: IDE port info |
445 | * @pciirq: IRQ line | 436 | * @pciirq: IRQ line |
446 | * @idx: ATA index table to update | ||
447 | * @hw: hw_regs_t instances corresponding to this PCI IDE device | 437 | * @hw: hw_regs_t instances corresponding to this PCI IDE device |
448 | * @hws: hw_regs_t pointers table to update | 438 | * @hws: hw_regs_t pointers table to update |
449 | * | 439 | * |
@@ -457,10 +447,9 @@ out: | |||
457 | */ | 447 | */ |
458 | 448 | ||
459 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | 449 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, |
460 | int pciirq, u8 *idx, hw_regs_t *hw, hw_regs_t **hws) | 450 | int pciirq, hw_regs_t *hw, hw_regs_t **hws) |
461 | { | 451 | { |
462 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 452 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
463 | ide_hwif_t *hwif; | ||
464 | u8 tmp; | 453 | u8 tmp; |
465 | 454 | ||
466 | /* | 455 | /* |
@@ -476,12 +465,10 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | |||
476 | continue; /* port not enabled */ | 465 | continue; /* port not enabled */ |
477 | } | 466 | } |
478 | 467 | ||
479 | hwif = ide_hwif_configure(dev, d, port, pciirq, hw + port); | 468 | if (ide_hw_configure(dev, d, port, pciirq, hw + port)) |
480 | if (hwif == NULL) | ||
481 | continue; | 469 | continue; |
482 | 470 | ||
483 | *(hws + port) = hw + port; | 471 | *(hws + port) = hw + port; |
484 | *(idx + port) = hwif->index; | ||
485 | } | 472 | } |
486 | } | 473 | } |
487 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | 474 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); |
@@ -554,7 +541,7 @@ out: | |||
554 | 541 | ||
555 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | 542 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) |
556 | { | 543 | { |
557 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 544 | struct ide_host *host; |
558 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 545 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
559 | int ret; | 546 | int ret; |
560 | 547 | ||
@@ -562,9 +549,11 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | |||
562 | 549 | ||
563 | if (ret >= 0) { | 550 | if (ret >= 0) { |
564 | /* FIXME: silent failure can happen */ | 551 | /* FIXME: silent failure can happen */ |
565 | ide_pci_setup_ports(dev, d, ret, &idx[0], &hw[0], &hws[0]); | 552 | ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]); |
566 | 553 | ||
567 | ide_device_add(idx, d, hws); | 554 | host = ide_host_alloc(d, hws); |
555 | if (host) | ||
556 | ide_host_register(host, d, hws); | ||
568 | } | 557 | } |
569 | 558 | ||
570 | return ret; | 559 | return ret; |
@@ -575,9 +564,9 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
575 | const struct ide_port_info *d) | 564 | const struct ide_port_info *d) |
576 | { | 565 | { |
577 | struct pci_dev *pdev[] = { dev1, dev2 }; | 566 | struct pci_dev *pdev[] = { dev1, dev2 }; |
567 | struct ide_host *host; | ||
578 | int ret, i; | 568 | int ret, i; |
579 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 569 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
580 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
581 | 570 | ||
582 | for (i = 0; i < 2; i++) { | 571 | for (i = 0; i < 2; i++) { |
583 | ret = do_ide_setup_pci_device(pdev[i], d, !i); | 572 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
@@ -590,11 +579,12 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
590 | goto out; | 579 | goto out; |
591 | 580 | ||
592 | /* FIXME: silent failure can happen */ | 581 | /* FIXME: silent failure can happen */ |
593 | ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2], &hw[i*2], | 582 | ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]); |
594 | &hws[i*2]); | ||
595 | } | 583 | } |
596 | 584 | ||
597 | ide_device_add(idx, d, hws); | 585 | host = ide_host_alloc(d, hws); |
586 | if (host) | ||
587 | ide_host_register(host, d, hws); | ||
598 | out: | 588 | out: |
599 | return ret; | 589 | return ret; |
600 | } | 590 | } |