Patch to convert usb2 to use cdev

Hans Petter Selasky hselasky at c2i.net
Sun Nov 9 08:46:04 PST 2008


On Sunday 09 November 2008, Rink Springer wrote:
> Hi Hans,
>
> On Sun, Nov 09, 2008 at 05:00:05PM +0100, Hans Petter Selasky wrote:
> > It is not the same endpoint, but multiple different endpoints on the same
> > device through the same file handle. Instead of one endpoint per file,
> > you have one file handle for each set of endpoints you need for your USB
> > userland driver, like LibUSB. Then there is only one file-handle to poll.
> > Actually there are two modes in UGEN now. Maybe you were not aware. Let
> > me quickly explain:
> >
> > 1) Simple read/write mode that works with cat & dd.
> >
> > 2) Special USB FS mode which exposes the full USB features to userland.
> > This mode does not use read/write, but rather copyin, copyout and a set
> > of software USB descriptors.
>
> Hmm, I think I see what you mean. Basically, you just
> open("/dev/ugenX.Y") and you can use the USB_FS_xxx ioctl's to have
> fine-grained control. However, if you open("/dev/ugen.X.Y.Z"), you'd
> talk with endpoint Z on USB device X.Y..  this is actually quite cool,
> guess I should have studied usb2_generic.c more :-)

That's correct.

>
> I think it makes sense to say that if /dev/ugenX.Y is opened, you
> shouldn't be able to open /dev/ugenX.Y.Z, right? However, what happends
> if /dev/ugenX.Y.Z is opened? I'd think that opening /dev/ugenX.Y would
> be fine, but any ioctl() dealing with the corresponding endpoint Z
> should be denied.

I would say it be allowed to open the endpoint both ways at the same time. It 
can make debugging easier.

But there can be two different processes opening /dev/ugenX.Y at the same 
time, accessing different endpoints!

--HPS


More information about the freebsd-usb mailing list