Received: by 10.213.65.68 with SMTP id h4csp443504imn; Tue, 27 Mar 2018 02:14:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELte6kWaTZMGStKUIuAt+P8qY+lgQBHPlfeYe3Q67pU/kbiXWz7BmYr60mecWdRE5f59/vdC X-Received: by 2002:a17:902:7295:: with SMTP id d21-v6mr28084660pll.130.1522142075349; Tue, 27 Mar 2018 02:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522142075; cv=none; d=google.com; s=arc-20160816; b=h/NXpT8UHcE1VvUE9pHKIt0ale6bOZqhVNxXaZ/aukArzLaHtf5/Cf5/QOmt6OygeD p0QyoVH5ISzJWIppJaKHxg2/qmxXdhx+Fa1RxC1OnP48dzdB0P24NFQDR4icLkU8dknU +BBsXlaR7rq5LvZj1OJVgAHnuDoB/GwsjFWXomyM3A6yy5Ph/T/knQ07aVQQ8pFIzWAj 1USGXseMbmjmVdDsOUONEXdCJaymh6o90wApzZwwe127RsPhFsDbKqoJ8IrXg5TF5KhM RnSos3HZPNXecfiwaSjZMAe9AWc29pX503FAvpGj8REbJlmJT1p2nl8yrPKHgIA88Ib8 8Mfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=B51rQGyYPVX1wUlufoKzjPSNN+MCDrsu+sbHwRO9DfM=; b=XoJobjHYfrq3RMImm50Ui6O4oNpi1o5ntQnU2UsFu8D/lriqMgTEH3s/UsGPv6JGR6 ifAYM0PtaataAnqrOQtBOaK352XKzcRQ7iS+8uUBBTcHSyGmMiwa2xXKiDAgtvpS+uGz 66cc3Z3fwsyctGQgOhoo6F+GjyFI2UQE9nEFLz7ZjeAZEWVbmeHWyj3dxex77HceSWMw jsnIEKU0RQBkwrhu4AnBquqEb8ESsMdkXwXvjUOYp3Rn1z+lzBoyGLg2U6h2FKXEiWg8 xrz88mdWc7Uh/VQBiLrIPjFKJ1u40ofKGr0NgrEMfQ6VUfUeg4JLS4KwtlqmKDPNQj7E Fpww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eaCgENgH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si588145pgu.357.2018.03.27.02.14.20; Tue, 27 Mar 2018 02:14:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eaCgENgH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbeC0JLy (ORCPT + 99 others); Tue, 27 Mar 2018 05:11:54 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33788 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752342AbeC0JLw (ORCPT ); Tue, 27 Mar 2018 05:11:52 -0400 Received: by mail-pg0-f68.google.com with SMTP id i194so4124968pgd.0 for ; Tue, 27 Mar 2018 02:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=B51rQGyYPVX1wUlufoKzjPSNN+MCDrsu+sbHwRO9DfM=; b=eaCgENgHZj+fsKQe532jUN1zH6qvM4bR+vZjd4iMt2E1nIX5mSRr+FHIR7MJlxfXxA 9YzyIIkYVE+L5OCLuiRpnaVOgDvenjRxDISotGJrSu37Zf34eG+4EOHX3qP2rcbGyjhp 4q9bC6HJJOgXcqRxPQkh3oStaZiOm5XxPccrmol9oHT1fxwBEziyhAei4kY1Qi/FJDJ2 s0bwYazjZPN2Y6oJq6gbH6b2cup68uqv5Wu/nrrBf6OslErZMsQn9Vf8Pn4VJTUIGKZh t7//sqWdcUoGV67DHBiPwZ/XpYx/m6MYNSXALjIDaA3CaXWSgJt1EVSYpvm011GOAVoI KQBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=B51rQGyYPVX1wUlufoKzjPSNN+MCDrsu+sbHwRO9DfM=; b=B8YAXwWT36qW7dlYNvYbzBpsaSKYO/WCr9BMGekoX9HDGoxaNWs2j5vVDuyh2sZe8M rPfNTmjWPdV/+1zJRZjiCULxhRAAUElfDajLhKNFj4tHEdJ+PjU18uu4WmCsmG8czgW7 UPPJpW9EZNs84s3lFnpcNrCOTI3Cfvnihpr5spUScC1XhBGsvgmWG7jOuFnuxl6dpD2K mp4SSqLSfKtJ1+DTE+SuK3JM2jRSLQvScwUrkvO6VFTNHARU5tIoHlOJA8AL5b39x0OH TdHqD/altSxDghh2V3RleagFgK8aiw82T7XAFtAdZUqXTD5n0o+JY8epUrhzEg8Z++FG UBYA== X-Gm-Message-State: AElRT7HPPEDyLnX4JRiCrZwgPTHXEExG6K7x69mTYdd4Y3A1Ze1ET/Tu gXWV2eMsqPrmp6HAaJ1pc909Vw== X-Received: by 10.101.83.199 with SMTP id z7mr31451320pgr.105.1522141911498; Tue, 27 Mar 2018 02:11:51 -0700 (PDT) Received: from seema-Inspiron-15-3567 ([14.139.82.6]) by smtp.gmail.com with ESMTPSA id e8sm2216233pfd.116.2018.03.27.02.11.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Mar 2018 02:11:50 -0700 (PDT) Date: Tue, 27 Mar 2018 14:41:56 +0530 From: Arushi Singhal To: bskeggs@redhat.com Cc: David Airlie , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, outreachy-kernel Subject: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse Message-ID: <20180327091156.GA23787@seema-Inspiron-15-3567> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's better to use "list_for_each_entry_from_reverse" for iterating list than "for loop" as it makes the code more clear to read. This patch replace "for loop" with "list_for_each_entry_from_reverse" and remove "cstate" variable as it is redundant in the code. Signed-off-by: Arushi Singhal --- drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c index 81c3567..5e56f74 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, { struct nvkm_device *device = clk->subdev.device; struct nvkm_volt *volt = device->volt; - struct nvkm_cstate *cstate; int max_volt; if (!pstate || !start) @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, max_volt = min(max_volt, nvkm_volt_map(volt, volt->max2_id, clk->temp)); - for (cstate = start; &cstate->head != &pstate->list; - cstate = list_prev_entry(cstate, head)) { - if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp)) + list_for_each_entry_from_reverse(start, &pstate->list, head) { + if (nvkm_cstate_valid(clk, start, max_volt, clk->temp)) break; } - return cstate; + return start; } static struct nvkm_cstate * -- 2.7.4