diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-24 16:53:16 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-24 16:53:16 -0400 |
commit | 1d76d9dc448d5a6fc7b49ba06c634aa6927bcc3d (patch) | |
tree | 0b04ce3643888a6fc86b889f33bec8455286b7af /drivers/ide/pci/it821x.c | |
parent | 74811f355f4f69a187fa74892dcf2a684b84ce99 (diff) |
it821x: convert to use ->host_priv
While at it:
* Allocate both struct it821x_dev instances at once.
* Don't leak itdevs on ide_pci_init_one() failure.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r-- | drivers/ide/pci/it821x.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index 40186f9e56aa..e63fdafe18fc 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -534,8 +534,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = { | |||
534 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 534 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
535 | { | 535 | { |
536 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 536 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
537 | struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); | 537 | struct ide_host *host = pci_get_drvdata(dev); |
538 | struct it821x_dev *idev = itdevs[hwif->channel]; | 538 | struct it821x_dev *itdevs = host->host_priv; |
539 | struct it821x_dev *idev = itdevs + hwif->channel; | ||
539 | u8 conf; | 540 | u8 conf; |
540 | 541 | ||
541 | ide_set_hwifdata(hwif, idev); | 542 | ide_set_hwifdata(hwif, idev); |
@@ -648,23 +649,20 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = { | |||
648 | 649 | ||
649 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 650 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
650 | { | 651 | { |
651 | struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; | 652 | struct it821x_dev *itdevs; |
652 | unsigned int i; | 653 | int rc; |
653 | |||
654 | for (i = 0; i < 2; i++) { | ||
655 | itdev = kzalloc(sizeof(*itdev), GFP_KERNEL); | ||
656 | if (itdev == NULL) { | ||
657 | kfree(itdevs[0]); | ||
658 | printk(KERN_ERR "it821x: out of memory\n"); | ||
659 | return -ENOMEM; | ||
660 | } | ||
661 | 654 | ||
662 | itdevs[i] = itdev; | 655 | itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL); |
656 | if (itdevs == NULL) { | ||
657 | printk(KERN_ERR "it821x: out of memory\n"); | ||
658 | return -ENOMEM; | ||
663 | } | 659 | } |
664 | 660 | ||
665 | pci_set_drvdata(dev, itdevs); | 661 | rc = ide_pci_init_one(dev, &it821x_chipsets[id->driver_data], itdevs); |
662 | if (rc) | ||
663 | kfree(itdevs); | ||
666 | 664 | ||
667 | return ide_pci_init_one(dev, &it821x_chipsets[id->driver_data], NULL); | 665 | return rc; |
668 | } | 666 | } |
669 | 667 | ||
670 | static const struct pci_device_id it821x_pci_tbl[] = { | 668 | static const struct pci_device_id it821x_pci_tbl[] = { |