From 602003c3d751c72fc309a0e64d4193f6da720f6b Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Mon, 11 Nov 2019 10:30:54 +0200 Subject: lib/igt_list: Update, clean-up and document igt_list Our list was something between Wayland and Linux Kernel list implementations, right in the uncanny valley. On top of that it falsely claimed that it's a straight copy from the Wayland project. Let's make our impl more akin to the kernel one to ease the cognitive dissonance for the developers working on all those projects. This patch: * mimics the current kernel list interface * separates IGT helpers in the source files * adds brief explanation and code example for igt-doc * introduces igt_list.c as static inlines are not visible in the docs v2: mimic the kernel instead of wayland (Chris) - _head suffix for the sentinel/link struct - _entry_ in iterator names that go over the elements v3: I forgot to merge this in time and there was another call site that had to be converted in gem_spin_batch.c Cc: Petri Latvala Cc: Chris Wilson Signed-off-by: Arkadiusz Hiler Acked-by: Chris Wilson Reviewed-by: Petri Latvala --- lib/igt_chamelium.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/igt_chamelium.c') diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index 1b03a103..9971f51d 100644 --- a/lib/igt_chamelium.c +++ b/lib/igt_chamelium.c @@ -87,7 +87,7 @@ struct chamelium_edid { struct edid *base; struct edid *raw[CHAMELIUM_MAX_PORTS]; int ids[CHAMELIUM_MAX_PORTS]; - struct igt_list link; + struct igt_list_head link; }; struct chamelium_port { @@ -122,7 +122,7 @@ struct chamelium { int drm_fd; - struct igt_list edids; + struct igt_list_head edids; struct chamelium_port ports[CHAMELIUM_MAX_PORTS]; int port_count; }; @@ -2336,7 +2336,7 @@ struct chamelium *chamelium_init(int drm_fd) memset(chamelium, 0, sizeof(*chamelium)); chamelium->drm_fd = drm_fd; - igt_list_init(&chamelium->edids); + IGT_INIT_LIST_HEAD(&chamelium->edids); /* Setup the libxmlrpc context */ xmlrpc_env_init(&chamelium->env); @@ -2388,7 +2388,7 @@ void chamelium_deinit(struct chamelium *chamelium) chamelium_plug(chamelium, &chamelium->ports[i]); /* Destroy any EDIDs we created to make sure we don't leak them */ - igt_list_for_each_safe(pos, tmp, &chamelium->edids, link) { + igt_list_for_each_entry_safe(pos, tmp, &chamelium->edids, link) { for (i = 0; i < CHAMELIUM_MAX_PORTS; i++) { if (pos->ids[i]) chamelium_destroy_edid(chamelium, pos->ids[i]); -- cgit v1.2.3