/* Returns BAR position in config space, or 0 if the BAR is invalid.  */
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
/* Returns BAR position in config space, or 0 if the BAR is invalid.  */
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
{
	int reg;
	if (resno < PCI_ROM_RESOURCE) {
		*type = pci_bar_unknown;
		return PCI_BASE_ADDRESS_0 + 4 * resno;
	} else if (resno == PCI_ROM_RESOURCE) {
		*type = pci_bar_mem32;
		return dev->rom_base_reg;
	} else if (resno < PCI_BRIDGE_RESOURCES) {
		reg = pci_iov_resource_bar(dev, resno, type);
		if (reg)
			return reg;
	}
	dev_err(&dev->dev, "BAR %d: invalid resource\n", resno);
	return 0;
}