diff options
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/Makefile | 1 | ||||
-rw-r--r-- | drivers/core/device.c | 36 | ||||
-rw-r--r-- | drivers/core/lists.c | 9 | ||||
-rw-r--r-- | drivers/core/simple-bus.c | 33 | ||||
-rw-r--r-- | drivers/core/uclass.c | 4 |
5 files changed, 70 insertions, 13 deletions
diff --git a/drivers/core/Makefile b/drivers/core/Makefile index c7905b1..151c239 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -5,3 +5,4 @@ # obj-y := device.o lists.o root.o uclass.o util.o +obj-$(CONFIG_OF_CONTROL) += simple-bus.o diff --git a/drivers/core/device.c b/drivers/core/device.c index 32e80e8..49faa29 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -232,7 +232,7 @@ static void device_free(struct udevice *dev) } } -int device_probe(struct udevice *dev) +int device_probe_child(struct udevice *dev, void *parent_priv) { struct driver *drv; int size = 0; @@ -282,6 +282,8 @@ int device_probe(struct udevice *dev) ret = -ENOMEM; goto fail; } + if (parent_priv) + memcpy(dev->parent_priv, parent_priv, size); } ret = device_probe(dev->parent); @@ -335,6 +337,11 @@ fail: return ret; } +int device_probe(struct udevice *dev) +{ + return device_probe_child(dev, NULL); +} + int device_remove(struct udevice *dev) { struct driver *drv; @@ -514,3 +521,30 @@ int device_get_child_by_of_offset(struct udevice *parent, int seq, ret = device_find_child_by_of_offset(parent, seq, &dev); return device_get_device_tail(dev, ret, devp); } + +int device_find_first_child(struct udevice *parent, struct udevice **devp) +{ + if (list_empty(&parent->child_head)) { + *devp = NULL; + } else { + *devp = list_first_entry(&parent->child_head, struct udevice, + sibling_node); + } + + return 0; +} + +int device_find_next_child(struct udevice **devp) +{ + struct udevice *dev = *devp; + struct udevice *parent = dev->parent; + + if (list_is_last(&dev->sibling_node, &parent->child_head)) { + *devp = NULL; + } else { + *devp = list_entry(dev->sibling_node.next, struct udevice, + sibling_node); + } + + return 0; +} diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 699f94b..3a1ea85 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -24,19 +24,12 @@ struct driver *lists_driver_lookup_name(const char *name) ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver); struct driver *entry; - int len; if (!drv || !n_ents) return NULL; - len = strlen(name); - for (entry = drv; entry != drv + n_ents; entry++) { - if (strncmp(name, entry->name, len)) - continue; - - /* Full match */ - if (len == strlen(entry->name)) + if (!strcmp(name, entry->name)) return entry; } diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c new file mode 100644 index 0000000..3ea4d82 --- /dev/null +++ b/drivers/core/simple-bus.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include <dm/root.h> + +DECLARE_GLOBAL_DATA_PTR; + +static int simple_bus_post_bind(struct udevice *dev) +{ + return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); +} + +UCLASS_DRIVER(simple_bus) = { + .id = UCLASS_SIMPLE_BUS, + .name = "simple_bus", + .post_bind = simple_bus_post_bind, +}; + +static const struct udevice_id generic_simple_bus_ids[] = { + { .compatible = "simple-bus" }, + { } +}; + +U_BOOT_DRIVER(simple_bus_drv) = { + .name = "generic_simple_bus", + .id = UCLASS_SIMPLE_BUS, + .of_match = generic_simple_bus_ids, +}; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 61ca17e..901b06e 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -60,10 +60,6 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) id); return -ENOENT; } - if (uc_drv->ops) { - dm_warn("No ops for uclass id %d\n", id); - return -EINVAL; - } uc = calloc(1, sizeof(*uc)); if (!uc) return -ENOMEM; |