[PATCH v5 04/12] spi: add ti-ssp spi master driver
Cyril Chemparathy
cyril at ti.com
Wed Nov 17 12:35:37 EST 2010
On 11/17/2010 11:11 AM, Grant Likely wrote:
[...]
> To start, I'm not a fan of matching by name. It's fragile because it
> makes assumptions about how devices will be names when they actually
> appear (ie. Sometimes .id is dynamically assigned). Ideally I'd
> prefer to have direct references (ie. pointers) to the devices that
> need to be registered, which *shouldn't* be difficult to handle. That
> guarantees that the correct device is always referenced. (aside: the
> device-tree use case provides this information by having direct
> 'phandle' references between dependencies.)
The pointer approach is possibly problematic with devices that get
registered by other drivers/masters (mfd, spi, i2c, etc.). With these
devices the board doesn't really have a reference to the device in question.
Something along the following lines may be better:
int device_requires(struct device *dev, const char *res);
int device_provides(struct device *provider, const char *res);
where res is a string of the form "gpio:25", "regulator:vlcd", or even
"dev:<dev_name>".
device_requires() would typically be used by board implementations, and
device_provides() would be called by gpiolib, regulator core, device
core, etc.
I guess this is somewhat along the lines of an earlier discussion on the
PPC list ([1] below), except that the drivers don't get probed until
specified prereqs are available.
Regards
Cyril.
[1] http://www.spinics.net/lists/linux-embedded/msg02764.html
More information about the linux-arm-kernel
mailing list