From 466615d0c2ae787f66ae1a7255aea40aaabfdbc1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 2 Feb 2016 22:29:14 -0500 Subject: ohci: Convert to new PCI BAR helper functions Use the pci_enable_x() functions. Signed-off-by: Kevin O'Connor --- src/hw/usb-ohci.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c index 0c0bf60..3d55d48 100644 --- a/src/hw/usb-ohci.c +++ b/src/hw/usb-ohci.c @@ -268,6 +268,10 @@ free: static void ohci_controller_setup(struct pci_device *pci) { + struct ohci_regs *regs = pci_enable_membar(pci, PCI_BASE_ADDRESS_0); + if (!regs) + return; + struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl)); if (!cntl) { warn_noalloc(); @@ -276,18 +280,13 @@ ohci_controller_setup(struct pci_device *pci) memset(cntl, 0, sizeof(*cntl)); cntl->usb.pci = pci; cntl->usb.type = USB_TYPE_OHCI; - - u16 bdf = pci->bdf; - u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0); - cntl->regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK); + cntl->regs = regs; dprintf(1, "OHCI init on dev %02x:%02x.%x (regs=%p)\n" - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf) - , pci_bdf_to_fn(bdf), cntl->regs); + , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) + , pci_bdf_to_fn(pci->bdf), cntl->regs); - // Enable bus mastering and memory access. - pci_config_maskw(bdf, PCI_COMMAND - , 0, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY); + pci_enable_busmaster(pci); // XXX - check for and disable SMM control? -- cgit v1.1