lib/drmtest: use igt_require/assert in the prefault helpers

This commit is contained in:
Daniel Vetter 2013-09-03 12:22:09 +02:00
parent e45b7d9474
commit f4b93781be
2 changed files with 8 additions and 18 deletions

View File

@ -1956,7 +1956,7 @@ void kmstest_free_connector_config(struct kmstest_connector_config *config)
} }
#define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable" #define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable"
static int igt_prefault_control(bool enable) static void igt_prefault_control(bool enable)
{ {
const char *name = PREFAULT_DEBUGFS; const char *name = PREFAULT_DEBUGFS;
int fd; int fd;
@ -1965,26 +1965,16 @@ static int igt_prefault_control(bool enable)
int result = 0; int result = 0;
fd = open(name, O_RDWR); fd = open(name, O_RDWR);
if (fd == -1) { igt_require(fd >= 0);
fprintf(stderr, "Couldn't open prefault_debugfs.%s\n",
strerror(errno));
return -1;
}
if (enable) if (enable)
index = 1; index = 1;
else else
index = 0; index = 0;
if (write(fd, &buf[index], 1) != 1) { igt_assert(write(fd, &buf[index], 1) == 1);
fprintf(stderr, "write prefault_debugfs error.%s\n",
strerror(errno));
result = -1;
}
close(fd); close(fd);
return result;
} }
static void enable_prefault_at_exit(int sig) static void enable_prefault_at_exit(int sig)
@ -1992,14 +1982,14 @@ static void enable_prefault_at_exit(int sig)
igt_enable_prefault(); igt_enable_prefault();
} }
int igt_disable_prefault(void) void igt_disable_prefault(void)
{ {
igt_install_exit_handler(enable_prefault_at_exit); igt_install_exit_handler(enable_prefault_at_exit);
return igt_prefault_control(false); igt_prefault_control(false);
} }
int igt_enable_prefault(void) void igt_enable_prefault(void)
{ {
return igt_prefault_control(true); return igt_prefault_control(true);
} }

View File

@ -341,8 +341,8 @@ void igt_disable_exit_handler(void);
int igt_set_vt_graphics_mode(void); int igt_set_vt_graphics_mode(void);
/* prefault disabling, needs the corresponding debugfs interface */ /* prefault disabling, needs the corresponding debugfs interface */
int igt_disable_prefault(void); void igt_disable_prefault(void);
int igt_enable_prefault(void); void igt_enable_prefault(void);
/* suspend and auto-resume system */ /* suspend and auto-resume system */
void igt_system_suspend_autoresume(void); void igt_system_suspend_autoresume(void);