summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-12-30 07:19:27 +0300
committerSimon Glass <sjg@chromium.org>2020-01-08 02:02:39 +0300
commitaf68411dd1e9ef69ada074963333a5a5b8e278a4 (patch)
tree8f7541d0684c7e549f37435bcad477e8d7166ec6 /drivers/core
parent8d6320cc4d5cd01e2e7fd01dd635e360cf0a1699 (diff)
downloadu-boot-af68411dd1e9ef69ada074963333a5a5b8e278a4.tar.xz
dm: devres: Use an enum for the allocation phase
At present we only support two phases where devres can be used: bind and probe. This is handled with a boolean. We want to add a new phase (platdata), so change this to an enum. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/devres.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 36a8b1eb5f..5376118f12 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -17,12 +17,21 @@
#include <dm/root.h>
#include <dm/util.h>
+/** enum devres_phase - Shows where resource was allocated
+ *
+ * DEVRES_PHASE_BIND: In the bind() method
+ * DEVRES_PHASE_PROBE: In the probe() method
+ */
+enum devres_phase {
+ DEVRES_PHASE_BIND,
+ DEVRES_PHASE_PROBE,
+};
+
/**
* struct devres - Bookkeeping info for managed device resource
* @entry: List to associate this structure with a device
* @release: Callback invoked when this resource is released
- * @probe: Flag to show when this resource was allocated
- (true = probe, false = bind)
+ * @probe: Show where this resource was allocated
* @name: Name of release function
* @size: Size of resource data
* @data: Resource data
@@ -30,7 +39,7 @@
struct devres {
struct list_head entry;
dr_release_t release;
- bool probe;
+ enum devres_phase phase;
#ifdef CONFIG_DEBUG_DEVRES
const char *name;
size_t size;
@@ -93,7 +102,8 @@ void devres_add(struct udevice *dev, void *res)
devres_log(dev, dr, "ADD");
assert_noisy(list_empty(&dr->entry));
- dr->probe = dev->flags & DM_FLAG_BOUND ? true : false;
+ dr->phase = dev->flags & DM_FLAG_BOUND ? DEVRES_PHASE_PROBE :
+ DEVRES_PHASE_BIND;
list_add_tail(&dr->entry, &dev->devres_head);
}
@@ -179,7 +189,7 @@ static void release_nodes(struct udevice *dev, struct list_head *head,
struct devres *dr, *tmp;
list_for_each_entry_safe_reverse(dr, tmp, head, entry) {
- if (probe_only && !dr->probe)
+ if (probe_only && dr->phase != DEVRES_PHASE_PROBE)
break;
devres_log(dev, dr, "REL");
dr->release(dev, dr->data);
@@ -209,7 +219,7 @@ static void dump_resources(struct udevice *dev, int depth)
list_for_each_entry(dr, &dev->devres_head, entry)
printf(" %p (%lu byte) %s %s\n", dr,
(unsigned long)dr->size, dr->name,
- dr->probe ? "PROBE" : "BIND");
+ dr->phase == DEVRES_PHASE_PROBE ? "PROBE" : "BIND");
list_for_each_entry(child, &dev->child_head, sibling_node)
dump_resources(child, depth + 1);