Module Name: src
Committed By: skrll
Date: Sat Apr 30 08:48:09 UTC 2016
Modified Files:
src/sys/dev/usb [nick-nhusb]: if_upgt.c
Log Message:
Partial conversion from spl(9)/tsleep(9) to mutex(9)/condvar(9)
To generate a diff of this commit:
cvs rdiff -u -r1.12.4.10 -r1.12.4.11 src/sys/dev/usb/if_upgt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/if_upgt.c
diff -u src/sys/dev/usb/if_upgt.c:1.12.4.10 src/sys/dev/usb/if_upgt.c:1.12.4.11
--- src/sys/dev/usb/if_upgt.c:1.12.4.10 Sat Mar 19 11:30:19 2016
+++ src/sys/dev/usb/if_upgt.c Sat Apr 30 08:48:09 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_upgt.c,v 1.12.4.10 2016/03/19 11:30:19 skrll Exp $ */
+/* $NetBSD: if_upgt.c,v 1.12.4.11 2016/04/30 08:48:09 skrll Exp $ */
/* $OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.12.4.10 2016/03/19 11:30:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.12.4.11 2016/04/30 08:48:09 skrll Exp $");
#include <sys/param.h>
#include <sys/callout.h>
@@ -1004,7 +1004,11 @@ upgt_eeprom_read(struct upgt_softc *sc)
"could not transmit EEPROM data URB\n");
return EIO;
}
- if (tsleep(sc, 0, "eeprom_request", UPGT_USB_TIMEOUT)) {
+
+ mutex_enter(&sc->sc_mtx);
+ int res = cv_timedwait(&sc->sc_cv, &sc->sc_mtx, UPGT_USB_TIMEOUT);
+ mutex_exit(&sc->sc_mtx);
+ if (res) {
aprint_error_dev(sc->sc_dev,
"timeout while waiting for EEPROM data\n");
return EIO;
@@ -1773,12 +1777,15 @@ upgt_rx_cb(struct usbd_xfer *xfer, void
DPRINTF(2, "%s: received EEPROM block (offset=%d, len=%d)\n",
device_xname(sc->sc_dev), eeprom_offset, eeprom_len);
+ mutex_enter(&sc->sc_mtx);
memcpy(sc->sc_eeprom + eeprom_offset,
data_rx->buf + sizeof(struct upgt_lmac_eeprom) + 4,
eeprom_len);
- /* EEPROM data has arrived in time, wakeup tsleep() */
- wakeup(sc);
+ /* EEPROM data has arrived in time, wakeup upgt_eeprom_read */
+ /* Note eeprom data arrived */
+ cv_broadcast(&sc->sc_cv);
+ mutex_exit(&sc->sc_mtx);
} else
if (h1_type == UPGT_H1_TYPE_CTRL &&
h2_type == UPGT_H2_TYPE_TX_DONE) {
@@ -2304,6 +2311,7 @@ upgt_alloc_cmd(struct upgt_softc *sc)
data_cmd->buf = usbd_get_buffer(data_cmd->xfer);
+ cv_init(&sc->sc_cv, "upgteeprom");
mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE);
return 0;
@@ -2350,6 +2358,7 @@ upgt_free_cmd(struct upgt_softc *sc)
}
mutex_destroy(&sc->sc_mtx);
+ cv_destroy(&sc->sc_cv);
}
static int