[igt-dev] [PATCH i-g-t v2 1/1] lib/igt_device_scan: clear igt_devs.devs_scanned in igt_devices_free

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Thu Sep 29 09:01:56 UTC 2022


On Thursday, 29 September 2022 06:50:58 CEST Riana Tauro wrote:
> 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.
> 
> v2: optimize code in igt_devices_scan (Zbigniew)
> 
> Signed-off-by: Riana Tauro <riana.tauro 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);
> -		}

Why don't we need to clean the igt_devs.filtered list up any longer?

Thanks,
Janusz

> -		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;
> 






More information about the igt-dev mailing list