On Sat, 2002-05-04 at 13:57, Munaut Sylvain wrote: > I was looking at the code of ibmcam.c & ultracam.c. And I have a question : > In the probe call back, when the call to AllocateDevice i successful but > the call to RegisterVideoDevice fail, these to modules, just send > a debug print in dmesg and return NULL. Don't they need to call > usbvideo_CameraRelease or another func to free what was allocated by > AllocateDevice ?
usbvideo_Disconnect() gets called by the USB stack when you pull the
cord out of the USB connector. It takes care of the allocated device.
This callback is set by usbvideo_register() and applies to the entire
driver:
if (cams->cb.disconnect == NULL)
cams->cb.disconnect = usbvideo_Disconnect;
Minidriver code usually does not need to reimplement it (but it can).
> I don't fully understant usbvideo yet but it always sound weird to have
> some "Allocate" without some "Free"
This "Free" code is split into two routines: usbvideo_Disconnect() and
usbvideo_CameraRelease(). This is because some work may need to be
deferred until the file handle is closed. But if file was not opened at
the disconnect time, it all happens in one call. See
usbvideo_Disconnect() for details, it's very straightforward.
Thanks,
Dmitri
signature.asc
Description: This is a digitally signed message part
