diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/serial/umct.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/sys/dev/usb/serial/umct.c b/sys/dev/usb/serial/umct.c index c83a223..7331a0b 100644 --- a/sys/dev/usb/serial/umct.c +++ b/sys/dev/usb/serial/umct.c @@ -115,6 +115,7 @@ struct umct_softc { uint8_t sc_lcr; uint8_t sc_mcr; uint8_t sc_iface_no; + uint8_t sc_swap_cb; uint8_t sc_name[16]; }; @@ -125,8 +126,10 @@ static device_attach_t umct_attach; static device_detach_t umct_detach; static usb_callback_t umct_intr_callback; -static usb_callback_t umct_write_callback; +static usb_callback_t umct_intr_callback_sub; static usb_callback_t umct_read_callback; +static usb_callback_t umct_read_callback_sub; +static usb_callback_t umct_write_callback; static void umct_cfg_do_request(struct umct_softc *sc, uint8_t request, uint16_t len, uint32_t value); @@ -240,7 +243,7 @@ umct_attach(device_t dev) struct usb_attach_arg *uaa = device_get_ivars(dev); struct umct_softc *sc = device_get_softc(dev); int32_t error; - //uint16_t maxp; + uint16_t maxp; uint8_t iface_index; sc->sc_udev = uaa->device; @@ -263,13 +266,13 @@ umct_attach(device_t dev) "transfers failed!\n"); goto detach; } + /* * The real bulk-in endpoint is also marked as an interrupt. * The only way to differentiate it from the real interrupt * endpoint is to look at the wMaxPacketSize field. */ -#ifdef XXX - maxp = UGETW(sc->sc_xfer[UMCT_BULK_DT_RD]->endpoint->edesc->wMaxPacketSize); + maxp = usbd_xfer_max_framelen(sc->sc_xfer[UMCT_BULK_DT_RD]); if (maxp == 0x2) { /* guessed wrong - switch around endpoints */ @@ -278,11 +281,9 @@ umct_attach(device_t dev) sc->sc_xfer[UMCT_INTR_DT_RD] = sc->sc_xfer[UMCT_BULK_DT_RD]; sc->sc_xfer[UMCT_BULK_DT_RD] = temp; - - sc->sc_xfer[UMCT_BULK_DT_RD]->callback = &umct_read_callback; - sc->sc_xfer[UMCT_INTR_DT_RD]->callback = &umct_intr_callback; + sc->sc_swap_cb = 1; } -#endif + sc->sc_obufsize = usbd_xfer_max_len(sc->sc_xfer[UMCT_BULK_DT_WR]); if (uaa->info.idProduct == USB_PRODUCT_MCT_SITECOM_USB232) { @@ -342,7 +343,7 @@ umct_cfg_do_request(struct umct_softc *sc, uint8_t request, } static void -umct_intr_callback(struct usb_xfer *xfer, usb_error_t error) +umct_intr_callback_sub(struct usb_xfer *xfer, usb_error_t error) { struct umct_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc; @@ -547,6 +548,28 @@ umct_stop_write(struct ucom_softc *ucom) } static void +umct_read_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct umct_softc *sc = usbd_xfer_softc(xfer); + + if (sc->sc_swap_cb) + umct_intr_callback_sub(xfer, error); + else + umct_read_callback_sub(xfer, error); +} + +static void +umct_intr_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct umct_softc *sc = usbd_xfer_softc(xfer); + + if (sc->sc_swap_cb) + umct_read_callback_sub(xfer, error); + else + umct_intr_callback_sub(xfer, error); +} + +static void umct_write_callback(struct usb_xfer *xfer, usb_error_t error) { struct umct_softc *sc = usbd_xfer_softc(xfer); @@ -577,7 +600,7 @@ tr_setup: } static void -umct_read_callback(struct usb_xfer *xfer, usb_error_t error) +umct_read_callback_sub(struct usb_xfer *xfer, usb_error_t error) { struct umct_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc; |