From: mpi Date: Sun, 10 Aug 2014 11:21:49 +0000 (+0000) Subject: Merge xhci_device_setup() into xhci_pipe_init() there's no reason to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cf73556ad0bb0576d6ee5e8547a2779cb707abfb;p=openbsd Merge xhci_device_setup() into xhci_pipe_init() there's no reason to have a separate function anymore, it is just a wrapper around the "set address" command. --- diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 1f209ab0350..6e7ad79665f 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.23 2014/08/10 11:18:57 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.24 2014/08/10 11:21:49 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -80,7 +80,6 @@ void xhci_event_xfer(struct xhci_softc *, uint64_t, uint32_t, uint32_t); void xhci_event_command(struct xhci_softc *, uint64_t); void xhci_event_port_change(struct xhci_softc *, uint64_t, uint32_t); int xhci_pipe_init(struct xhci_softc *, struct usbd_pipe *, uint32_t); -int xhci_device_setup(struct xhci_softc *, struct usbd_device *, uint8_t); int xhci_scratchpad_alloc(struct xhci_softc *, int); void xhci_scratchpad_free(struct xhci_softc *); int xhci_softdev_alloc(struct xhci_softc *, uint8_t); @@ -976,35 +975,6 @@ xhci_get_txinfo(struct xhci_softc *sc, struct usbd_pipe *pipe) return (XHCI_EPCTX_MAX_ESIT_PAYLOAD(mep) | XHCI_EPCTX_AVG_TRB_LEN(atl)); } -int -xhci_device_setup(struct xhci_softc *sc, struct usbd_device *dev, uint8_t slot) -{ - struct xhci_soft_dev *sdev = &sc->sc_sdevs[slot]; - struct xhci_sctx *sctx; - uint8_t addr; - int error; - - /* - * Issue only one Set address to set up the slot context and - * assign an address. - */ - error = xhci_cmd_address_device(sc, slot, DMAADDR(&sdev->ictx_dma, 0)); - if (error) - return (error); - - usb_syncmem(&sdev->octx_dma, 0, sc->sc_pagesize, BUS_DMASYNC_POSTREAD); - - /* Get output slot context. */ - sctx = KERNADDR(&sdev->octx_dma, 0); - addr = XHCI_SCTX_DEV_ADDR(letoh32(sctx->state)); - if (addr == 0) - return (EINVAL); - - DPRINTF(("%s: dev %d internal addr %d\n", DEVNAME(sc), slot, addr)); - - return (0); -} - int xhci_pipe_init(struct xhci_softc *sc, struct usbd_pipe *pipe, uint32_t port) { @@ -1105,14 +1075,34 @@ xhci_pipe_init(struct xhci_softc *sc, struct usbd_pipe *pipe, uint32_t port) usb_syncmem(&sdev->ictx_dma, 0, sc->sc_pagesize, BUS_DMASYNC_PREWRITE); - if (xp->dci == 1) - error = xhci_device_setup(sc, pipe->device, xp->slot); - else + /* + * Issue only one Set address to set up the slot context and + * assign an address. + */ + if (xp->dci == 1) { + error = xhci_cmd_address_device(sc, xp->slot, + DMAADDR(&sdev->ictx_dma, 0)); + } else { error = xhci_cmd_configure_ep(sc, xp->slot, DMAADDR(&sdev->ictx_dma, 0)); + } usb_syncmem(&sdev->octx_dma, 0, sc->sc_pagesize, BUS_DMASYNC_POSTREAD); +#ifdef XHCI_DEBUG + if (xp->dci == 1 && !error) { + struct xhci_sctx *sctx; + uint8_t addr; + + /* Get output slot context. */ + sctx = KERNADDR(&sdev->octx_dma, 0); + addr = XHCI_SCTX_DEV_ADDR(letoh32(sctx->state)); + error = (addr != 0); + + printf("%s: dev %d addr %d\n", DEVNAME(sc), xp->slot, addr); + } +#endif + if (error) { xhci_ring_free(sc, &xp->ring); return (EIO);