summaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e0dd9ea58e..8c80e8e26d 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -21,10 +21,31 @@
*/
#include <common.h>
#include <driver.h>
+#include <errno.h>
+#include <init.h>
static int platform_match(struct device_d *dev, struct driver_d *drv)
{
- return strcmp(dev->name, drv->name) ? -1 : 0;
+ if (IS_ENABLED(CONFIG_OFDEVICE) && dev->device_node &&
+ drv->of_compatible)
+ return of_match(dev, drv);
+
+ 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)
@@ -44,15 +65,8 @@ struct bus_type platform_bus = {
.remove = platform_remove,
};
-#if 0
-LIST_HEAD(bus_list);
-EXPORT_SYMBOL(bus_list);
-
-int bus_register(struct bus_type *bus)
+static int plarform_init(void)
{
- list_add_tail(&bus->list, &bus_list);
-
- return 0;
+ return bus_register(&platform_bus);
}
-#endif
-
+pure_initcall(plarform_init);