ref: 153793714ec92bd3a3aa4a3b2d26861c54dd03c4
parent: 0daed9edea06e8699b662efe7fe2625ad206f75e
author: cinap_lenrek <[email protected]>
date: Thu Aug 10 21:00:09 EDT 2017
nusb/disk: add a 100ms sleep after ums reset, remove unused note handler, cleanup my pretec usb stick sometimes hangs on the first inquiry request, waiting for the inquiry response forever. adding a 100ms delay after the reset command seems to fix it. getting rid of unused "ding()" note handler and simplify umsrequest() incomplete read handling.
--- a/sys/src/cmd/nusb/disk/disk.c
+++ b/sys/src/cmd/nusb/disk/disk.c
@@ -208,14 +208,6 @@
int diskdebug;
-static void
-ding(void *, char *msg)
-{
- if(strstr(msg, "alarm") != nil)
- noted(NCONT);
- noted(NDFLT);
-}
-
static int
getmaxlun(void)
{
@@ -243,6 +235,7 @@
fprint(2, "disk: reset: %r\n");
return -1;
}
+ sleep(100);
return 0;
}
@@ -253,7 +246,6 @@
return -1;
if(unstall(dev, ums->epin, Ein) < 0)
dprint(2, "disk: unstall epin: %r\n");
-
/* do we need this when epin == epout? */
if(unstall(dev, ums->epout, Eout) < 0)
dprint(2, "disk: unstall epout: %r\n");
@@ -260,7 +252,6 @@
return 0;
}
-
static int
ispow2(uvlong ul)
{
@@ -379,7 +370,7 @@
{
Cbw cbw;
Csw csw;
- int n, nio, left;
+ int n, nio;
Ums *ums;
ums = umsc->ums;
@@ -418,9 +409,8 @@
n = write(ums->epout->dfd, data->p, nio);
else{
n = read(ums->epin->dfd, data->p, nio);
- left = nio - n;
- if (n >= 0 && left > 0) /* didn't fill data->p? */
- memset(data->p + n, 0, left);
+ if (n >= 0 && n < nio) /* didn't fill data->p? */
+ memset(data->p + n, 0, nio - n);
}
nio = n;
if(diskdebug)
@@ -1047,7 +1037,6 @@
}ARGEND
if(argc != 1)
usage();
-
dev = getdev(*argv);
if(dev == nil)
sysfatal("getdev: %r");