summaryrefslogtreecommitdiff
path: root/include/cyclic.h
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2022-10-28 13:50:53 +0200
committerStefan Roese <sr@denx.de>2022-11-02 08:41:55 +0100
commit28968394839bec37dacf6ffc2ae880e38756e917 (patch)
tree8dfb3538a21379a017537937e071c8beb7284b2d /include/cyclic.h
parent2399b628f4c1c92bbe9033273b450b1e514f802e (diff)
cyclic: switch to using hlist instead of list
A hlist is headed by just a single pointer, so can only be traversed forwards, and insertions can only happen at the head (or before/after an existing list member). But each list node still consists of two pointers, so arbitrary elements can still be removed in O(1). This is precisely what we need for the cyclic_list - we never need to traverse it backwards, and the order the callbacks appear in the list should really not matter. One advantage, and the main reason for doing this switch, is that an empty list is represented by a NULL head pointer, so unlike a list_head, it does not need separate C code to initialize - a memset(,0,) of the containing structure is sufficient. This is mostly mechanical: - The iterators are updated with an h prefix, and the type of the temporary variable changed to struct hlist_node*. - Adding/removing is now just hlist_add_head (and not tail) and hlist_del(). - struct members and function return values updated. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de> Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
Diffstat (limited to 'include/cyclic.h')
-rw-r--r--include/cyclic.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/cyclic.h b/include/cyclic.h
index 263b74d89b..4a11f9b105 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -20,7 +20,7 @@
* @cyclic_list: Cylic list node
*/
struct cyclic_drv {
- struct list_head cyclic_list;
+ struct hlist_head cyclic_list;
};
/**
@@ -46,7 +46,7 @@ struct cyclic_info {
uint64_t cpu_time_us;
uint64_t run_cnt;
uint64_t next_call;
- struct list_head list;
+ struct hlist_node list;
bool already_warned;
};
@@ -95,7 +95,7 @@ int cyclic_uninit(void);
*
* @return: pointer to cyclic_list
*/
-struct list_head *cyclic_get_list(void);
+struct hlist_head *cyclic_get_list(void);
/**
* cyclic_run() - Interate over all registered cyclic functions