diff options
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r-- | drivers/ide/pci/it821x.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index d8a167451fd6..a38ec47423a0 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -523,16 +523,12 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
523 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 523 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
524 | { | 524 | { |
525 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 525 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
526 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 526 | struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); |
527 | struct it821x_dev *idev = itdevs[hwif->channel]; | ||
527 | u8 conf; | 528 | u8 conf; |
528 | 529 | ||
529 | hwif->quirkproc = &it821x_quirkproc; | 530 | hwif->quirkproc = &it821x_quirkproc; |
530 | 531 | ||
531 | if (idev == NULL) { | ||
532 | printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | ide_set_hwifdata(hwif, idev); | 532 | ide_set_hwifdata(hwif, idev); |
537 | 533 | ||
538 | pci_read_config_byte(dev, 0x50, &conf); | 534 | pci_read_config_byte(dev, 0x50, &conf); |
@@ -623,7 +619,6 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha | |||
623 | .name = name_str, \ | 619 | .name = name_str, \ |
624 | .init_chipset = init_chipset_it821x, \ | 620 | .init_chipset = init_chipset_it821x, \ |
625 | .init_hwif = init_hwif_it821x, \ | 621 | .init_hwif = init_hwif_it821x, \ |
626 | .host_flags = IDE_HFLAG_BOOTABLE, \ | ||
627 | .pio_mask = ATA_PIO4, \ | 622 | .pio_mask = ATA_PIO4, \ |
628 | } | 623 | } |
629 | 624 | ||
@@ -642,6 +637,22 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = { | |||
642 | 637 | ||
643 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 638 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
644 | { | 639 | { |
640 | struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; | ||
641 | unsigned int i; | ||
642 | |||
643 | for (i = 0; i < 2; i++) { | ||
644 | itdev = kzalloc(sizeof(*itdev), GFP_KERNEL); | ||
645 | if (itdev == NULL) { | ||
646 | kfree(itdevs[0]); | ||
647 | printk(KERN_ERR "it821x: out of memory\n"); | ||
648 | return -ENOMEM; | ||
649 | } | ||
650 | |||
651 | itdevs[i] = itdev; | ||
652 | } | ||
653 | |||
654 | pci_set_drvdata(dev, itdevs); | ||
655 | |||
645 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); | 656 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); |
646 | } | 657 | } |
647 | 658 | ||