On Wednesday 09 March 2005 00:59, Greg KH wrote: > On Tue, Mar 08, 2005 at 08:57:06PM -0500, Nick Sillik wrote: > > Do I need to use a spinlock, or should I just impliment a simple up/down > > lock? > > Depends on how long you are going to need to hold it, and what you are > going to be doing while holding the lock. >
It looks like spinlock will be fine - at connect time it has to be taken while adding to the list, at disconnect time it has to be taken while searching list and removing element. Btw, since there can be only one entry for a device in that list you can rearrange code like this: wrap = NULL; spin_lock(&onetouch_list_lock); list_for_each_entry(entry, &onetouch_list, list) { if (entry->onetouch->udev == udev) { wrap = entry; list_del(&wrap->list); break; } } spin_unlock(&onetouch_list_lock); if (wrap) { onetouh = wrap->onetouch; US_DEBUGP("device found: %s. Releasing\n", onetouch->phys); usb_unlink_urb(onetouch->irq); input_unregister_device(&onetouch->dev); usb_free_urb(onetouch->irq); ... Btw, why don't you drop that "wrap" structure and put list_head right into usb_onetouch structure? -- Dmitry ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel