summaryrefslogtreecommitdiff
path: root/lib/igt_debugfs.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-12-14 19:44:56 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-12-15 11:22:50 +0000
commite337f2bf378494083052288c7e65e7191ce9a921 (patch)
tree2615ece6f084ba40cd2e20ec1e9b51ef51a47cf5 /lib/igt_debugfs.c
parent9dd7e9b6f4c96cc1fd1c930452c7f54c12892b9d (diff)
lib/debug: Convert igt_drop_caches_set() to use common file writers
Why open code a printf/write loop, when we already have a function providing it? Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com
Diffstat (limited to 'lib/igt_debugfs.c')
-rw-r--r--lib/igt_debugfs.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 49b68dfe..1aec079c 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -887,20 +887,12 @@ bool igt_drop_caches_has(int drm_fd, uint64_t val)
*/
void igt_drop_caches_set(int drm_fd, uint64_t val)
{
- int fd;
- char data[19];
- size_t nbytes;
-
- sprintf(data, "0x%" PRIx64, val);
-
- fd = igt_debugfs_open(drm_fd, "i915_gem_drop_caches", O_WRONLY);
+ int dir;
- igt_assert(fd >= 0);
- do {
- nbytes = write(fd, data, strlen(data) + 1);
- } while (nbytes == -1 && (errno == EINTR || errno == EAGAIN));
- igt_assert(nbytes == strlen(data) + 1);
- close(fd);
+ dir = igt_debugfs_dir(drm_fd);
+ igt_assert(igt_sysfs_printf(dir, "i915_gem_drop_caches",
+ "0x%" PRIx64, val) > 0);
+ close(dir);
}
/*