summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-09-09 16:28:59 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-14 11:47:42 +0200
commit420815465ee3e09c853d9491e546666d4a867e9c (patch)
tree020954f37e9aa52a26bb6c0ada76f13f0b0d6b68 /drivers
parent08a7d5a6251ba433c9443ad9e439af96ee4eed40 (diff)
downloadbarebox-420815465ee3e09c853d9491e546666d4a867e9c.tar.gz
barebox-420815465ee3e09c853d9491e546666d4a867e9c.tar.xz
driver: Add platform_device_id mechanism
It is common for drivers to handle multiple similar devices. On Linux the driver can distinguish between the devices using the platform_device_id mechanism. Introduce the same for barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/platform.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e0dd9ea58e..82d2521a2e 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -24,7 +24,22 @@
static int platform_match(struct device_d *dev, struct driver_d *drv)
{
- return strcmp(dev->name, drv->name) ? -1 : 0;
+ if (!strcmp(dev->name, drv->name))
+ return 0;
+
+ if (drv->id_table) {
+ struct platform_device_id *id = drv->id_table;
+
+ while (id->name) {
+ if (!strcmp(id->name, dev->name)) {
+ dev->id_entry = id;
+ return 0;
+ }
+ id++;
+ }
+ }
+
+ return -1;
}
static int platform_probe(struct device_d *dev)