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

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Sep 29 08:55:23 UTC 2022


On Thu, Sep 29, 2022 at 10:20:58AM +0530, 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>

Looks good for me:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

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