return -EINVAL;
}
-static void cleanup_device_allocations(comedi_device *dev)
+static void cleanup_device(comedi_device *dev)
{
int i;
comedi_subdevice *s;
kfree(dev->private);
dev->private = NULL;
}
+ dev->driver = 0;
+ dev->board_name = NULL;
+ dev->board_ptr = NULL;
+ dev->iobase = 0;
+ dev->irq = 0;
+ dev->read_subdev = NULL;
+ dev->write_subdev = NULL;
+ dev->open = NULL;
+ dev->close = NULL;
}
int comedi_device_detach(comedi_device *dev)
printk("BUG: dev->driver=NULL in comedi_device_detach()\n");
}
- cleanup_device_allocations(dev);
- dev->driver = 0;
- dev->board_name = NULL;
- dev->board_ptr = NULL;
- dev->iobase = 0;
- dev->irq = 0;
- dev->read_subdev = NULL;
- dev->write_subdev = NULL;
- dev->open = NULL;
- dev->close = NULL;
+ cleanup_device(dev);
return 0;
}
dev->driver=driv;
ret=driv->attach(dev,it);
if(ret<0){
- comedi_device_detach(dev);
+ driv->detach(dev);
+ cleanup_device(dev);
+ module_put(driv->module);
return ret;
}
goto attached;
if(ret < 0)
{
driv->detach(dev);
- cleanup_device_allocations(dev);
+ cleanup_device(dev);
+ module_put(driv->module);
return ret;
}