Why open code a printf/write loop, when we already have a function
providing it?

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahti...@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to