diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-09-27 15:32:38 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-09-27 15:32:38 +0000 |
commit | d2061881c3793205ea307ae6eaa712758f737b95 (patch) | |
tree | 10e1ef4e686b216a770708969a85e70763ab052a /sys/dev/usb/uow.c | |
parent | a629bff4c622cfd246b689666d2d98c79efc2a37 (diff) |
Move bulk-in transfer to the separate function.
Diffstat (limited to 'sys/dev/usb/uow.c')
-rw-r--r-- | sys/dev/usb/uow.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sys/dev/usb/uow.c b/sys/dev/usb/uow.c index ad257019991..7a5c0b2b4df 100644 --- a/sys/dev/usb/uow.c +++ b/sys/dev/usb/uow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uow.c,v 1.4 2006/09/27 15:02:45 grange Exp $ */ +/* $OpenBSD: uow.c,v 1.5 2006/09/27 15:32:37 grange Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -70,6 +70,7 @@ Static int uow_ow_bit(void *, int); Static int uow_cmd(struct uow_softc *, int, int); Static void uow_intr(usbd_xfer_handle, usbd_private_handle, usbd_status); +Static int uow_recv(struct uow_softc *, void *, int); USB_MATCH(uow) { @@ -267,20 +268,12 @@ uow_ow_bit(void *arg, int value) { struct uow_softc *sc = arg; u_int8_t data; - usbd_status error; if (uow_cmd(sc, DS2490_COMM_BIT_IO | DS2490_BIT_IM | (value ? DS2490_BIT_D : 0), 0) != 0) return (1); - - usbd_setup_xfer(sc->sc_xfer, sc->sc_ph_ibulk, sc, &data, sizeof(data), - 0, UOW_TIMEOUT, NULL); - error = usbd_sync_transfer(sc->sc_xfer); - if (error != 0) { - printf("%s: failed to do xfer: %s\n", - USBDEVNAME(sc->sc_dev), usbd_errstr(error)); + if (uow_recv(sc, &data, sizeof(data)) != 0) return (1); - } return (data); } @@ -327,3 +320,19 @@ uow_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) wakeup(sc->sc_regs); } + +Static int +uow_recv(struct uow_softc *sc, void *buf, int size) +{ + usbd_status error; + + usbd_setup_xfer(sc->sc_xfer, sc->sc_ph_ibulk, sc, buf, size, 0, + UOW_TIMEOUT, NULL); + if ((error = usbd_sync_transfer(sc->sc_xfer)) != 0) { + printf("%s: failed to recv xfer: %s\n", + USBDEVNAME(sc->sc_dev), usbd_errstr(error)); + return (1); + } + + return (0); +} |