[igt-dev] [PATCH i-g-t 4/7] lib/params: add igt_params_open() which will return path
Jani Nikula
jani.nikula at intel.com
Fri May 8 11:07:20 UTC 2020
On Thu, 07 May 2020, Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com> wrote:
> From: Jani Nikula <jani.nikula at intel.com>
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> Reviewed-by: Petri Latvala <petri.latvala at intel.com>
I no longer have recollection how much of this is mine, and how much is
JP's. In any case, for the parts I've contributed,
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
Feel free to retain or take authorship as you feel just.
BR,
Jani.
> ---
> lib/igt_params.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/lib/igt_params.c b/lib/igt_params.c
> index b5ac1266..fe4b1df3 100644
> --- a/lib/igt_params.c
> +++ b/lib/igt_params.c
> @@ -107,17 +107,7 @@ static void igt_params_save(int dir, const char *path, const char *name)
> module_params = data;
> }
>
> -/**
> - * igt_params_open:
> - * @device: fd of the device
> - *
> - * This opens the module parameters directory (under sysfs) corresponding
> - * to the device for use with igt_sysfs_set() and igt_sysfs_get().
> - *
> - * Returns:
> - * The directory fd, or -1 on failure.
> - */
> -int igt_params_open(int device)
> +static int __igt_params_open(int device, char **outpath)
> {
> int dir, params = -1;
>
> @@ -141,11 +131,28 @@ int igt_params_open(int device)
>
> sprintf(path, "/sys/module/%s/parameters", name);
> params = open(path, O_RDONLY);
> + if (params >= 0 && outpath)
> + *outpath = strdup(path);
> }
>
> return params;
> }
>
> +/**
> + * igt_params_open:
> + * @device: fd of the device
> + *
> + * This opens the module parameters directory (under sysfs) corresponding
> + * to the device for use with igt_sysfs_set() and igt_sysfs_get().
> + *
> + * Returns:
> + * The directory fd, or -1 on failure.
> + */
> +int igt_params_open(int device)
> +{
> + return __igt_params_open(device, NULL);
> +}
> +
> /**
> * igt_params_set:
> * @device: fd of the device
--
Jani Nikula, Intel Open Source Graphics Center
More information about the igt-dev
mailing list