Index: head/sys/dev/usb/controller/ehci.c =================================================================== --- head/sys/dev/usb/controller/ehci.c +++ head/sys/dev/usb/controller/ehci.c @@ -90,8 +90,7 @@ #include #define EHCI_BUS2SC(bus) \ - ((ehci_softc_t *)(((uint8_t *)(bus)) - \ - ((uint8_t *)&(((ehci_softc_t *)0)->sc_bus)))) + __containerof(bus, ehci_softc_t, sc_bus) #ifdef USB_DEBUG static int ehcidebug = 0; Index: head/sys/dev/usb/controller/ohci.c =================================================================== --- head/sys/dev/usb/controller/ohci.c +++ head/sys/dev/usb/controller/ohci.c @@ -79,8 +79,7 @@ #include #define OHCI_BUS2SC(bus) \ - ((ohci_softc_t *)(((uint8_t *)(bus)) - \ - ((uint8_t *)&(((ohci_softc_t *)0)->sc_bus)))) + __containerof(bus, ohci_softc_t, sc_bus) #ifdef USB_DEBUG static int ohcidebug = 0; Index: head/sys/dev/usb/controller/uhci.c =================================================================== --- head/sys/dev/usb/controller/uhci.c +++ head/sys/dev/usb/controller/uhci.c @@ -83,8 +83,7 @@ #define alt_next next #define UHCI_BUS2SC(bus) \ - ((uhci_softc_t *)(((uint8_t *)(bus)) - \ - ((uint8_t *)&(((uhci_softc_t *)0)->sc_bus)))) + __containerof(bus, uhci_softc_t, sc_bus) #ifdef USB_DEBUG static int uhcidebug = 0; Index: head/sys/dev/usb/controller/xhci.c =================================================================== --- head/sys/dev/usb/controller/xhci.c +++ head/sys/dev/usb/controller/xhci.c @@ -86,8 +86,7 @@ #include #define XHCI_BUS2SC(bus) \ - ((struct xhci_softc *)(((uint8_t *)(bus)) - \ - ((uint8_t *)&(((struct xhci_softc *)0)->sc_bus)))) + __containerof(bus, struct xhci_softc, sc_bus) static SYSCTL_NODE(_hw_usb, OID_AUTO, xhci, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "USB XHCI"); Index: head/sys/dev/usb/usb_transfer.h =================================================================== --- head/sys/dev/usb/usb_transfer.h +++ head/sys/dev/usb/usb_transfer.h @@ -153,9 +153,7 @@ }; #define USB_DMATAG_TO_XROOT(dpt) \ - ((struct usb_xfer_root *)( \ - ((uint8_t *)(dpt)) - \ - ((uint8_t *)&((struct usb_xfer_root *)0)->dma_parent_tag))) + __containerof(dpt, struct usb_xfer_root, dma_parent_tag) /* * The following structure is used to keep information about memory