All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH igt] lib/debug: Convert igt_drop_caches_set() to use common file writers
@ 2017-12-14 19:57 Chris Wilson
  2017-12-14 20:15 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2017-12-14 19:57 UTC (permalink / raw)
  To: intel-gfx

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>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-15 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 19:57 [PATCH igt] lib/debug: Convert igt_drop_caches_set() to use common file writers Chris Wilson
2017-12-14 20:15 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-12-14 21:09 ` ✗ Fi.CI.IGT: warning " Patchwork
2017-12-15 10:31 ` [PATCH igt] " Joonas Lahtinen
2017-12-15 10:33   ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.