[Intel-gfx] [PATCH igt] lib/debug: Convert igt_drop_caches_set() to use common file writers
Chris Wilson
chris at chris-wilson.co.uk
Thu Dec 14 19:57:16 UTC 2017
Why open code a printf/write loop, when we already have a function
providing it?
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
lib/igt_debugfs.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 49b68dfed..1aec079c5 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);
}
/*
--
2.15.1
More information about the Intel-gfx
mailing list