diff options
| author | Jani Nikula <jani.nikula@intel.com> | 2020-05-07 22:09:41 +0300 |
|---|---|---|
| committer | Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> | 2020-05-08 15:21:50 +0300 |
| commit | 840981d169d2ea73d16e1efeff7dabe351f71392 (patch) | |
| tree | 6e32454159960ff4a86848fcd016cce194d6c506 /lib | |
| parent | 347e0f5e6fa34d77c1135532ccc11c20753336b7 (diff) | |
lib/params: add igt_params_open() which will return path
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/igt_params.c | 29 |
1 files 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,12 +131,29 @@ 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 * @parameter: the name of the parameter to set |
