[PATCH igt] lib/debug: Convert igt_drop_caches_set() to use common file writers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux