/* Increment usage count */
tm6000_devused|=1<<nr;
+ INIT_LIST_HEAD(&dev->tm6000_corelist);
dev->udev= usbdev;
dev->model=id->driver_info;
snprintf(dev->name, 29, "tm6000 #%d", nr);
if (!dev)
return;
- tm6000_i2c_unregister(dev);
-
printk("tm6000: disconnecting %s\n", dev->name);
mutex_lock(&dev->lock);
dev->state |= DEV_DISCONNECTED;
mutex_unlock(&dev->lock);
+ kfree(dev);
}
static struct usb_driver tm6000_usb_driver = {
int tm6000_v4l2_unregister(struct tm6000_core *dev)
{
struct tm6000_core *h;
- struct list_head *list;
+ struct list_head *pos, *tmp;
- while (!list_empty(&tm6000_corelist)) {
- list = tm6000_corelist.next;
- h = list_entry(list, struct tm6000_core, tm6000_corelist);
+ video_unregister_device(&dev->vfd);
+
+ list_for_each_safe(pos, tmp, &tm6000_corelist) {
+ h = list_entry(pos, struct tm6000_core, tm6000_corelist);
if (h == dev) {
- video_unregister_device(&dev->vfd);
list_del(list);
- kfree (h);
}
}