diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-10 08:37:21 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-10 08:37:21 -0400 |
commit | ad7c52d0988a8965989dc06d630c52a5bde849d5 (patch) | |
tree | e0500a523bf85b9957001d0ff5d9fb7701315245 /drivers | |
parent | 5df3bc2d35bd5cd08053f71679b27577b42676d6 (diff) |
ide: re-implement ide_pci_init_one() on top of ide_pci_init_two()
There should be no functional changes caused by this patch.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/setup-pci.c | 70 |
1 files changed, 16 insertions, 54 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 5314edffc303..ab3db61d2ba0 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
3 | * Copyright (C) 1995-1998 Mark Lord | 3 | * Copyright (C) 1995-1998 Mark Lord |
4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007-2009 Bartlomiej Zolnierkiewicz |
5 | * | 5 | * |
6 | * May be copied or modified under the terms of the GNU General Public License | 6 | * May be copied or modified under the terms of the GNU General Public License |
7 | */ | 7 | */ |
@@ -534,61 +534,15 @@ out: | |||
534 | return ret; | 534 | return ret; |
535 | } | 535 | } |
536 | 536 | ||
537 | int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | ||
538 | void *priv) | ||
539 | { | ||
540 | struct ide_host *host; | ||
541 | struct ide_hw hw[2], *hws[] = { NULL, NULL }; | ||
542 | int ret; | ||
543 | |||
544 | ret = ide_setup_pci_controller(dev, d, 1); | ||
545 | if (ret < 0) | ||
546 | goto out; | ||
547 | |||
548 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); | ||
549 | |||
550 | host = ide_host_alloc(d, hws, 2); | ||
551 | if (host == NULL) { | ||
552 | ret = -ENOMEM; | ||
553 | goto out; | ||
554 | } | ||
555 | |||
556 | host->dev[0] = &dev->dev; | ||
557 | |||
558 | host->host_priv = priv; | ||
559 | |||
560 | host->irq_flags = IRQF_SHARED; | ||
561 | |||
562 | pci_set_drvdata(dev, host); | ||
563 | |||
564 | ret = do_ide_setup_pci_device(dev, d, 1); | ||
565 | if (ret < 0) | ||
566 | goto out; | ||
567 | |||
568 | /* fixup IRQ */ | ||
569 | if (ide_pci_is_in_compatibility_mode(dev)) { | ||
570 | hw[0].irq = pci_get_legacy_ide_irq(dev, 0); | ||
571 | hw[1].irq = pci_get_legacy_ide_irq(dev, 1); | ||
572 | } else | ||
573 | hw[1].irq = hw[0].irq = ret; | ||
574 | |||
575 | ret = ide_host_register(host, d, hws); | ||
576 | if (ret) | ||
577 | ide_host_free(host); | ||
578 | out: | ||
579 | return ret; | ||
580 | } | ||
581 | EXPORT_SYMBOL_GPL(ide_pci_init_one); | ||
582 | |||
583 | int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | 537 | int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, |
584 | const struct ide_port_info *d, void *priv) | 538 | const struct ide_port_info *d, void *priv) |
585 | { | 539 | { |
586 | struct pci_dev *pdev[] = { dev1, dev2 }; | 540 | struct pci_dev *pdev[] = { dev1, dev2 }; |
587 | struct ide_host *host; | 541 | struct ide_host *host; |
588 | int ret, i; | 542 | int ret, i, n_ports = dev2 ? 4 : 2; |
589 | struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 543 | struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
590 | 544 | ||
591 | for (i = 0; i < 2; i++) { | 545 | for (i = 0; i < n_ports / 2; i++) { |
592 | ret = ide_setup_pci_controller(pdev[i], d, !i); | 546 | ret = ide_setup_pci_controller(pdev[i], d, !i); |
593 | if (ret < 0) | 547 | if (ret < 0) |
594 | goto out; | 548 | goto out; |
@@ -596,23 +550,24 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | |||
596 | ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); | 550 | ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); |
597 | } | 551 | } |
598 | 552 | ||
599 | host = ide_host_alloc(d, hws, 4); | 553 | host = ide_host_alloc(d, hws, n_ports); |
600 | if (host == NULL) { | 554 | if (host == NULL) { |
601 | ret = -ENOMEM; | 555 | ret = -ENOMEM; |
602 | goto out; | 556 | goto out; |
603 | } | 557 | } |
604 | 558 | ||
605 | host->dev[0] = &dev1->dev; | 559 | host->dev[0] = &dev1->dev; |
606 | host->dev[1] = &dev2->dev; | 560 | if (dev2) |
561 | host->dev[1] = &dev2->dev; | ||
607 | 562 | ||
608 | host->host_priv = priv; | 563 | host->host_priv = priv; |
609 | |||
610 | host->irq_flags = IRQF_SHARED; | 564 | host->irq_flags = IRQF_SHARED; |
611 | 565 | ||
612 | pci_set_drvdata(pdev[0], host); | 566 | pci_set_drvdata(pdev[0], host); |
613 | pci_set_drvdata(pdev[1], host); | 567 | if (dev2) |
568 | pci_set_drvdata(pdev[1], host); | ||
614 | 569 | ||
615 | for (i = 0; i < 2; i++) { | 570 | for (i = 0; i < n_ports / 2; i++) { |
616 | ret = do_ide_setup_pci_device(pdev[i], d, !i); | 571 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
617 | 572 | ||
618 | /* | 573 | /* |
@@ -638,6 +593,13 @@ out: | |||
638 | } | 593 | } |
639 | EXPORT_SYMBOL_GPL(ide_pci_init_two); | 594 | EXPORT_SYMBOL_GPL(ide_pci_init_two); |
640 | 595 | ||
596 | int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | ||
597 | void *priv) | ||
598 | { | ||
599 | return ide_pci_init_two(dev, NULL, d, priv); | ||
600 | } | ||
601 | EXPORT_SYMBOL_GPL(ide_pci_init_one); | ||
602 | |||
641 | void ide_pci_remove(struct pci_dev *dev) | 603 | void ide_pci_remove(struct pci_dev *dev) |
642 | { | 604 | { |
643 | struct ide_host *host = pci_get_drvdata(dev); | 605 | struct ide_host *host = pci_get_drvdata(dev); |