I have a webcam module driver working fairly well, with the exception that if the driver is loaded before the camera is plugged in, the camera frequently does not initialize correctly. It seems to work nearly always if the camera is already plugged in when the driver is loaded; the camera can be unplugged and replugged and continue to work. Until I figure out what is causing the problem, I would like to prevent the driver from loading unless it detects that the camera is plugged in. The routines that check for the camera are in the probe function, but the init function doesn't (apparently) call the probe:
module_init(usb_stv680_init); module_exit(usb_stv680_exit); are at the end of the file, and static struct usb_driver stv680_driver = { name: "stv680", probe: stv680_probe, disconnect: stv680_disconnect, id_table: device_table }; /******************************************************************** * Module routines ********************************************************************/ static int __init usb_stv680_init(void) { #if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS) if (proc_stv680_create() < 0) return -1; #endif if (usb_register(&stv680_driver) < 0) { PDEBUG(0, "STV: Could not setup STV0680 driver"); return -1; } PDEBUG(0, "STV: usb camera driver version %s registering", version); return 0; } are the init and driver table foutines. proc_stv680_create doesn't check to see if the camera is present either: static int proc_stv680_create (void) { if (video_proc_entry == NULL) { PDEBUG(0, "STV: /proc/video/ doesn't exist!"); return -1; } stv680_proc_entry = create_proc_entry("stv680", S_IFDIR, video_proc_entry); if (stv680_proc_entry) { stv680_proc_entry->owner = THIS_MODULE; } else { PDEBUG(0, "STV: Unable to initialize /proc/video/stv680"); return -1; } return 0; } I would like to put in some simple code in the init function, perhaps checking whether the vendor/product numbers are listed, or using the function in probe : static void* __devinit stv680_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) { struct usb_interface_descriptor *interface; struct usb_stv *stv680; char *camera_name=NULL; struct usb_endpoint_descriptor *endpoint; int buffer_size; int i; /* We don't handle multi-config cameras */ if (dev->descriptor.bNumConfigurations != 1) { PDEBUG(1, "STV: Number of Configurations != 1"); return NULL; } interface = &dev->actconfig->interface[ifnum].altsetting[0]; /* Is it a STV680? */ PDEBUG(0, "Checking Vendor/Product ID"); if ((dev->descriptor.idVendor == USB_PENCAM_VENDOR_ID) && (dev->descriptor.idProduct == USB_PENCAM_PRODUCT_ID)) { camera_name="STV0680"; } else { PDEBUG(0, "STV: Vendor/Product ID do not match STV0680 values."); PDEBUG(0, "STV: Check that the STV0680 camera is connected to the computer."); return NULL; } /* We found one */ PDEBUG(1, "STV: STV0680 camera found."); ---- cut ----------- Is there a way to call probe (without knowing the parameters it takes) from the init function? or (as above) check vendor or product ID? If not found, the init routine would do any cleanup necessary and exit. Thanks, Kevin _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel