aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/setup-pci.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:14 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:14 -0400
commit6cdf6eb357c2681596b7b1672b92396ba82333d4 (patch)
treea6194373c64616ecb3d1af2c9247a32f50543f97 /drivers/ide/setup-pci.c
parent8c2eece50a368c7986bae0b3e52739558dd71b51 (diff)
ide: add ->dev and ->host_priv fields to struct ide_host
* Add 'struct device *dev[2]' and 'void *host_priv' fields to struct ide_host. * Set ->dev[] in ide_host_alloc_all()/ide_setup_pci_device[s](). * Pass 'void *priv' argument to ide_setup_pci_device[s]() and use it to set ->host_priv. * Set PCI dev's ->driver_data to point to the struct ide_host instance if PCI host driver wants to use ->host_priv. * Rename ide_setup_pci_device[s]() to ide_pci_init_{one,two}(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r--drivers/ide/setup-pci.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index b85de71fdc88..ca17bf8896df 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -525,8 +525,10 @@ out:
525 return ret; 525 return ret;
526} 526}
527 527
528int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) 528int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
529 void *priv)
529{ 530{
531 struct ide_host *host;
530 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 532 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
531 int ret; 533 int ret;
532 534
@@ -536,6 +538,19 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
536 538
537 ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]); 539 ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]);
538 540
541 host = ide_host_alloc(d, hws);
542 if (host == NULL) {
543 ret = -ENOMEM;
544 goto out;
545 }
546
547 host->dev[0] = &dev->dev;
548
549 host->host_priv = priv;
550
551 if (priv)
552 pci_set_drvdata(dev, host);
553
539 ret = do_ide_setup_pci_device(dev, d, 1); 554 ret = do_ide_setup_pci_device(dev, d, 1);
540 if (ret < 0) 555 if (ret < 0)
541 goto out; 556 goto out;
@@ -543,16 +558,19 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
543 /* fixup IRQ */ 558 /* fixup IRQ */
544 hw[1].irq = hw[0].irq = ret; 559 hw[1].irq = hw[0].irq = ret;
545 560
546 ret = ide_host_add(d, hws, NULL); 561 ret = ide_host_register(host, d, hws);
562 if (ret)
563 ide_host_free(host);
547out: 564out:
548 return ret; 565 return ret;
549} 566}
550EXPORT_SYMBOL_GPL(ide_setup_pci_device); 567EXPORT_SYMBOL_GPL(ide_pci_init_one);
551 568
552int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, 569int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
553 const struct ide_port_info *d) 570 const struct ide_port_info *d, void *priv)
554{ 571{
555 struct pci_dev *pdev[] = { dev1, dev2 }; 572 struct pci_dev *pdev[] = { dev1, dev2 };
573 struct ide_host *host;
556 int ret, i; 574 int ret, i;
557 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 575 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
558 576
@@ -562,7 +580,25 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
562 goto out; 580 goto out;
563 581
564 ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]); 582 ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]);
583 }
565 584
585 host = ide_host_alloc(d, hws);
586 if (host == NULL) {
587 ret = -ENOMEM;
588 goto out;
589 }
590
591 host->dev[0] = &dev1->dev;
592 host->dev[1] = &dev2->dev;
593
594 host->host_priv = priv;
595
596 if (priv) {
597 pci_set_drvdata(pdev[0], host);
598 pci_set_drvdata(pdev[1], host);
599 }
600
601 for (i = 0; i < 2; i++) {
566 ret = do_ide_setup_pci_device(pdev[i], d, !i); 602 ret = do_ide_setup_pci_device(pdev[i], d, !i);
567 603
568 /* 604 /*
@@ -576,8 +612,10 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
576 hw[i*2 + 1].irq = hw[i*2].irq = ret; 612 hw[i*2 + 1].irq = hw[i*2].irq = ret;
577 } 613 }
578 614
579 ret = ide_host_add(d, hws, NULL); 615 ret = ide_host_register(host, d, hws);
616 if (ret)
617 ide_host_free(host);
580out: 618out:
581 return ret; 619 return ret;
582} 620}
583EXPORT_SYMBOL_GPL(ide_setup_pci_devices); 621EXPORT_SYMBOL_GPL(ide_pci_init_two);