[igt-dev] [PATCH i-g-t v3 1/1] lib/igt_device_scan: clear igt_devs.devs_scanned in igt_devices_free
Riana Tauro
riana.tauro at intel.com
Tue Oct 11 05:34:18 UTC 2022
1) igt_devices_scan returns with empty list if devs_scanned
is true and function is called after igt_devices_free
clear igt_devs.devs_scanned in igt_devices_free.
2) remove redudant code from igt_devices_scan and replace it with
igt_devices_free
v2: optimize code in igt_devices_scan (Zbigniew)
v3: update commit message (Janusz)
Signed-off-by: Riana Tauro <riana.tauro at intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
lib/igt_device_scan.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..8b70e375 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -1027,9 +1027,11 @@ void igt_devices_free(void)
}
igt_list_for_each_entry_safe(dev, tmp, &igt_devs.all, link) {
+ igt_list_del(&dev->link);
igt_device_free(dev);
free(dev);
}
+ igt_devs.devs_scanned = false;
}
/**
@@ -1043,22 +1045,8 @@ void igt_devices_free(void)
*/
void igt_devices_scan(bool force)
{
- if (force && igt_devs.devs_scanned) {
- struct igt_device *dev, *tmp;
-
- igt_list_for_each_entry_safe(dev, tmp, &igt_devs.filtered,
- link) {
- igt_list_del(&dev->link);
- free(dev);
- }
- igt_list_for_each_entry_safe(dev, tmp, &igt_devs.all, link) {
- igt_list_del(&dev->link);
- igt_device_free(dev);
- free(dev);
- }
-
- igt_devs.devs_scanned = false;
- }
+ if (force && igt_devs.devs_scanned)
+ igt_devices_free();
if (igt_devs.devs_scanned)
return;
--
2.25.1
More information about the igt-dev
mailing list