speedtch Makefile, 1.12, 1.13 cxacru2.c, 1.3, 1.4 usbatm.h, 1.5,
1.6 usbatm2.c, 1.15, 1.16
Roman Kagan
rkagan at mail.ru
Mon Jan 31 15:52:45 EST 2005
Hi Duncan,
On Fri, Jan 28, 2005 at 02:58:20PM +0000, Duncan Sands wrote:
> New registration model, basically Roman's patch plus control over USB probing
> given to the minidrivers. Hopefully Matthieu will like it :) It works like
> this (actually, since I haven't tested it, maybe it doesn't work at all):
>
> minidrivers register a struct usbatm_driver with usbatm, and register a
> struct usb_driver with usb. Most minidrivers should be happy with letting
> usbatm do all the work: they can just use the usbatm probe and disconnect
> methods:
>
> ...
> .probe = usbatm_usb_probe,
> .disconnect = usbatm_usb_disconnect,
> ...
>
> However, if a driver needs extra flexibility it can use its own methods:
>
> ...
> .probe = matthieu_usb_probe,
> .disconnect = matthieu_usb_disconnect
> ...
>
> It is OK to register minidrivers in the probe method, so matthieu_usb_probe
> etc could be:
>
> int matthieu_usb_probe(...) {
> ...query the device, find the best driver to use...
> if ((ret = usbatm_register(best_driver)) < 0)
> return ret;
> if ((ret = usbatm_usb_probe(intf, id)) < 0) {
> usbatm_deregister(best_driver);
> return ret;
> }
> return 0;
> }
Now I'm really confused. I thought the whole purpose of these
usbatm_(de)register was to eliminate the need for the subdrivers to
write their own probe and disconnect adhering to a certain calling
order.
If you decide to make the subdrivers provide their probe methods, why do
you need all this complexity with registration at all?
Instead you can make usbatm_usb_probe take a pointer to the subdriver as
a parameter:
int usbatm_usb_probe (struct usb_interface *intf,
const struct usb_device_id *id,
struct usbatm_driver *driver)
{
...
instance->driver = driver;
...
}
In subdriver's probe you pass your struct usbatm_driver, and that's all
you need. No registration, no locks, no lists, no risk of multiple
subdrivers registering the same usb_device_id (breaking the list stuff
BTW).
Or am I overlooking something?
Cheers,
Roman.
More information about the Usbatm
mailing list