From patchwork Tue Mar 27 09:11:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arushi X-Patchwork-Id: 10309597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12FB060212 for ; Tue, 27 Mar 2018 09:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED70D2823D for ; Tue, 27 Mar 2018 09:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F8D29C32; Tue, 27 Mar 2018 09:11:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 444452823D for ; Tue, 27 Mar 2018 09:11:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 980EE6E5B5; Tue, 27 Mar 2018 09:11:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 329D389F92; Tue, 27 Mar 2018 09:11:52 +0000 (UTC) Received: by mail-pg0-x243.google.com with SMTP id f10so8168263pgs.9; Tue, 27 Mar 2018 02:11:52 -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=Jb9ukG9bqO1rGZvRUw/0erd+sseC5w7JImJ9IFkrLCUIaH9lhRpl6ldQMsfxlnEOYi uixxM0uDYWc52CR9qp3d1YMCPLcXjVuh2NobrZLBR+JIu3bkQ6Y1XFrpAtTYTylQjFGs SPbZdFLVB/uCIIpApLCi5BVa65tvv23fDwSwLBBqm/WygOqXAcXDHdJgVoA8j1TJn/OG CkjnKtRkRxHEMhh0ghMqL5qWOLOctYcGvwCgBE5Z+V73rgKp2+OtPReJau1PzTZfVXfL uyMiTRtHlG0vmek4KFg01S74Ctm011PPldJsvUhOwBDePo/BSFTEWZg2iYsZIarbb0ml kNZg== X-Gm-Message-State: AElRT7EccvYJQJrzPsGbJEpJ9qmMcesSl2d1dQQlEX5hBsG3aN/S9qSa t1K23zrXvA1yVrN8OGvKGTs= X-Google-Smtp-Source: AG47ELtj5uBGs3V0Cb5Dr3Txkrt3Rb3OEKkppO2RfShEVg2EzbQkVfkBL6LH7NSUMhHXtW0fGWOXhw== 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 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-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, outreachy-kernel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 *