Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp573364pxb; Tue, 15 Feb 2022 22:31:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCVnaxElpLWLODYEHxBLW5e09rTZOkRmdqA6n2JzSbKlnj88O6otXc8JibIaHKPZLtaO0B X-Received: by 2002:a17:90b:120d:b0:1b8:98f3:53f1 with SMTP id gl13-20020a17090b120d00b001b898f353f1mr129770pjb.36.1644993066109; Tue, 15 Feb 2022 22:31:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644993066; cv=none; d=google.com; s=arc-20160816; b=W1/5Srd6nmBmut5pknG0MxVN1e1bY3woP/33TfGUx24HdNnNWT876urEd5tdDgyikk TCOlVzyQAiwixv+bw2b4W3dqxX39FbSBpB4zyRS8AyFLSy5RITFT7c5BXun+c8LMk/Ld yTsxjNt/SbUmo8eKrz4tkZoFvo4DSeQ3GvRGAmbsm8SkU4xWib8kVqM4a15TuEKr6gwp lAeESa+9ZnmOSn9vq2rwd996p4uxJ/NqMYJnEB9eys8NRTlu2wZtqv+wQC8Y++yiyPg+ rsnRbSJxOoB3s0hV269JF34yYD7tWu8pdS9rmkfKki7DOivyk4JsgcLXxRMvlxfzUKED Yefw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=KIvcyrQ3Ns0tQzb1LD3dVCKgjzdZpqJR2rFWnovwl/E=; b=QCOUjhArpAHFPYZK8oz4mgs2tRyeuiP0z28LMO6JhtulagdUws0dZKlubTvueTMN9j 6ICvMGOmLG1kq4VVSdhE8c3xejqi0L1O1yI5JRNp68tRRKwPpks24NMRfMu1nQyf/dAL 8v3PczNvobNq2uSfHeG90PXpkXkGEiwYBnN9IomFGeOFmZh6NgtE2ubYGfhrS/BEjqHj toyb3R7ota9QfqS+6gEKUzQ6tZvqKWV1aZRg7qNH1qutUTCageF5yLM/XQpb6TtJ8jvf I421jYGsdFXJCORbT1PO0NsjcMnT7vWC0gqmtjH64vYfISh2syHCypWPP4ltTlWGLQEM ygKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RGEXUDXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c16si3862176pgw.564.2022.02.15.22.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:31:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RGEXUDXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BDBD1CFA39; Tue, 15 Feb 2022 22:25:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242360AbiBORPT (ORCPT + 99 others); Tue, 15 Feb 2022 12:15:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242361AbiBORPP (ORCPT ); Tue, 15 Feb 2022 12:15:15 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D554111ADDB for ; Tue, 15 Feb 2022 09:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644945305; x=1676481305; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=wYSE1d1KywOXWozIw3qtjar4Hm4wpZeg71RZfiDgbYU=; b=RGEXUDXgJueONHOG7YvUo6EonpSK2JgzL1X+32cq+3/scplEzUKwmQ3u 6M9Hs0vpTohM/qm5Wo8ROKt50OXUwsFj02N2UzPf5q6smxK/A679Cjx1m 74Q8S0Vw8SJFdYmL+QU5fdTCW/peX6NkL4WHjZohIcl5bIeWnoDbCz0Ik OH1MN+s14ioa6MdvIluR4w/etZxf56IsuUIO5z/D9272B117wWGPt3nKe 8m+Vd6ZMRZFfTRI+85nU9H+WYHE2/8w6FoA15FppNm+psw8fQAsaf7q0S tTUCMVTuE6Iiqb8kWf5wUNgrFbiSoLOcZnIvkikJMLX4R/j+ng7ii/ora w==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="250141893" X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="250141893" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 09:14:56 -0800 X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="544392412" Received: from ylian16-mobl1.ccr.corp.intel.com (HELO localhost) ([10.252.20.230]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 09:14:52 -0800 From: Jani Nikula To: Andy Shevchenko , Andy Shevchenko , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Thomas Zimmermann , Geert Uytterhoeven Subject: Re: [PATCH v1 1/1] drm/i915/selftests: Replace too verbose for-loop with simpler while In-Reply-To: <20220215163213.54917-1-andriy.shevchenko@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220215163213.54917-1-andriy.shevchenko@linux.intel.com> Date: Tue, 15 Feb 2022 19:14:49 +0200 Message-ID: <87o83859x2.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Feb 2022, Andy Shevchenko wrote: > It's hard to parse for-loop which has some magic calculations inside. > Much cleaner to use while-loop directly. I assume you're trying to prove a point following our recent for-vs-while loop discussion. I really can't think of any other reason you'd end up looking at this file or this loop. With the change, the loop indeed becomes simpler, but it also runs one iteration further than the original. Whoops. It's a selftest. The loop's been there for five years. What are we trying to achieve here? So we disagree on loops, fine. Perhaps this is not the best use of either of our time? Please just let the for loops in i915 be. BR, Jani. > > Signed-off-by: Andy Shevchenko > --- > 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, " "); -- Jani Nikula, Intel Open Source Graphics Center