linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] drm/i915/selftests: Replace too verbose for-loop with simpler while
@ 2022-02-15 16:32 Andy Shevchenko
  2022-02-15 17:14 ` Jani Nikula
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-02-15 16:32 UTC (permalink / raw)
  To: Andy Shevchenko, intel-gfx, dri-devel, linux-kernel
  Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Daniel Vetter, Thomas Zimmermann,
	Geert Uytterhoeven

It's hard to parse for-loop which has some magic calculations inside.
Much cleaner to use while-loop directly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_syncmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_syncmap.c b/drivers/gpu/drm/i915/selftests/i915_syncmap.c
index 47f4ae18a1ef..26981d1c3025 100644
--- a/drivers/gpu/drm/i915/selftests/i915_syncmap.c
+++ b/drivers/gpu/drm/i915/selftests/i915_syncmap.c
@@ -36,10 +36,10 @@ __sync_print(struct i915_syncmap *p,
 	unsigned int i, X;
 
 	if (depth) {
-		unsigned int d;
+		unsigned int d = depth;
 
-		for (d = 0; d < depth - 1; d++) {
-			if (last & BIT(depth - d - 1))
+		while (d--) {
+			if (last & BIT(d))
 				len = scnprintf(buf, *sz, "|   ");
 			else
 				len = scnprintf(buf, *sz, "    ");
-- 
2.34.1


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

end of thread, other threads:[~2022-02-16  9:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-15 16:32 [PATCH v1 1/1] drm/i915/selftests: Replace too verbose for-loop with simpler while Andy Shevchenko
2022-02-15 17:14 ` Jani Nikula
2022-02-15 18:58   ` Andy Shevchenko
2022-02-16  8:55     ` Jani Nikula
2022-02-16  9:02       ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).