PERFORCE change 145684 for review
Weongyo Jeong
weongyo at FreeBSD.org
Wed Jul 23 08:51:36 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145684
Change 145684 by weongyo at weongyo_ws on 2008/07/23 08:50:56
found a more clean way to process this case that resetting events
before calling the Query/Set callback.
Affected files ...
.. //depot/projects/ndisusb/sys/compat/ndis/kern_ndis.c#4 edit
Differences ...
==== //depot/projects/ndisusb/sys/compat/ndis/kern_ndis.c#4 (text+ko) ====
@@ -879,15 +879,15 @@
sc = arg;
+ KeResetEvent(&sc->ndis_block->nmb_setevent);
+
KeAcquireSpinLock(&sc->ndis_block->nmb_lock, &irql);
if (sc->ndis_block->nmb_pendingreq != NULL) {
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
panic("ndis_set_info() called while other request pending");
- } else {
+ } else
sc->ndis_block->nmb_pendingreq = (ndis_request *)sc;
- sc->ndis_block->nmb_setstat = -1;
- }
setfunc = sc->ndis_chars->nmc_setinfo_func;
adapter = sc->ndis_block->nmb_miniportadapterctx;
@@ -903,16 +903,12 @@
&byteswritten, &bytesneeded);
sc->ndis_block->nmb_pendingreq = NULL;
- /* please see a description of ndis_get_info() why we check this. */
- if (rval == NDIS_STATUS_PENDING && sc->ndis_block->nmb_setstat != -1)
- rval = sc->ndis_block->nmb_setstat;
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
if (rval == NDIS_STATUS_PENDING) {
/* Wait up to 5 seconds. */
duetime = (5 * 1000000) * -10;
- KeResetEvent(&sc->ndis_block->nmb_setevent);
KeWaitForSingleObject(&sc->ndis_block->nmb_setevent,
0, 0, FALSE, &duetime);
rval = sc->ndis_block->nmb_setstat;
@@ -1306,16 +1302,15 @@
sc = arg;
+ KeResetEvent(&sc->ndis_block->nmb_getevent);
+
KeAcquireSpinLock(&sc->ndis_block->nmb_lock, &irql);
if (sc->ndis_block->nmb_pendingreq != NULL) {
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
panic("ndis_get_info() called while other request pending");
- } else {
+ } else
sc->ndis_block->nmb_pendingreq = (ndis_request *)sc;
- /* NB: `nmb_getstat' type is uint32_t. */
- sc->ndis_block->nmb_getstat = -1;
- }
queryfunc = sc->ndis_chars->nmc_queryinfo_func;
adapter = sc->ndis_block->nmb_miniportadapterctx;
@@ -1331,18 +1326,6 @@
&byteswritten, &bytesneeded);
sc->ndis_block->nmb_pendingreq = NULL;
- /*
- * NB: some NDIS USB drivers (AFAIK Netgear WG111v2) looks that they
- * return NDIS_STATUS_PENDING value even if they already called the
- * callback function in their routine, ndis_getdone_func(). So we
- * need to check the value whether it's set or not before waiting for
- * 5 seconds. If we doesn't, we would always be blocked for 5 seconds
- * because the `nmb_getevent' event wouldn't be happened that the event
- * is already fired before we try to set it using
- * KeWaitForSingleObject().
- */
- if (rval == NDIS_STATUS_PENDING && sc->ndis_block->nmb_getstat != -1)
- rval = sc->ndis_block->nmb_getstat;
KeReleaseSpinLock(&sc->ndis_block->nmb_lock, irql);
@@ -1351,7 +1334,6 @@
if (rval == NDIS_STATUS_PENDING) {
/* Wait up to 5 seconds. */
duetime = (5 * 1000000) * -10;
- KeResetEvent(&sc->ndis_block->nmb_getevent);
KeWaitForSingleObject(&sc->ndis_block->nmb_getevent,
0, 0, FALSE, &duetime);
rval = sc->ndis_block->nmb_getstat;
More information about the p4-projects
mailing list