[igt-dev] [PATCH i-g-t] lib/chamelium: Check drmModeGetResources()

Souza, Jose jose.souza at intel.com
Mon Oct 15 21:40:19 UTC 2018


On Fri, 2018-10-05 at 09:08 +0100, Chris Wilson wrote:
> If KMS is not available, drmModeGetResoures() reports NULL and so we
> cannot use this device to find the chamelium connector.

Reviewed-by: José Roberto de Souza <jose.souza at intel.com>

> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  lib/igt_chamelium.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index fe5c4dac..3150f609 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -1422,6 +1422,10 @@ static bool
> chamelium_read_port_mappings(struct chamelium *chamelium,
>  	int port_i, i, j;
>  	bool ret = true;
>  
> +	res = drmModeGetResources(drm_fd);
> +	if (!res)
> +		return false;
> +
>  	group_list = g_key_file_get_groups(igt_key_file, NULL);
>  
>  	/* Count how many connector mappings are specified in the
> config */
> @@ -1433,7 +1437,6 @@ static bool chamelium_read_port_mappings(struct
> chamelium *chamelium,
>  	chamelium->ports = calloc(sizeof(struct chamelium_port),
>  				  chamelium->port_count);
>  	port_i = 0;
> -	res = drmModeGetResources(drm_fd);
>  
>  	for (i = 0; group_list[i] != NULL; i++) {
>  		group = group_list[i];
> @@ -1494,8 +1497,8 @@ static bool chamelium_read_port_mappings(struct
> chamelium *chamelium,
>  	}
>  
>  out:
> -	drmModeFreeResources(res);
>  	g_strfreev(group_list);
> +	drmModeFreeResources(res);
>  
>  	return ret;
>  }


More information about the igt-dev mailing list