/* Normally called automaticall from do_ide_pci_setup_device, but is also used directly as a helper function by some controllers where the chipset setup is not the default PCI IDE one.  */
void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, struct ide_hw *hw, struct ide_hw **hws)
/* Normally called automaticall from do_ide_pci_setup_device, but is also used directly as a helper function by some controllers where the chipset setup is not the default PCI IDE one.  */
void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, struct ide_hw *hw, struct ide_hw **hws)
{
	int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
	u8 tmp;
	for (port = 0; port < channels; ++port) {
		const struct ide_pci_enablebit *e = &d->enablebits[port];
		if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
		    (tmp & e->mask) != e->val)) {
			printk(KERN_INFO "%s %s: IDE port disabled\n",
				d->name, pci_name(dev));
			continue;
		}
		if (ide_hw_configure(dev, d, port, hw + port))
			continue;
		*(hws + port) = hw + port;
	}
}