*
* This should only be allowed when there are no remaining users -
* i.e. it is not necessary to go through and clear all the hooks, as
- * they should have already been removed. This is enforced through a
- * usage count and BUG_ON(use!=0), but should be made more user-friendly
+ * they should have already been removed. This is enforced by taking
+ * a module reference to the plugin while the interfaces are in use
*/
void netback_disconnect_accelerator(int id, const char *eth_name)
{
*/
spin_lock_irqsave(&accelerators_lock, flags);
list_for_each_entry(accelerator, &accelerators_list, link) {
- if (match_accelerator(dev, be, accelerator)) {
+ if (match_accelerator(dev, be, accelerator) &&
+ try_module_get(accelerator->hooks->owner)) {
be->accelerator = accelerator;
atomic_inc(&be->accelerator->use_count);
be->accelerator->hooks->probe(dev);
struct xenbus_device *dev)
{
/* Notify the accelerator (if any) of this device's removal */
- if ( be->accelerator ) {
+ if (be->accelerator) {
be->accelerator->hooks->remove(dev);
atomic_dec(&be->accelerator->use_count);
+ module_put(be->accelerator->hooks->owner);
}
be->accelerator = NULL;
}