Oliver Neukum <oliver@xxxxxxxxxx> writes: > Am Dienstag, 24. Januar 2012, 00:52:02 schrieb Bjørn Mork: >> /* --- method tables --- */ >> >> @@ -111,13 +112,45 @@ struct wdm_device { >> struct work_struct rxwork; >> int werr; >> int rerr; >> + >> + struct list_head device_list; >> }; >> >> static struct usb_driver wdm_driver; >> >> +/* return intfdata if we own the interface, else look up intf in the list */ >> static struct wdm_device *wdm_get_device(struct usb_interface *intf) >> { >> - struct wdm_device *desc = usb_get_intfdata(intf); >> + struct wdm_device *desc = NULL; >> + >> + pr_debug("%s: intf->dev.driver=%p, &wdm_driver=%p\n", __func__, to_usb_driver(intf->dev.driver), &wdm_driver); >> + >> + mutex_lock(&wdm_mutex); >> + if (to_usb_driver(intf->dev.driver) == &wdm_driver) >> + desc = usb_get_intfdata(intf); >> + else >> + list_for_each_entry(desc, &wdm_device_list, device_list) >> + if (desc->intf == intf) >> + break; >> + mutex_unlock(&wdm_mutex); >> + >> + return desc; >> +} > > Well, this is conceptually inelegant. If we need to maintain our own list, > we can put every instance on it. We should have as few code paths as > possible. Agreed. The above is a result of coding-as-you-go without actually knowing where you're going... Given that I ended up putting every device on the list, then everthying should use the list lookup. Which makes it possible to drop the usb_set_intfdata() and then also combine even more of the probe/register by moving the now common usb_register_dev part to create. Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html