On Mon, Aug 29, 2011 at 10:51:04 -0700, Greg KH wrote: > On Mon, Aug 29, 2011 at 11:02:48AM +0200, Manohar Vanga wrote: > > This patch adds functions that allow for reference counting > > bridge modules. The patch introduces the functions > > 'vme_bridge_get()' and 'vme_bridge_put()'. > > > > The functions are automatically called during .probe and .remove > > for drivers. > > > > This patch is based on the changes introduced by Emilio G. Cota > > in the patch: > > > > https://lkml.org/lkml/2010/10/25/492 > > Generally do not try to couple a module reference count with a device > count, you are locking code, not data, and we really don't want to lock > code anymore now that we properly handle device reference counts. (snip) > > diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h > > index 8959670..ef751a4 100644 > > --- a/drivers/staging/vme/vme_bridge.h > > +++ b/drivers/staging/vme/vme_bridge.h > > @@ -113,6 +113,7 @@ struct vme_bridge { > > struct device *parent; /* Parent device (eg. pdev->dev for PCI) */ > > void *driver_priv; /* Private pointer for the bridge driver */ > > struct list_head bus_list; /* list of VME buses */ > > + struct module *owner; /* module that owns the bridge */ > > Why? When you register the device for this bridge, you should properly > handle the module reference counting in the vme core for any open sysfs > files. > > Other than that, you shouldn't care about the module reference at all, > right? > > What am I missing here? What is this solving? > > confused, AFAIK currently a vme bridge driver can be freely removed with rmmod even if it has devices under it. The patch avoids this by increasing the refcount of the bridge module every time a device is registered under it. What's the appropriate thing to do when rmmod tries to remove a bridge module? Shall we remove each bridge and all the child devices, or just refuse to remove a bridge when it has child devices? Manohar implements the latter, although incrementing the refcount of the module is admittedly coarse. He said he'd later change this to implement the refcounting on each bridge device (and not module). Hope this helps, thanks for looking at it. Emilio _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel