Commit 8e3fe6a3 authored by Michał Winiarski's avatar Michał Winiarski

lib/igt_sysfs: Remove idx from sysfs_open

Similar to sysfs_path - more explicit more better.
Signed-off-by: Michał Winiarski's avatarMichał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 023d7b42
......@@ -76,7 +76,7 @@ static void eat_error_state(int dev)
{
int dir;
dir = igt_sysfs_open(dev, NULL);
dir = igt_sysfs_open(dev);
if (dir < 0)
return;
......
......@@ -52,6 +52,7 @@
#include "igt_aux.h"
#include "intel_chipset.h"
#include "igt_debugfs.h"
#include "igt_device.h"
#include "igt_sysfs.h"
#include "sw_sync.h"
......@@ -806,10 +807,14 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
break;
}
dir = igt_sysfs_open(drm_fd, &idx);
dir = igt_sysfs_open(drm_fd);
if (dir < 0)
return false;
idx = igt_device_get_card_index(drm_fd);
if (idx < 0 || idx > 63)
return false;
if (asprintf(&path, "card%d-%s-%d/status",
idx,
kmstest_connector_type_str(connector->connector_type),
......
......@@ -135,7 +135,6 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
/**
* igt_sysfs_open:
* @device: fd of the device
* @idx: optional pointer to store the card index of the opened device
*
* This opens the sysfs directory corresponding to device for use
* with igt_sysfs_set() and igt_sysfs_get().
......@@ -143,16 +142,13 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
* Returns:
* The directory fd, or -1 on failure.
*/
int igt_sysfs_open(int device, int *idx)
int igt_sysfs_open(int device)
{
char path[80];
if (!igt_sysfs_path(device, path, sizeof(path)))
return -1;
if (idx)
*idx = igt_device_get_card_index(device);
return open(path, O_RDONLY);
}
......@@ -199,7 +195,7 @@ int igt_sysfs_open_parameters(int device)
{
int dir, params = -1;
dir = igt_sysfs_open(device, &params);
dir = igt_sysfs_open(device);
if (dir >= 0) {
params = openat(dir,
"device/driver/module/parameters",
......
......@@ -29,7 +29,7 @@
#include <stdarg.h>
char *igt_sysfs_path(int device, char *path, int pathlen);
int igt_sysfs_open(int device, int *idx);
int igt_sysfs_open(int device);
int igt_sysfs_open_parameters(int device);
bool igt_sysfs_set_parameter(int device,
const char *parameter,
......
......@@ -315,7 +315,7 @@ int main(int argc, char **argv)
fd = drm_open_driver(DRIVER_INTEL);
igt_require_gem(fd);
sysfs = igt_sysfs_open(fd, NULL);
sysfs = igt_sysfs_open(fd);
igt_require(sysfs >= 0);
min = igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz");
......
......@@ -547,7 +547,7 @@ igt_main
igt_require(has_capture(fd));
igt_allow_hang(fd, 0, HANG_ALLOW_CAPTURE);
dir = igt_sysfs_open(fd, NULL);
dir = igt_sysfs_open(fd);
igt_require(igt_sysfs_set(dir, "error", "Begone!"));
igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
}
......
......@@ -262,14 +262,12 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
int idx;
device = drm_open_driver(DRIVER_INTEL);
igt_require_gem(device);
hang = igt_allow_hang(device, 0, HANG_ALLOW_CAPTURE);
sysfs = igt_sysfs_open(device, &idx);
sysfs = igt_sysfs_open(device);
igt_assert(sysfs != -1);
igt_require(has_error_state(sysfs));
......
......@@ -208,7 +208,7 @@ igt_main
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
sysfs = igt_sysfs_open(fd, NULL);
sysfs = igt_sysfs_open(fd);
igt_require(has_rc6_residency("rc6"));
......
......@@ -4092,7 +4092,7 @@ igt_main
igt_require_gem(drm_fd);
devid = intel_get_drm_devid(drm_fd);
sysfs = igt_sysfs_open(drm_fd, NULL);
sysfs = igt_sysfs_open(drm_fd);
igt_require(init_sys_info());
......
......@@ -1275,7 +1275,7 @@ test_frequency(int gem_fd)
igt_spin_t *spin;
int fd, sysfs;
sysfs = igt_sysfs_open(gem_fd, NULL);
sysfs = igt_sysfs_open(gem_fd);
igt_require(sysfs >= 0);
min_freq = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
......
......@@ -262,7 +262,7 @@ static void test_dmabuf_fence_before(int fd)
static void test_sysfs_read(int fd)
{
int dir = igt_sysfs_open(fd, NULL);
int dir = igt_sysfs_open(fd);
DIR *dirp = fdopendir(dir);
struct dirent *de;
......
......@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
assert(intel_register_access_init(intel_get_pci_device(), 0, device) == 0);
dir = igt_sysfs_open(device, NULL);
dir = igt_sysfs_open(device);
for_each_slice(i) {
fd[i] = openat(dir, path[i], O_RDWR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment