speedtch usbatm.h,1.4,1.5 usbatm2.c,1.13,1.14

Duncan Sands duncan.sands at math.u-psud.fr
Mon Feb 7 12:52:28 EST 2005


Hi Roman,

> It adds .cleanup method to struct usbatm_driver which is supposed to
> release the allocated resources when the last reference to the subdriver
> instance is dropped.  To preserve the lifetime rules which you've
> implemented, I've introduced another kref to struct usbatm_data to
> control the lifetime of the subdriver instance.
> 
> I see the following arguments advocating this approach:
> 
>  1) it isn't any more complex than the synchronous one

but it pushes complexity to the minidriver, since it needs to be race
free, while with the synchronous version race-less behaviour is guaranteed
by usbatm.

>  2) the requirements to the .cleanup method in the async case are
>     obvious from the interface, unlike the obscure requirements to the
>     .heavy_init to be interruptible and quick to exit in the sync case

kernel threads don't vaporise when hit with a signal, unlike user-space
threads.  That means being interruptible is easy to arrange in general:
just do msleep_interruptible instead of msleep...  So I'm not too worried
about that.

>  3) if we ever come to publish some info from the subdrivers in sysfs,
>     the .cleanup will be a must (as the only way to handle the
>     degenerate case of open files in sysfs while removing the device)

Well, we could (and probably should) just return an error when someone tries
to read info for a subdriver that has been disconnected.  But indeed this
kind of thing can be tricky to do right, so maybe in practice your solution
will turn out to be the best.  That won't become clear until we have some
examples, but perhaps you have some in mind already?

Ciao,

Duncan.



More information about the Usbatm mailing list