summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-08-17 00:46:33 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-08-17 00:46:33 +0200
commit9f65da6d7049259d505552f483339057172959ba (patch)
treea6b2fb7968216b541250e7fee6976ddb665baed3
parent961a87388965341f1217ec2b65f56aeb6ca1576c (diff)
downloadplan9front-9f65da6d7049259d505552f483339057172959ba.tar.xz
usb/ptp: ignore zero reads
-rw-r--r--sys/src/cmd/nusb/ptp/usbptp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/src/cmd/nusb/ptp/usbptp.c b/sys/src/cmd/nusb/ptp/usbptp.c
index 5d6a0ac7c..190163408 100644
--- a/sys/src/cmd/nusb/ptp/usbptp.c
+++ b/sys/src/cmd/nusb/ptp/usbptp.c
@@ -122,10 +122,13 @@ isinterrupt(void)
static int
usbread(Dev *ep, void *data, int len)
{
- int n;
+ int n, try;
- for(;;){
+ n = 0;
+ for(try = 0; try < 4; try++){
n = read(ep->dfd, data, len);
+ if(n == 0)
+ continue;
if(n >= 0 || !isinterrupt())
break;
}
@@ -135,10 +138,13 @@ usbread(Dev *ep, void *data, int len)
static int
usbwrite(Dev *ep, void *data, int len)
{
- int n;
+ int n, try;
- for(;;){
+ n = 0;
+ for(try = 0; try < 4; try++){
n = write(ep->dfd, data, len);
+ if(n == 0)
+ continue;
if(n >= 0 || !isinterrupt())
break;
}
@@ -198,7 +204,7 @@ ptpcheckerr(Ptprpc *rpc, int type, int transid, int length)
char *s;
if(length < 4+2+2+4){
- werrstr("short response");
+ werrstr("short response: %d < %d", length, 4+2+2+4);
return -1;
}
if(GET4(rpc->length) < length){
@@ -291,6 +297,7 @@ ptprpc(int code, int flags, ...)
if((n = usbread(usbep[In], &rpc, sizeof(rpc))) < 0)
return -1;
+
if(debug)
hexdump("data<", (uchar*)&rpc, n);
if(ptpcheckerr(&rpc, 2, t, n))