Received: by 10.213.65.68 with SMTP id h4csp444715imn; Tue, 27 Mar 2018 02:16:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELunBcH9YKJNU4qjW+6PCQVK6znUcIDxMmEhdX9BSGLMpFgX4xpOR7I6JXOCcODk6ohS/Rm8 X-Received: by 2002:a17:902:322:: with SMTP id 31-v6mr44452283pld.122.1522142183563; Tue, 27 Mar 2018 02:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522142183; cv=none; d=google.com; s=arc-20160816; b=phxXGuw3cdhKURjN7EyfnNvpLqXGs3rWWQTDgTK0f48ocMKmGTjTRblU7gHrfK9agj 78Alcuk+Ih7FbMBxxAft2CgyVbeu1q/Rn7Qln4Nc5Xcyk8syZArch9t0INetxWHqWTdN Ftpz3Fwd2EDaGMKBOtXLYInLKPNfPxdOZFOSr2memvUvICnG2PmcxqgXsye8kuwLPGdt t1f9No/ivaG2xLH/iCi0pDbJjSm4eauGsKsRZr/XOw9a7h1cfmnfXyh+1Wnd5sPgB9HA 3I8XxVvea5Idqqi7p6G6i2slLGeyy+ARhC/L1lsJSncWQveoW6qM0tMpjzhvwfxnyAIG z+yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=fo5j6+wcAg13jWE8T4OWUV2bENjTphMQ9FelCU+/XPk=; b=svJhd//jUYjHTqlPHryG0JVayVhQrbzYmTa50At9S2HOPVgxt+1AVsQYDuAELEIaUk iYOGUDoXWq6RAHtfbAz/ImaDss6s6Ob6VYK5+bQZ1/SN25AWbMvZhkVbx2DwHGjnE0dl 33xz+0VNaV80iyfxg3j8nAxc1CuTf3+8q0KwpQJR2OMGLOSSJdbGk4ah17QXTk2WuEgZ TMrfKBV8/WF6asbvqB1vkWe+cq1mNc/Odpjha5cWYO79elRpt17ItKQwmJzD9Fn7nrv5 66POi1MFlDMqQ/Xc/ZLv/xlX+vLvqKzRLdcCQzbq6nJpEUDiGswHuVBKDzDeUAGDFzO6 tfaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ruIo1CDS; 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 h3si217389pgf.314.2018.03.27.02.16.07; Tue, 27 Mar 2018 02:16:23 -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=ruIo1CDS; 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 S1751398AbeC0JOI (ORCPT + 99 others); Tue, 27 Mar 2018 05:14:08 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:42099 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750944AbeC0JOG (ORCPT ); Tue, 27 Mar 2018 05:14:06 -0400 Received: by mail-vk0-f65.google.com with SMTP id y127so12828646vky.9 for ; Tue, 27 Mar 2018 02:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fo5j6+wcAg13jWE8T4OWUV2bENjTphMQ9FelCU+/XPk=; b=ruIo1CDSZiAWa2oWRUj7F0mHHbYEg0v3uWwjjw+fRpkCXo/Y/nWLOb6fp4Pt6X4/pW ClV9o6xLCOeDpnp2UEYTEqmG2lT1ThN4iDjxkbUHk56Di+a4Np/5vn37MUdJ8OtxAPk+ 7SUApDR5YnQpA8duhDHCaRtpTeeMEGGLi5KWGgSR9YmRRf+eSRFjQ7pfIQ2P8O1aQ+QY a73U2IuFzCClkcWzhKrR9fz18nmBod4EV5vB2l2e+tAp0Gvpkjcxl3j5nrLorlNH8rFk Pjo+DNCpBW0Of5b0WGMzRMc5NUBSo00Ce+fG+kQyFVnBc/U21oQ/iADXIr3aIbL9ZKCp +Pdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fo5j6+wcAg13jWE8T4OWUV2bENjTphMQ9FelCU+/XPk=; b=eVcHAjlAoS/lANGS5xAwR1J8daZvAROwCwGRaJntGLTY8QWIXl4juvV/kwSYr6atgD AFDYF2TaDFezexEK8x2dj7Mo2AlGEIo28HYiXixT7cca6Co5RkjhuyvNVa+xQC2dDihQ 9LnEw6htzBBwbAmxocKtCgqO08AkTgVCgGkllnh54QfqLClZRfirhKGXrXrherk062FS CSOKKFfOExvhWbSMWwnyOQzIHfrgD28o0NxAAvv/JLwUtVdG8fAw0kf+dZaXs26TDFyA bVcPlgPVD1MZHkjKpHrEcJRglqaNgQDVVqr2Oa2LS90qB1xrVzJJJemflezVj+BrcfnI /Yqg== X-Gm-Message-State: AElRT7GIODXMNpcp7r89CAiozXDt+ZG4Owxv+AoOevtSvM8Tf2P/zxfI SNI6vi5Yg6ZDiUKBKdA+a/qU+c+E9nHyJvSnerk= X-Received: by 10.31.114.201 with SMTP id n192mr6658433vkc.70.1522142045669; Tue, 27 Mar 2018 02:14:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.137.5 with HTTP; Tue, 27 Mar 2018 02:14:05 -0700 (PDT) In-Reply-To: <20180327091156.GA23787@seema-Inspiron-15-3567> References: <20180327091156.GA23787@seema-Inspiron-15-3567> From: Ben Skeggs Date: Tue, 27 Mar 2018 19:14:05 +1000 Message-ID: Subject: Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse To: Arushi Singhal Cc: Ben Skeggs , David Airlie , nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, outreachy-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27 March 2018 at 19:11, Arushi Singhal wrote: > 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. I would prefer to also see "start" renamed to "cstate" with this change. Ben. > > 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 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel