diff options
author | Simon Glass <sjg@chromium.org> | 2015-11-08 23:47:52 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-11-19 20:27:51 -0700 |
commit | 7aeac5bc8c5903b8d27188a21b39f0b2c4bd13c1 (patch) | |
tree | d2bc124ba0ef8028c5e183e8112b317b30621f43 /include/dm/uclass.h | |
parent | 45bfa47e123cdb0df8e273e3f0c84907c7394f6a (diff) |
dm: core: Add safe device iteration macros
Add iteration macros which support unbinding a device within the loop.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm/uclass.h')
-rw-r--r-- | include/dm/uclass.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/dm/uclass.h b/include/dm/uclass.h index d214b88734..bfbd27afd6 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -243,4 +243,19 @@ int uclass_resolve_seq(struct udevice *dev); #define uclass_foreach_dev(pos, uc) \ list_for_each_entry(pos, &uc->dev_head, uclass_node) +/** + * uclass_foreach_dev_safe() - Helper function to safely iteration through devs + * + * This creates a for() loop which works through the available devices in + * a uclass in order from start to end. Inside the loop, it is safe to remove + * @pos if required. + * + * @pos: struct udevice * to hold the current device. Set to NULL when there + * are no more devices. + * @next: struct udevice * to hold the next next + * @uc: uclass to scan + */ +#define uclass_foreach_dev_safe(pos, next, uc) \ + list_for_each_entry_safe(pos, next, &uc->dev_head, uclass_node) + #endif |