summaryrefslogtreecommitdiff
path: root/lib/igt_sysfs.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-12-21 16:37:07 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-12-22 18:09:48 +0000
commita3556f495f36e92381f35327cca41d426cfae5a6 (patch)
treef9ceb919aac08bf7a7e5e6b90b8ecfd2f3f44ec4 /lib/igt_sysfs.c
parente6d52317724eaa7314f7d8e53b313f5a5676ecdf (diff)
lib: Kick all fbcon
i915 may not be the only, nor the first, vtcon framebuffer device - we need to check them all! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_sysfs.c')
-rw-r--r--lib/igt_sysfs.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 570329d0..ded10a67 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -406,42 +406,40 @@ bool igt_sysfs_set_boolean(int dir, const char *attr, bool value)
*/
void kick_fbcon(bool enable)
{
- char buf[128];
const char *path = "/sys/class/vtconsole";
DIR *dir;
- struct dirent *vtcon;
+ struct dirent *de;
dir = opendir(path);
if (!dir)
return;
- while ((vtcon = readdir(dir))) {
+ while ((de = readdir(dir))) {
+ char buf[128];
int fd, len;
- if (strncmp(vtcon->d_name, "vtcon", 5))
+ if (strncmp(de->d_name, "vtcon", 5))
continue;
- sprintf(buf, "%s/%s/name", path, vtcon->d_name);
+ sprintf(buf, "%s/%s/name", path, de->d_name);
fd = open(buf, O_RDONLY);
if (fd < 0)
continue;
+ buf[sizeof(buf) - 1] = '\0';
len = read(fd, buf, sizeof(buf) - 1);
close(fd);
if (len >= 0)
buf[len] = '\0';
- if (strstr(buf, "frame buffer device")) {
- sprintf(buf, "%s/%s/bind", path, vtcon->d_name);
- fd = open(buf, O_WRONLY);
- if (fd != -1) {
- if (enable)
- igt_ignore_warn(write(fd, "1\n", 2));
- else
- igt_ignore_warn(write(fd, "0\n", 2));
- close(fd);
- }
- break;
+ if (!strstr(buf, "frame buffer device"))
+ continue;
+
+ sprintf(buf, "%s/%s/bind", path, de->d_name);
+ fd = open(buf, O_WRONLY);
+ if (fd != -1) {
+ igt_ignore_warn(write(fd, enable ? "1\n" : "0\n", 2));
+ close(fd);
}
}
closedir(dir);