diff options
Diffstat (limited to 'sys/dev/usb/serial/u3g.c')
-rw-r--r-- | sys/dev/usb/serial/u3g.c | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c index fb25936..eb12f8a 100644 --- a/sys/dev/usb/serial/u3g.c +++ b/sys/dev/usb/serial/u3g.c @@ -30,22 +30,37 @@ * */ -#include "usbdevs.h" + +#include <sys/stdint.h> +#include <sys/stddef.h> +#include <sys/param.h> +#include <sys/queue.h> +#include <sys/types.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/linker_set.h> +#include <sys/module.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/condvar.h> +#include <sys/sysctl.h> +#include <sys/sx.h> +#include <sys/unistd.h> +#include <sys/callout.h> +#include <sys/malloc.h> +#include <sys/priv.h> + #include <dev/usb/usb.h> -#include <dev/usb/usb_mfunc.h> -#include <dev/usb/usb_error.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdi_util.h> +#include "usbdevs.h" #define USB_DEBUG_VAR u3g_debug - -#include <dev/usb/usb_core.h> #include <dev/usb/usb_debug.h> #include <dev/usb/usb_process.h> -#include <dev/usb/usb_request.h> -#include <dev/usb/usb_lookup.h> -#include <dev/usb/usb_util.h> -#include <dev/usb/usb_busdma.h> -#include <dev/usb/usb_msctest.h> #include <dev/usb/usb_dynamic.h> +#include <dev/usb/usb_msctest.h> #include <dev/usb/usb_device.h> #include <dev/usb/serial/usb_serial.h> @@ -501,8 +516,8 @@ u3g_attach(device_t dev) /* set stall by default */ mtx_lock(&sc->sc_mtx); - usbd_transfer_set_stall(sc->sc_xfer[nports][U3G_BULK_WR]); - usbd_transfer_set_stall(sc->sc_xfer[nports][U3G_BULK_RD]); + usbd_xfer_set_stall(sc->sc_xfer[nports][U3G_BULK_WR]); + usbd_xfer_set_stall(sc->sc_xfer[nports][U3G_BULK_RD]); mtx_unlock(&sc->sc_mtx); nports++; /* found one port */ @@ -588,26 +603,27 @@ u3g_stop_write(struct ucom_softc *ucom) } static void -u3g_write_callback(struct usb_xfer *xfer) +u3g_write_callback(struct usb_xfer *xfer, usb_error_t error) { - struct ucom_softc *ucom = xfer->priv_sc; + struct ucom_softc *ucom = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; uint32_t actlen; switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: tr_setup: - if (ucom_get_data(ucom, xfer->frbuffers, 0, - U3G_BSIZE, &actlen)) { - xfer->frlengths[0] = actlen; + pc = usbd_xfer_get_frame(xfer, 0); + if (ucom_get_data(ucom, pc, 0, U3G_BSIZE, &actlen)) { + usbd_xfer_set_frame_len(xfer, 0, actlen); usbd_transfer_submit(xfer); } break; default: /* Error */ - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* do a builtin clear-stall */ - xfer->flags.stall_pipe = 1; + usbd_xfer_set_stall(xfer); goto tr_setup; } break; @@ -616,24 +632,29 @@ tr_setup: } static void -u3g_read_callback(struct usb_xfer *xfer) +u3g_read_callback(struct usb_xfer *xfer, usb_error_t error) { - struct ucom_softc *ucom = xfer->priv_sc; + struct ucom_softc *ucom = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + int actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - ucom_put_data(ucom, xfer->frbuffers, 0, xfer->actlen); + pc = usbd_xfer_get_frame(xfer, 0); + ucom_put_data(ucom, pc, 0, actlen); case USB_ST_SETUP: tr_setup: - xfer->frlengths[0] = xfer->max_data_length; + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); usbd_transfer_submit(xfer); break; default: /* Error */ - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* do a builtin clear-stall */ - xfer->flags.stall_pipe = 1; + usbd_xfer_set_stall(xfer); goto tr_setup; } break; |