Commit 5bf30a96 authored by Maarten Lankhorst's avatar Maarten Lankhorst

lib/psr: Do not use out of bound enum for psr_set.

Using an undefined int not in the enum is undefined. Use -1 and change
mode to an integer.

Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: José Roberto de Souza's avatarJosé Roberto de Souza <jose.souza@intel.com>
parent 4049adf0
...@@ -100,13 +100,13 @@ static void restore_psr_debugfs(int sig) ...@@ -100,13 +100,13 @@ static void restore_psr_debugfs(int sig)
psr_write(psr_restore_debugfs_fd, "0"); psr_write(psr_restore_debugfs_fd, "0");
} }
static bool psr_set(int debugfs_fd, enum psr_mode mode) static bool psr_set(int debugfs_fd, int mode)
{ {
int ret; int ret;
ret = has_psr_debugfs(debugfs_fd); ret = has_psr_debugfs(debugfs_fd);
if (ret == -ENODEV) { if (ret == -ENODEV) {
igt_skip("PSR not available\n"); igt_skip_on_f(mode >= PSR_MODE_1, "PSR not available\n");
return false; return false;
} }
...@@ -117,7 +117,7 @@ static bool psr_set(int debugfs_fd, enum psr_mode mode) ...@@ -117,7 +117,7 @@ static bool psr_set(int debugfs_fd, enum psr_mode mode)
* version enabled and the PSR version of the test, it will * version enabled and the PSR version of the test, it will
* fail in the first psr_wait_entry() of the test. * fail in the first psr_wait_entry() of the test.
*/ */
ret = psr_modparam_set(mode <= PSR_MODE_2); ret = psr_modparam_set(mode >= PSR_MODE_1);
} else { } else {
const char *debug_val; const char *debug_val;
...@@ -155,7 +155,7 @@ bool psr_enable(int debugfs_fd, enum psr_mode mode) ...@@ -155,7 +155,7 @@ bool psr_enable(int debugfs_fd, enum psr_mode mode)
bool psr_disable(int debugfs_fd) bool psr_disable(int debugfs_fd)
{ {
/* Any mode different than PSR_MODE_1/2 will disable PSR */ /* Any mode different than PSR_MODE_1/2 will disable PSR */
return psr_set(debugfs_fd, PSR_MODE_2 + 1); return psr_set(debugfs_fd, -1);
} }
bool psr_sink_support(int debugfs_fd, enum psr_mode mode) bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
......
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