new USB driver

Hans Petter Selasky hselasky at c2i.net
Tue Nov 9 08:41:33 PST 2004


On Mon, Nov 08, 2004 at 12:46:56PM -0800, Julian Elischer wrote:
> 
> 
> Hans Petter Selasky wrote:
> 
> >
> >There are some more differences, but that will be details. My new USB driver 
> >is built upon the FreeBSD-5-current USB driver, but it is not fully compatible 
> >with it.
> >
> >So is it a candidate for a new /sys/ directory?
> >
> 
> I would hope not..
> 
> If these are generally useful changes then maybe they might also be 
> useful to NetBSD and OpenBSD.
> If so, then they could be adopted everywhere and we could "migrate" to 
> it in the same place rather than
> get a new directory.
> 
> Have you thought about how your changes would go in 4.x?
>
> I assume it would require some work as you have incorporated the mutex 
> into how you do things..
>

I have thought that maybe usb_port.h could contain a set of defines
mtx_init, mtx_lock and mtx_unlock that call splxxx() and store the value 
returned from splxxx() into struct mtx  { int s; int mtx_recurse; }. So 
porting to 4.x should not be a big problem.

msleep() could be defined { mtx_unlock(); tsleep(); mtx_lock(); },
though there will be a small gap between unlock and sleep where wakeup can be 
called, it will work, if tsleep does not exit the current spl level then.

concerning callouts I suggest that the FreeBSD-5 way is used and that other 
incompatible platforms use something like:

struct callout { void *func; void *arg; };
#define callout_init(args...)
#define callout_reset(h, t, f, d) { (h)->func = (f); (h)->arg = (d); timeout((f), (d), (t)); }
#define callout_stop(h) { if((h)->func) { untimeout((h)->func, (h)->arg); (h)->func = NULL; } }

Yours
--HPS


More information about the freebsd-usb mailing list