diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-12-03 17:11:03 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-12-03 17:11:03 +0000 |
commit | 35b8a692679495606c09e3f023ddee744a8852b9 (patch) | |
tree | 3c9c871258227cfb626bd9c9174fd9cf5f61d496 | |
parent | 133900625619ca253759b43cf39073d1adca6fc3 (diff) |
usbxhci: cleanup
-rw-r--r-- | sys/src/9/imx8/usbxhciimx.c | 4 | ||||
-rw-r--r-- | sys/src/9/port/usbxhci.c | 2 | ||||
-rw-r--r-- | sys/src/9/port/usbxhcipci.c | 19 |
3 files changed, 15 insertions, 10 deletions
diff --git a/sys/src/9/imx8/usbxhciimx.c b/sys/src/9/imx8/usbxhciimx.c index c42ccaeac..e06bed463 100644 --- a/sys/src/9/imx8/usbxhciimx.c +++ b/sys/src/9/imx8/usbxhciimx.c @@ -74,6 +74,8 @@ reset(Hci *hp) if(ctlrs[i] == nil){ uintptr base = VIRTIO + 0x8100000 + i*0x100000; ctlr = xhcialloc((u32int*)base, base - KZERO, 0x100000); + if(ctlr == nil) + break; ctlrs[i] = ctlr; goto Found; } @@ -81,9 +83,9 @@ reset(Hci *hp) return -1; Found: - xhcilinkage(hp, ctlr); hp->tbdf = BUSUNKNOWN; hp->irq = IRQusb1 + i; + xhcilinkage(hp, ctlr); if(i == 0){ iomuxpad("pad_gpio1_io13", "usb1_otg_oc", "~LVTTL ~HYS ~PUE ~ODE FAST 45_OHM"); diff --git a/sys/src/9/port/usbxhci.c b/sys/src/9/port/usbxhci.c index 77fad1574..030b82003 100644 --- a/sys/src/9/port/usbxhci.c +++ b/sys/src/9/port/usbxhci.c @@ -1799,9 +1799,9 @@ xhcialloc(u32int *mmio, u64int base, u64int size) print("usbxhci: no memory for controller\n"); return nil; } + ctlr->mmio = mmio; ctlr->base = base; ctlr->size = size; - ctlr->mmio = mmio; ctlr->dmaaddr = physaddr; diff --git a/sys/src/9/port/usbxhcipci.c b/sys/src/9/port/usbxhcipci.c index f3e419817..27c5e2204 100644 --- a/sys/src/9/port/usbxhcipci.c +++ b/sys/src/9/port/usbxhcipci.c @@ -83,11 +83,11 @@ scanpci(void) static void init(Hci *hp) { - Xhci *xhci = hp->aux; - Pcidev *pcidev = xhci->aux; + Xhci *ctlr = hp->aux; + Pcidev *pcidev = ctlr->aux; pcienable(pcidev); - if(xhci->mmio[0] == -1){ + if(ctlr->mmio[0] == -1){ pcidisable(pcidev); error("controller vanished"); } @@ -97,8 +97,8 @@ init(Hci *hp) static void shutdown(Hci *hp) { - Xhci *xhci = hp->aux; - Pcidev *pcidev = xhci->aux; + Xhci *ctlr = hp->aux; + Pcidev *pcidev = ctlr->aux; xhcishutdown(hp); pcidisable(pcidev); @@ -120,8 +120,10 @@ reset(Hci *hp) * Any adapter matches if no hp->port is supplied, * otherwise the ports must match. */ - for(i = 0; i < nelem(ctlrs) && ctlrs[i] != nil; i++){ + for(i = 0; i < nelem(ctlrs); i++){ ctlr = ctlrs[i]; + if(ctlr == nil) + break; if(ctlr->active == nil) if(hp->port == 0 || hp->port == ctlr->base) goto Found; @@ -130,11 +132,12 @@ reset(Hci *hp) Found: pcidev = ctlr->aux; + hp->irq = pcidev->intl; + hp->tbdf = pcidev->tbdf; + xhcilinkage(hp, ctlr); hp->init = init; hp->shutdown = shutdown; - hp->irq = pcidev->intl; - hp->tbdf = pcidev->tbdf; return 0; } |