diff options
author | Andrew Thompson <thompsa@FreeBSD.org> | 2009-06-23 02:19:59 +0000 |
---|---|---|
committer | Andrew Thompson <thompsa@FreeBSD.org> | 2009-06-23 02:19:59 +0000 |
commit | ed6d949afdbe3f25e6ef640881d8a0a72d7b7aa8 (patch) | |
tree | ee5c9acfe716a9835136731811e9e1a68751e278 /sys/dev/usb/storage/urio.c | |
parent | 8c8fff3177f8d9611f191878b3864dc8ca3e5965 (diff) | |
download | src-ed6d949afdbe3f25e6ef640881d8a0a72d7b7aa8.tar.gz src-ed6d949afdbe3f25e6ef640881d8a0a72d7b7aa8.zip |
- Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just usb.h and usbdi.h
Notes
Notes:
svn path=/head/; revision=194677
Diffstat (limited to 'sys/dev/usb/storage/urio.c')
-rw-r--r-- | sys/dev/usb/storage/urio.c | 94 |
1 files changed, 57 insertions, 37 deletions
diff --git a/sys/dev/usb/storage/urio.c b/sys/dev/usb/storage/urio.c index 01502bba83a7..6bb2e889e405 100644 --- a/sys/dev/usb/storage/urio.c +++ b/sys/dev/usb/storage/urio.c @@ -44,25 +44,39 @@ __FBSDID("$FreeBSD$"); * 2000/2/24 first version. */ -#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 <sys/conf.h> +#include <sys/fcntl.h> + #include <dev/usb/usb.h> -#include <dev/usb/usb_mfunc.h> -#include <dev/usb/usb_error.h> +#include <dev/usb/usbdi.h> +#include "usbdevs.h" + #include <dev/usb/usb_ioctl.h> -#include <dev/usb/storage/rio500_usb.h> +#include <dev/usb/usb_generic.h> #define USB_DEBUG_VAR urio_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_mbuf.h> -#include <dev/usb/usb_dev.h> -#include <dev/usb/usb_generic.h> + +#include <dev/usb/storage/rio500_usb.h> #if USB_DEBUG static int urio_debug = 0; @@ -242,10 +256,11 @@ detach: } static void -urio_write_callback(struct usb_xfer *xfer) +urio_write_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urio_softc *sc = xfer->priv_sc; + struct urio_softc *sc = usbd_xfer_softc(xfer); struct usb_fifo *f = sc->sc_fifo.fp[USB_FIFO_TX]; + struct usb_page_cache *pc; uint32_t actlen; switch (USB_GET_STATE(xfer)) { @@ -255,16 +270,17 @@ urio_write_callback(struct usb_xfer *xfer) usbd_transfer_start(sc->sc_xfer[URIO_T_WR_CS]); return; } - if (usb_fifo_get_data(f, xfer->frbuffers, 0, - xfer->max_data_length, &actlen, 0)) { + pc = usbd_xfer_get_frame(xfer, 0); + if (usb_fifo_get_data(f, pc, 0, + usbd_xfer_max_len(xfer), &actlen, 0)) { - xfer->frlengths[0] = actlen; + usbd_xfer_set_frame_len(xfer, 0, actlen); usbd_transfer_submit(xfer); } return; default: /* Error */ - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ sc->sc_flags |= URIO_FLAG_WRITE_STALL; usbd_transfer_start(sc->sc_xfer[URIO_T_WR_CS]); @@ -274,9 +290,9 @@ urio_write_callback(struct usb_xfer *xfer) } static void -urio_write_clear_stall_callback(struct usb_xfer *xfer) +urio_write_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urio_softc *sc = xfer->priv_sc; + struct urio_softc *sc = usbd_xfer_softc(xfer); struct usb_xfer *xfer_other = sc->sc_xfer[URIO_T_WR]; if (usbd_clear_stall_callback(xfer, xfer_other)) { @@ -287,15 +303,19 @@ urio_write_clear_stall_callback(struct usb_xfer *xfer) } static void -urio_read_callback(struct usb_xfer *xfer) +urio_read_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urio_softc *sc = xfer->priv_sc; + struct urio_softc *sc = usbd_xfer_softc(xfer); struct usb_fifo *f = sc->sc_fifo.fp[USB_FIFO_RX]; + struct usb_page_cache *pc; + int actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - usb_fifo_put_data(f, xfer->frbuffers, 0, - xfer->actlen, 1); + pc = usbd_xfer_get_frame(xfer, 0); + usb_fifo_put_data(f, pc, 0, actlen, 1); case USB_ST_SETUP: if (sc->sc_flags & URIO_FLAG_READ_STALL) { @@ -303,13 +323,13 @@ urio_read_callback(struct usb_xfer *xfer) return; } if (usb_fifo_put_bytes_max(f) != 0) { - xfer->frlengths[0] = xfer->max_data_length; + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); usbd_transfer_submit(xfer); } return; default: /* Error */ - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ sc->sc_flags |= URIO_FLAG_READ_STALL; usbd_transfer_start(sc->sc_xfer[URIO_T_RD_CS]); @@ -319,9 +339,9 @@ urio_read_callback(struct usb_xfer *xfer) } static void -urio_read_clear_stall_callback(struct usb_xfer *xfer) +urio_read_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urio_softc *sc = xfer->priv_sc; + struct urio_softc *sc = usbd_xfer_softc(xfer); struct usb_xfer *xfer_other = sc->sc_xfer[URIO_T_RD]; if (usbd_clear_stall_callback(xfer, xfer_other)) { @@ -334,7 +354,7 @@ urio_read_clear_stall_callback(struct usb_xfer *xfer) static void urio_start_read(struct usb_fifo *fifo) { - struct urio_softc *sc = fifo->priv_sc0; + struct urio_softc *sc = usb_fifo_softc(fifo); usbd_transfer_start(sc->sc_xfer[URIO_T_RD]); } @@ -342,7 +362,7 @@ urio_start_read(struct usb_fifo *fifo) static void urio_stop_read(struct usb_fifo *fifo) { - struct urio_softc *sc = fifo->priv_sc0; + struct urio_softc *sc = usb_fifo_softc(fifo); usbd_transfer_stop(sc->sc_xfer[URIO_T_RD_CS]); usbd_transfer_stop(sc->sc_xfer[URIO_T_RD]); @@ -351,7 +371,7 @@ urio_stop_read(struct usb_fifo *fifo) static void urio_start_write(struct usb_fifo *fifo) { - struct urio_softc *sc = fifo->priv_sc0; + struct urio_softc *sc = usb_fifo_softc(fifo); usbd_transfer_start(sc->sc_xfer[URIO_T_WR]); } @@ -359,7 +379,7 @@ urio_start_write(struct usb_fifo *fifo) static void urio_stop_write(struct usb_fifo *fifo) { - struct urio_softc *sc = fifo->priv_sc0; + struct urio_softc *sc = usb_fifo_softc(fifo); usbd_transfer_stop(sc->sc_xfer[URIO_T_WR_CS]); usbd_transfer_stop(sc->sc_xfer[URIO_T_WR]); @@ -368,7 +388,7 @@ urio_stop_write(struct usb_fifo *fifo) static int urio_open(struct usb_fifo *fifo, int fflags) { - struct urio_softc *sc = fifo->priv_sc0; + struct urio_softc *sc = usb_fifo_softc(fifo); if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) { return (EACCES); @@ -380,7 +400,7 @@ urio_open(struct usb_fifo *fifo, int fflags) mtx_unlock(&sc->sc_mtx); if (usb_fifo_alloc_buffer(fifo, - sc->sc_xfer[URIO_T_RD]->max_data_length, + usbd_xfer_max_len(sc->sc_xfer[URIO_T_RD]), URIO_IFQ_MAXLEN)) { return (ENOMEM); } @@ -390,7 +410,7 @@ urio_open(struct usb_fifo *fifo, int fflags) sc->sc_flags |= URIO_FLAG_WRITE_STALL; if (usb_fifo_alloc_buffer(fifo, - sc->sc_xfer[URIO_T_WR]->max_data_length, + usbd_xfer_max_len(sc->sc_xfer[URIO_T_WR]), URIO_IFQ_MAXLEN)) { return (ENOMEM); } |