{
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
        u8 mask                 = hwif->ultra_mask;
 
        switch (info->chip_type) {
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
 
        switch (info->chip_type) {
        case HPT372 :
 
 static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
 {
-       struct pci_dev  *dev    = to_pci_dev(drive->hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       ide_hwif_t *hwif        = drive->hwif;
+       struct pci_dev *dev     = to_pci_dev(hwif->dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
        struct hpt_timings *t   = info->timings;
        u8  itr_addr            = 0x40 + (drive->dn * 4);
        u32 old_itr             = 0;
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev  *dev    = to_pci_dev(hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
 
        if (drive->quirk_list) {
                if (info->chip_type >= HPT370) {
 
 static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name)
 {
-       struct hpt_info *info   = kmalloc(sizeof(struct hpt_info), GFP_KERNEL);
        unsigned long io_base   = pci_resource_start(dev, 4);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (&dev->dev == host->dev[1]);
        u8 pci_clk,  dpll_clk   = 0;    /* PCI and DPLL clock in MHz */
        u8 chip_type;
        enum ata_clock  clock;
 
-       if (info == NULL) {
-               printk(KERN_ERR "%s: out of memory!\n", name);
-               return -ENOMEM;
-       }
-
-       /*
-        * Copy everything from a static "template" structure
-        * to just allocated per-chip hpt_info structure.
-        */
-       memcpy(info, pci_get_drvdata(dev), sizeof(struct hpt_info));
        chip_type = info->chip_type;
 
        pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
 
                if (info->timings->clock_table[clock] == NULL) {
                        printk(KERN_ERR "%s: unknown bus timing!\n", name);
-                       kfree(info);
                        return -EIO;
                }
 
                }
                if (adjust == 8) {
                        printk(KERN_ERR "%s: DPLL did not stabilize!\n", name);
-                       kfree(info);
                        return -EIO;
                }
 
        info->pci_clk   = pci_clk;
        info->clock     = clock;
 
-       /* Point to this chip's own instance of the hpt_info structure. */
-       pci_set_drvdata(dev, info);
-
        if (chip_type >= HPT370) {
                u8  mcr1, mcr4;
 
 static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
 {
        struct pci_dev  *dev    = to_pci_dev(hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
        u8 chip_type            = info->chip_type;
        u8 scr1 = 0, ata66      = hwif->channel ? 0x01 : 0x02;
 
 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
 {
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
-       struct hpt_info *info   = pci_get_drvdata(dev);
+       struct ide_host *host   = pci_get_drvdata(dev);
+       struct hpt_info *info   = host->host_priv + (hwif->dev == host->dev[1]);
        int serialize           = HPT_SERIALIZE_IO;
        u8  chip_type           = info->chip_type;
        u8  new_mcr, old_mcr    = 0;
 static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
        const struct hpt_info *info = NULL;
+       struct hpt_info *dyn_info;
        struct pci_dev *dev2 = NULL;
        struct ide_port_info d;
        u8 idx = id->driver_data;
        u8 rev = dev->revision;
+       int ret;
 
        if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1))
                return -ENODEV;
        if (info == &hpt370 || info == &hpt370a)
                d.dma_ops = &hpt370_dma_ops;
 
-       pci_set_drvdata(dev, (void *)info);
-
        if (info == &hpt36x || info == &hpt374)
                dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
 
-       if (dev2) {
-               int ret;
+       dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
+       if (dyn_info == NULL) {
+               printk(KERN_ERR "%s: out of memory!\n", d.name);
+               pci_dev_put(dev2);
+               return -ENOMEM;
+       }
+
+       /*
+        * Copy everything from a static "template" structure
+        * to just allocated per-chip hpt_info structure.
+        */
+       memcpy(dyn_info, info, sizeof(*dyn_info));
 
-               pci_set_drvdata(dev2, (void *)info);
+       if (dev2) {
+               memcpy(dyn_info + 1, info, sizeof(*dyn_info));
 
                if (info == &hpt374)
                        hpt374_init(dev, dev2);
                                d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE;
                }
 
-               ret = ide_pci_init_two(dev, dev2, &d, NULL);
-               if (ret < 0)
+               ret = ide_pci_init_two(dev, dev2, &d, dyn_info);
+               if (ret < 0) {
                        pci_dev_put(dev2);
+                       kfree(dyn_info);
+               }
                return ret;
        }
 
-       return ide_pci_init_one(dev, &d, NULL);
+       ret = ide_pci_init_one(dev, &d, dyn_info);
+       if (ret < 0)
+               kfree(dyn_info);
+
+       return ret;
 }
 
 static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {