From patchwork Sat Oct 14 20:09:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harsha sharma X-Patchwork-Id: 10007195 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 74CE260596 for ; Sun, 15 Oct 2017 16:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 534DF205A8 for ; Sun, 15 Oct 2017 16:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41363205F6; Sun, 15 Oct 2017 16:42:25 +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 70E79205A4 for ; Sun, 15 Oct 2017 16:42:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EC2B6E30E; Sun, 15 Oct 2017 16:12:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5663E6E12C for ; Sat, 14 Oct 2017 20:12:23 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id n14so12885866pfh.8 for ; Sat, 14 Oct 2017 13:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Uno1BOV23/nMtZm4n9mCujAfeQFz3uRT7fPyh8vbQuE=; b=k6W879Yl0mzhlbI/3+sogK/rYNOwqy1wh73w6+3Fi7En544YLrb1YB2v3Ky69s+I9o MzU2dc+98jSYzdSNC4FmaIx0In+wuY/1xSlsQurty3dkJkTvRt64Dtg22pd4d0knC8bh 59QyJX9/OCR745GR2ffo9ft1ugOtFghYM8pJfBPq8wu4TPhc1ANh70fVoQ6oWP4k3Vik u1iBR1Px9PGbTLTwFhAKRPYBNvMJQAllCeW7a5h7pue9y5A746n0H5Es24BZolvutO+B lUO+ILMu4YPt4ByjhFuQz6Kso2SYz8RGUoNkN+0B8Ki1/E+5aij/3MizP/gMVAa1MfBE CbMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Uno1BOV23/nMtZm4n9mCujAfeQFz3uRT7fPyh8vbQuE=; b=rws/GDDDyPDshYFERHxKz5VkxnKBqbULVv3Yry6D2/9PtUh1WMXwdVYO6Hk32M+ePP XSDqnQu6K3YyeluAOzp3dChhDdBYOmZ1OaiVHdFabLPRz0yCgvH8xURjaKWhvKH1kzhs YSY9aAf3AlmtRDeUz3hyMp8n+9wfr1tkm/Nrz3KIBBwujVwtbv3j6hHaNEStIrGOA11H UTKteyW69iU1tDcrqEU2iUm8MjOK7xIG/OgpwWn5SXPrvQ1uLJUxGaLQ7SgCyymZ+ZNE pVZtLgRiqVY8qp5f4pbuDC4nvNFbVYVKOmr38Mx9aLNWi/63YMqxAbVdKSFjUKDhZDI9 rbrQ== X-Gm-Message-State: AMCzsaU3NoeRSTzvyYeqFXWlg5D4GDafg+4YxHbyZmwUtNr6J9ICPILo 1CXR37hw5+gSKk+impVq2o6QMA0g X-Google-Smtp-Source: AOwi7QDahNpieVRWr+lsBB3I2kP9X9/EEKIUpVD7MhirgFXwvDp/nBF9mta5RMC2mwtVmlQ8kLbgLA== X-Received: by 10.101.65.197 with SMTP id b5mr4378513pgq.91.1508011942657; Sat, 14 Oct 2017 13:12:22 -0700 (PDT) Received: from localhost.localdomain ([103.37.201.27]) by smtp.gmail.com with ESMTPSA id i72sm8328838pfi.137.2017.10.14.13.12.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Oct 2017 13:12:22 -0700 (PDT) From: Harsha Sharma To: tomi.valkeinen@ti.com, airlied@linux.ie Subject: [PATCH] drm/omap: Replace list_for_each with list_for_each_entry Date: Sun, 15 Oct 2017 01:39:42 +0530 Message-Id: <20171014200942.27388-1-harshasharmaiitr@gmail.com> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Sun, 15 Oct 2017 16:12:36 +0000 Cc: outreachy-kernel@googlegroups.com, Harsha Sharma , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace use of list_for_each with list_for_each_entry to simplify the code and remove variables that are used only in list_for_each. Done with following coccinelle patch: @r@ identifier fn,i,f,p; expression e; iterator name list_for_each, list_for_each_entry; type T; @@ fn(...) { ++ T *i; <+... - list_for_each(p,e) + list_for_each_entry(i,e,f) { ... - T *i = list_entry(p,T,f); ... } ...+> } @@ identifier r.fn,r.p; @@ fn(...) { ... - struct list_head *p; ... when != p } @@ identifier r.fn,r.i,r.f; expression r.e; statement S; @@ fn(...) { <... list_for_each_entry(i,e,f) - { S - } ...> } @s@ identifier i,f,p; expression e; type T; @@ - list_for_each(p,e) + list_for_each_entry(i,e,f) { ... when != T *i; - i = list_entry(p,T,f); ... } @@ identifier s.p; @@ - struct list_head *p; ... when != p @@ identifier s.i,s.f; expression s.e; statement S; @@ list_for_each_entry(i,e,f) - { S - } Signed-off-by: Harsha Sharma --- drivers/gpu/drm/omapdrm/dss/display.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 42279933790e..e6f86026dd93 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -43,6 +43,7 @@ static int disp_num_counter; int omapdss_register_display(struct omap_dss_device *dssdev) { + struct omp_dss_device *ldev; struct omap_dss_driver *drv = dssdev->driver; struct list_head *cur; int id; @@ -67,13 +68,9 @@ int omapdss_register_display(struct omap_dss_device *dssdev) drv->get_timings = omapdss_default_get_timings; mutex_lock(&panel_list_mutex); - list_for_each(cur, &panel_list) { - struct omap_dss_device *ldev = list_entry(cur, - struct omap_dss_device, - panel_list); + list_for_each_entry(ldev, &panel_list, panel_list) if (strcmp(ldev->alias, dssdev->alias) > 0) break; - } list_add_tail(&dssdev->panel_list, cur); mutex_unlock(&panel_list_mutex); return 0; @@ -94,12 +91,11 @@ bool omapdss_component_is_display(struct device_node *node) bool found = false; mutex_lock(&panel_list_mutex); - list_for_each_entry(dssdev, &panel_list, panel_list) { + list_for_each_entry(dssdev, &panel_list, panel_list) if (dssdev->dev->of_node == node) { found = true; goto out; } - } out: mutex_unlock(&panel_list_mutex); return found; @@ -152,8 +148,7 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from) omap_dss_put_device(from); - list_for_each(l, &panel_list) { - dssdev = list_entry(l, struct omap_dss_device, panel_list); + list_for_each_entry(dssdev, &panel_list, panel_list) if (dssdev == from) { if (list_is_last(l, &panel_list)) { dssdev = NULL; @@ -165,7 +160,6 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from) omap_dss_get_device(dssdev); goto out; } - } WARN(1, "'from' dssdev not found\n");