Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nick-nhusb]: src/sys/dev/usb Partial conversion from spl(9)/tsleep(9) to...



details:   https://anonhg.NetBSD.org/src/rev/62eef3a9ba2b
branches:  nick-nhusb
changeset: 334504:62eef3a9ba2b
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Apr 30 08:48:09 2016 +0000

description:
Partial conversion from spl(9)/tsleep(9) to mutex(9)/condvar(9)

diffstat:

 sys/dev/usb/if_upgt.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (65 lines):

diff -r d265217af6a1 -r 62eef3a9ba2b sys/dev/usb/if_upgt.c
--- a/sys/dev/usb/if_upgt.c     Sat Apr 30 08:45:13 2016 +0000
+++ b/sys/dev/usb/if_upgt.c     Sat Apr 30 08:48:09 2016 +0000
@@ -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 @@
                            "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 @@
                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 @@
 
        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 @@
        }
 
        mutex_destroy(&sc->sc_mtx);
+       cv_destroy(&sc->sc_cv);
 }
 
 static int



Home | Main Index | Thread Index | Old Index