@@ -440,12 +440,10 @@ static void vmd_setup_dma_ops(struct vmd_dev *vmd)
}
#undef ASSIGN_VMD_DMA_OPS
-static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
+static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, unsigned char busn,
unsigned int devfn, int reg, int len)
{
- char __iomem *addr = vmd->cfgbar +
- ((bus->number - vmd->busn_start) << 20) +
- (devfn << 12) + reg;
+ char __iomem *addr = vmd->cfgbar + (busn << 20) + (devfn << 12) + reg;
if ((addr - vmd->cfgbar) + len >=
resource_size(&vmd->dev->resource[VMD_CFGBAR]))
@@ -458,11 +456,10 @@ static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
* CPU may deadlock if config space is not serialized on some versions of this
* hardware, so all config space access is done under a spinlock.
*/
-static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
- int len, u32 *value)
+static int vmd_cfg_read(struct vmd_dev *vmd, unsigned char busn,
+ unsigned int devfn, int reg, int len, u32 *value)
{
- struct vmd_dev *vmd = vmd_from_bus(bus);
- char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+ char __iomem *addr = vmd_cfg_addr(vmd, busn, devfn, reg, len);
unsigned long flags;
int ret = 0;
@@ -488,16 +485,23 @@ static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
return ret;
}
+static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
+ int len, u32 *value)
+{
+ struct vmd_dev *vmd = vmd_from_bus(bus);
+ return vmd_cfg_read(vmd, bus->number - vmd->busn_start, devfn,
+ reg, len, value);
+}
+
/*
* VMD h/w converts non-posted config writes to posted memory writes. The
* read-back in this function forces the completion so it returns only after
* the config space was written, as expected.
*/
-static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
- int len, u32 value)
+static int vmd_cfg_write(struct vmd_dev *vmd, unsigned char busn,
+ unsigned int devfn, int reg, int len, u32 value)
{
- struct vmd_dev *vmd = vmd_from_bus(bus);
- char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+ char __iomem *addr = vmd_cfg_addr(vmd, busn, devfn, reg, len);
unsigned long flags;
int ret = 0;
@@ -526,6 +530,14 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
return ret;
}
+static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
+ int len, u32 value)
+{
+ struct vmd_dev *vmd = vmd_from_bus(bus);
+ return vmd_cfg_write(vmd, bus->number - vmd->busn_start, devfn,
+ reg, len, value);
+}
+
static struct pci_ops vmd_ops = {
.read = vmd_pci_read,
.write = vmd_pci_write,