9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] usb serial bug
Date: Thu, 14 Feb 2013 09:33:10 -0500	[thread overview]
Message-ID: <54c0ba490a70bb58de6700d2c4e7bd96@brasstown.quanstro.net> (raw)
In-Reply-To: <b9c4bbdbf64d4c863276a47dd9b14de8@hamnavoe.com>

On Thu Feb 14 05:24:27 EST 2013, 9fans@hamnavoe.com wrote:
> > this is a WORKAROUND.  a proper fix would be something
> > like allowing ORDWR in usbopen if that is indeed the problem.
>
> No, endpoints are unidirectional by design; in the usb spec there are
> no read/write endpoints.  The confusing thing in the spec is that two
> different endpoints can have the same endpoint number - they are
> distinguished by direction.  So what looks like a read/write endpoint
> number 1 is really two separate endpoints, input ep 1 and output ep 1.
> The current Plan 9 usb architecture perpetuates the confusion by
> referring to them both with one name epN.1, but you still have to open
> them both independently.
>
>

in that case, shouldn't these three blocks be reverted?

- erik

/n/dump/2012/1201/sys/src/cmd/usb/serial/serial.c:648,654 - /n/dump/2013/0212/sys/src/cmd/usb/serial/serial.c:647,657
  		fprint(2, "serial: openep %d: %r\n", epin);
  		return -1;
  	}
- 	p->epout = openep(ser->dev, epout);
+ 	if(epout == epin){
+ 		incref(p->epin);
+ 		p->epout = p->epin;
+ 	}else
+ 		p->epout = openep(ser->dev, epout);
  	if(p->epout == nil){
  		fprint(2, "serial: openep %d: %r\n", epout);
  		closedev(p->epin);
/n/dump/2012/1201/sys/src/cmd/usb/serial/serial.c:674,681 - /n/dump/2013/0212/sys/src/cmd/usb/serial/serial.c:677,688

  	if(ser->seteps!= nil)
  		ser->seteps(p);
- 	opendevdata(p->epin, OREAD);
- 	opendevdata(p->epout, OWRITE);
+ 	if(p->epin == p->epout)
+ 		opendevdata(p->epin, ORDWR);
+ 	else{
+ 		opendevdata(p->epin, OREAD);
+ 		opendevdata(p->epout, OWRITE);
+ 	}
  	if(p->epin->dfd < 0 ||p->epout->dfd < 0 ||
  	    (ser->hasepintr && p->epintr->dfd < 0)){
  		fprint(2, "serial: open i/o ep data: %r\n");
/n/dump/2012/1201/sys/src/cmd/usb/serial/serial.c:709,717 - /n/dump/2013/0212/sys/src/cmd/usb/serial/serial.c:716,724
  		    ep->dir == Ein && epintr == -1)
  			epintr = ep->id;
  		if(ep->type == Ebulk){
- 			if(ep->dir == Ein && epin == -1)
+ 			if((ep->dir == Ein || ep->dir == Eboth) && epin == -1)
  				epin = ep->id;
- 			if(ep->dir == Eout && epout == -1)
+ 			if((ep->dir == Ein || ep->dir == Eboth) && epout == -1)
  				epout = ep->id;
  		}
  	}



  reply	other threads:[~2013-02-14 14:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14  3:46 erik quanstrom
2013-02-14 10:23 ` Richard Miller
2013-02-14 14:33   ` erik quanstrom [this message]
2013-02-14 15:21     ` Jeff Sickel
2013-02-14 19:24     ` Richard Miller
2013-02-14 19:54       ` Gorka Guardiola
2013-02-14 20:16         ` Gorka Guardiola
2013-02-14 20:44           ` Richard Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54c0ba490a70bb58de6700d2c4e7bd96@brasstown.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).