[PATCH i-g-t v9 2/7] lib/drmtest: Introduced drm_open_driver_another

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Fri Feb 16 10:23:58 UTC 2024


Hi Kamil, Dominik,

On Thursday, 15 February 2024 17:10:09 CET Kamil Konieczny wrote:
> From: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> 
> For user convenience, introduce drm_open_driver_another as
> a wrapper for __drm_open_driver_another with successful open
> assert.

Out of several existing variants of *drm_open_driver* functions, those which 
names start with "drm_", wrapped around their counterparts which names start 
with double underscores, used to set up an exit handler that performs 
necessary cleanups before exit, freeing users from taking care of that.  Don't 
we want to keep that convention also for drm_open_driver_another() and set up 
the exit handler from inside that wrapper on success?

Thanks,
Janusz

> 
> v2: rebased (Kamil)
> v6: reword description (Janusz)
> 
> Cc: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
> Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> ---
>  lib/drmtest.c | 19 +++++++++++++++++++
>  lib/drmtest.h |  1 +
>  2 files changed, 20 insertions(+)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 52b5a2020..73d9159af 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -563,6 +563,25 @@ int __drm_open_driver_another(int idx, int chipset)
>  	return fd;
>  }
>  
> +/*
> + * drm_open_driver_another
> + * @idx: index of the device you are opening
> + * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> + *
> + * A wrapper for __drm_open_driver with successful open assert.
> + *
> + * Returns:
> + * An open DRM fd
> + */
> +int drm_open_driver_another(int idx, int chipset)
> +{
> +	int fd = __drm_open_driver_another(idx, chipset);
> +
> +	igt_assert_fd(fd);
> +
> +	return fd;
> +}
> +
>  /**
>   * __drm_open_driver:
>   * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 6bc819734..856208c48 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -101,6 +101,7 @@ void __set_forced_driver(const char *name);
>  
>  int __drm_open_device(const char *name, unsigned int chipset);
>  void drm_load_module(unsigned int chipset);
> +int drm_open_driver_another(int idx, int chipset);
>  int drm_open_driver(int chipset);
>  int drm_open_driver_master(int chipset);
>  int drm_open_driver_render(int chipset);
> 






More information about the igt-dev mailing list