[PATCH 3/5] staging: vme: add functions for bridge module refcounting

Manohar Vanga manohar.vanga at cern.ch
Mon Aug 15 10:05:03 UTC 2011


> If the driver doesn't provide a .probe, we would still increment
> the refcount of the bridge module. Is that reasonable? I dunno.
> 
> If there's no .probe then the device is doing something
> weird, and probably either it doesn't have much to do with a
> particular bridge (i.e. it manages no "real" devices) or
> it'd need to manage its own resources (in which case we could
> easily export vme_bridge_get/put.)
> 
> Perhaps then the following would be more appropriate,
> what do you think?
> 
> +	if (driver->probe) {
> +		if (vme_bridge_get(bridge->num))
> +			return -ENXIO; /* although this could change, see above comment */
> +
>  		retval = driver->probe(dev, bridge->num, vme_calc_slot(dev));
> +		if (retval)
> +			vme_bridge_put(bridge);
> +	}
> +
>  	return retval;
> 
> .. and then remember to do
> + 	if (probe)
> + 		vme_bridge_put(bridge)
> in vme_bus_remove(), which in your patch is unconditional (correctly
> matching the unconditional get() in vme_bus_probe)

I picked this default behaviour from the PCI driver code (drivers/pci/pci-driver.c):

	static int pci_device_probe(struct device * dev)
	{
		...
		pci_dev_get(pci_dev);
		error = __pci_device_probe(drv, pci_dev);
		if (error)
			pci_dev_put(pci_dev);
	
		return error;
	}

The __pci_device_probe() function checks if probe is present or not.

> I'm certainly no checkpatch taliban, but guess you probably
> didn't want to send this line change.

Gak! Will cleanup and resend.

--
/manohar



More information about the devel mailing list