[Intel-gfx] [igt-dev] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values

Matthew Auld matthew.william.auld at gmail.com
Tue Mar 30 10:49:56 UTC 2021


On Thu, 18 Mar 2021 at 16:24, Tvrtko Ursulin
<tvrtko.ursulin at linux.intel.com> wrote:
>
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>
> Add __igt_params_get for simple reading of modparams.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
>  lib/igt_params.c | 26 ++++++++++++++++++++++++++
>  lib/igt_params.h |  2 ++
>  2 files changed, 28 insertions(+)
>
> diff --git a/lib/igt_params.c b/lib/igt_params.c
> index c06416988baa..1dc6de77b2e0 100644
> --- a/lib/igt_params.c
> +++ b/lib/igt_params.c
> @@ -156,6 +156,32 @@ int igt_params_open(int device)
>         return params;
>  }
>
> +/**
> + * __igt_params_get:
> + * @device: fd of the device
> + * @parameter: the name of the parameter to set

to get

> + *
> + * This reads the value of the modparam.
> + *
> + * Returns:
> + * A nul-terminated string, must be freed by caller after use, or NULL
> + * on failure.
> + */
> +char *__igt_params_get(int device, const char *parameter)
> +{
> +       char *str;
> +       int dir;
> +
> +       dir = igt_params_open(device);
> +       if (dir < 0)
> +               return NULL;
> +
> +       str = igt_sysfs_get(dir, parameter);
> +       close(dir);
> +
> +       return str;
> +}

Reviewed-by: Matthew Auld <matthew.auld at intel.com>


More information about the Intel-gfx mailing list