On Tue, Aug 09, 2011 at 15:26:09 +0100, Martyn Welch wrote:
> On 09/08/11 14:24, Manohar Vanga wrote:
> > If we really don't want explicit module refcounting by drivers, can we
> > perhaps use
> > the return value of the probe to automatically do this? eg. in
> > vme_bus_probe() like
> > below:
> >
> > int ret = 0;
> > ...
> > vme_bridge_get(bridge);
> > if (driver->probe)
> > ret = driver->probe(vdev);
> > if (ret)
> > vme_bridge_put(bridge);
> > return ret;
> >
> > Just a thought. Feel free to shoot it down if you think it's the incorrect
> > approach :P
> >
>
> After looking at the PCI and RapidIO subsystems, I think this is probably the
> correct approach. I guess the only quiestion then is at which point is
> vme_bridge_put() called assuming the probe is successful. I guess at module
> unload time, though I haven't checked in the PCI and RapidIO code.
This works as long as all devices are tied to the driver
loading; i.e. when the devices can only be removed when the
driver is removed. A device might go away while the driver
still manages other devices of the same kin; this is why
particular drivers explicitly manage the get/put in
.probe/.release.
In vme we may one day have hotplug (VME64x supports it IIRC),
but we're not quite there yet. One can remove devices from
sysfs anytime though.
I still think the original patch is the sane way to go.
Emilio
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel