Sun Sep 23 14:40:29 2012 UTC ()
Don't use a usbd_status as an int, split error into two variables.


(joerg)
diff -r1.31 -r1.32 src/sys/dev/usb/if_zyd.c

cvs diff -r1.31 -r1.32 src/sys/dev/usb/if_zyd.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_zyd.c 2012/09/23 01:08:17 1.31
+++ src/sys/dev/usb/if_zyd.c 2012/09/23 14:40:29 1.32
@@ -1,38 +1,38 @@ @@ -1,38 +1,38 @@
1/* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ 1/* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */
2/* $NetBSD: if_zyd.c,v 1.31 2012/09/23 01:08:17 chs Exp $ */ 2/* $NetBSD: if_zyd.c,v 1.32 2012/09/23 14:40:29 joerg Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de> 6 * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21/* 21/*
22 * ZyDAS ZD1211/ZD1211B USB WLAN driver. 22 * ZyDAS ZD1211/ZD1211B USB WLAN driver.
23 */ 23 */
24#include <sys/cdefs.h> 24#include <sys/cdefs.h>
25__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.31 2012/09/23 01:08:17 chs Exp $"); 25__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.32 2012/09/23 14:40:29 joerg Exp $");
26 26
27 27
28#include <sys/param.h> 28#include <sys/param.h>
29#include <sys/sockio.h> 29#include <sys/sockio.h>
30#include <sys/proc.h> 30#include <sys/proc.h>
31#include <sys/mbuf.h> 31#include <sys/mbuf.h>
32#include <sys/kernel.h> 32#include <sys/kernel.h>
33#include <sys/socket.h> 33#include <sys/socket.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/malloc.h> 35#include <sys/malloc.h>
36#include <sys/conf.h> 36#include <sys/conf.h>
37#include <sys/device.h> 37#include <sys/device.h>
38 38
@@ -792,54 +792,55 @@ zyd_newstate(struct ieee80211com *ic, en @@ -792,54 +792,55 @@ zyd_newstate(struct ieee80211com *ic, en
792 usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER); 792 usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER);
793 793
794 return 0; 794 return 0;
795} 795}
796 796
797Static int 797Static int
798zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen, 798zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen,
799 void *odata, int olen, u_int flags) 799 void *odata, int olen, u_int flags)
800{ 800{
801 usbd_xfer_handle xfer; 801 usbd_xfer_handle xfer;
802 struct zyd_cmd cmd; 802 struct zyd_cmd cmd;
803 struct rq rq; 803 struct rq rq;
804 uint16_t xferflags; 804 uint16_t xferflags;
805 usbd_status error; 805 int error;
 806 usbd_status uerror;
806 int s = 0; 807 int s = 0;
807 808
808 if ((xfer = usbd_alloc_xfer(sc->sc_udev)) == NULL) 809 if ((xfer = usbd_alloc_xfer(sc->sc_udev)) == NULL)
809 return ENOMEM; 810 return ENOMEM;
810 811
811 cmd.code = htole16(code); 812 cmd.code = htole16(code);
812 bcopy(idata, cmd.data, ilen); 813 bcopy(idata, cmd.data, ilen);
813 814
814 xferflags = USBD_FORCE_SHORT_XFER; 815 xferflags = USBD_FORCE_SHORT_XFER;
815 if (!(flags & ZYD_CMD_FLAG_READ)) 816 if (!(flags & ZYD_CMD_FLAG_READ))
816 xferflags |= USBD_SYNCHRONOUS; 817 xferflags |= USBD_SYNCHRONOUS;
817 else { 818 else {
818 s = splusb(); 819 s = splusb();
819 rq.idata = idata; 820 rq.idata = idata;
820 rq.odata = odata; 821 rq.odata = odata;
821 rq.len = olen / sizeof (struct zyd_pair); 822 rq.len = olen / sizeof (struct zyd_pair);
822 SIMPLEQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); 823 SIMPLEQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq);
823 } 824 }
824 825
825 usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_IOUT], 0, &cmd, 826 usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_IOUT], 0, &cmd,
826 sizeof (uint16_t) + ilen, xferflags, ZYD_INTR_TIMEOUT, NULL); 827 sizeof (uint16_t) + ilen, xferflags, ZYD_INTR_TIMEOUT, NULL);
827 error = usbd_transfer(xfer); 828 uerror = usbd_transfer(xfer);
828 if (error != USBD_IN_PROGRESS && error != 0) { 829 if (uerror != USBD_IN_PROGRESS && uerror != 0) {
829 if (flags & ZYD_CMD_FLAG_READ) 830 if (flags & ZYD_CMD_FLAG_READ)
830 splx(s); 831 splx(s);
831 printf("%s: could not send command (error=%s)\n", 832 printf("%s: could not send command (error=%s)\n",
832 device_xname(sc->sc_dev), usbd_errstr(error)); 833 device_xname(sc->sc_dev), usbd_errstr(uerror));
833 (void)usbd_free_xfer(xfer); 834 (void)usbd_free_xfer(xfer);
834 return EIO; 835 return EIO;
835 } 836 }
836 if (!(flags & ZYD_CMD_FLAG_READ)) { 837 if (!(flags & ZYD_CMD_FLAG_READ)) {
837 (void)usbd_free_xfer(xfer); 838 (void)usbd_free_xfer(xfer);
838 return 0; /* write: don't wait for reply */ 839 return 0; /* write: don't wait for reply */
839 } 840 }
840 /* wait at most one second for command reply */ 841 /* wait at most one second for command reply */
841 error = tsleep(odata, PCATCH, "zydcmd", hz); 842 error = tsleep(odata, PCATCH, "zydcmd", hz);
842 if (error == EWOULDBLOCK) 843 if (error == EWOULDBLOCK)
843 printf("%s: zyd_read sleep timeout\n", device_xname(sc->sc_dev)); 844 printf("%s: zyd_read sleep timeout\n", device_xname(sc->sc_dev));
844 SIMPLEQ_REMOVE(&sc->sc_rqh, &rq, rq, rq); 845 SIMPLEQ_REMOVE(&sc->sc_rqh, &rq, rq, rq);
845 splx(s); 846 splx(s);