summaryrefslogtreecommitdiff
path: root/sys/src/cmd/nusb/serial/prolific.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-07-05 08:17:37 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-07-05 08:17:37 +0200
commit8677db333a11de80971df3e60f787b72b45a568c (patch)
tree521566837bf0eac9dd4b56fe1eb9423e8caa5b9f /sys/src/cmd/nusb/serial/prolific.c
parent502247bf92f380a642b8e17048466c18bb9efd24 (diff)
nusb/serial: implement flushes
handle reads and writes with 9pqueue(2) so they can be flushed and wont hang the filesystem. this also lets us get rid of the timeouts. ftdi is still full of braindamage that should be rewritten, but i dont have a device to test.
Diffstat (limited to 'sys/src/cmd/nusb/serial/prolific.c')
-rw-r--r--sys/src/cmd/nusb/serial/prolific.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/sys/src/cmd/nusb/serial/prolific.c b/sys/src/cmd/nusb/serial/prolific.c
index a0a489111..4ada08fa9 100644
--- a/sys/src/cmd/nusb/serial/prolific.c
+++ b/sys/src/cmd/nusb/serial/prolific.c
@@ -446,12 +446,13 @@ plinit(Serialport *p)
plgetparam(p);
qunlock(ser);
free(buf);
- st = emallocz(255, 1);
qlock(ser);
- if(serialdebug)
+ if(serialdebug){
+ st = emallocz(255, 1);
serdumpst(p, st, 255);
- dsprint(2, st);
- free(st);
+ dsprint(2, "%s", st);
+ free(st);
+ }
/* p gets freed by closedev, the process has a reference */
incref(ser->dev);
proccreate(statusreader, p, 8*1024);
@@ -528,31 +529,26 @@ static int
plreadstatus(Serialport *p)
{
int nr, dfd;
- char err[40];
+ char err[ERRMAX];
uchar buf[VendorReqSz];
Serial *ser;
ser = p->s;
qlock(ser);
- dsprint(2, "serial: reading from interrupt\n");
dfd = p->epintr->dfd;
-
qunlock(ser);
nr = read(dfd, buf, sizeof buf);
qlock(ser);
- snprint(err, sizeof err, "%r");
- dsprint(2, "serial: interrupt read %d %r\n", nr);
-
+ rerrstr(err, sizeof err);
if(nr < 0 && strstr(err, "timed out") == nil){
- dsprint(2, "serial: need to recover, status read %d %r\n", nr);
if(serialrecover(ser, nil, nil, err) < 0){
qunlock(ser);
return -1;
}
}
if(nr < 0)
- dsprint(2, "serial: reading status: %r");
+ dsprint(2, "serial: reading status: %r\n");
else if(nr >= sizeof buf - 1){
p->dcd = buf[8] & DcdStatus;
p->dsr = buf[8] & DsrStatus;
@@ -567,7 +563,6 @@ plreadstatus(Serialport *p)
p->novererr++;
} else
dsprint(2, "serial: bad status read %d\n", nr);
- dsprint(2, "serial: finished read from interrupt %d\n", nr);
qunlock(ser);
return 0;
}