From patchwork Sat Oct 14 20:28:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harsha sharma X-Patchwork-Id: 10007193 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 424EE601E9 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 10D6D205A8 for ; Sun, 15 Oct 2017 16:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DECF6205E9; Sun, 15 Oct 2017 16:42:24 +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 71207205A8 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 6FE526E2FF; Sun, 15 Oct 2017 16:12:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3AC286E12C for ; Sat, 14 Oct 2017 20:30:48 +0000 (UTC) Received: by mail-pf0-x244.google.com with SMTP id b85so12890348pfj.13 for ; Sat, 14 Oct 2017 13:30:48 -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=VEXRu7uXS3NaZqeG6OpXvUPqfRMMxr6Oq+z9J2ZPj8I=; b=TRvIb26zXAoWoXJfq6KFLKHqPSJdpvZ8amx9REUyyg9jZS+1aQuWAIomP1rcyOqfJQ VyOeqR91AFlg7BZgrT0+a4j6LTGcm1fhpOUAxnJfV3WQDmosIKW35zSOQrLbVMWckZz0 sT39bQmMVX0p4EQg+wNTpwd5F4bF9jxTDmShUH1dim/xwYKbNdhIKJ3/YaDPLZIRIRS/ qN3e+ZEK4kckf42gnwhE/X5lF8zMYK9eFqvBDEKU1SOE9lrkn+Wmbyw9/3UYw/UagjP8 3axwyrpeCyPWqTmOhOb8tma1ahKk9AJHZ7bHCSXVWTqnxbQOG5Nrg0PeuMazy5TXq7Gv Zkpg== 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=VEXRu7uXS3NaZqeG6OpXvUPqfRMMxr6Oq+z9J2ZPj8I=; b=NNRz2YygfYmSSTC4pqDYTdiq8u0gnNlSiFRT5f4pcMWy5yFDrASgZSrVHf7WVFjugV bEyScWT+6TH6UQ/U7AXf9BRJg2cj9DwXh5QBNPZrfftcEJA1/gx0WVaoDYP/B9C6uqWP gctfob0PIVmOONWosGwjVMJEAdKIB7KoFkQhp3zJMELiRoArcv21HsmRBSbRV0AEtoz/ W5gy6JB1FCWEq6kUcTlfVqclWuHyTuiI6jn4dud8m5jYYlRw3nf7DLJ08daCz2s4q8nU LtJPTK9vSWoojmBmYpHws5zCKOjTXj4xaDaihDtXHD+CbqK0xdO2pYNQTqvHdgcsh1gm XuqQ== X-Gm-Message-State: AMCzsaVr05ZK7D37BXi5K/1eroLYpNgZu3v7tGHvRZB0x3L+pafvBLE6 QESssi74D8AmWd8IAodQnL0= X-Google-Smtp-Source: AOwi7QBu5vmWCCUZT6vdpYUalc3jj7go4NjlWDqXmIDvVAQZ9AfbJ/x/TKk63Ykw67fqzMm6tqWSGQ== X-Received: by 10.98.56.18 with SMTP id f18mr4597738pfa.81.1508013047711; Sat, 14 Oct 2017 13:30:47 -0700 (PDT) Received: from localhost.localdomain ([103.37.201.27]) by smtp.gmail.com with ESMTPSA id u6sm9532360pgo.9.2017.10.14.13.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Oct 2017 13:30:47 -0700 (PDT) From: Harsha Sharma To: daniel.vetter@ffwll.ch, treding@nvidia.com, airlied@linux.ie Subject: [PATCH] drm/tinydrm: Replace list_for_each with list_for_each_entry Date: Sun, 15 Oct 2017 01:58:23 +0530 Message-Id: <20171014202823.29230-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 Reviewed-by: Sean Paul --- drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c index bd6cce093a85..bf96072d1b97 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c @@ -414,11 +414,9 @@ tinydrm_dbg_spi_print(struct spi_device *spi, struct spi_transfer *tr, void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m) { struct spi_transfer *tmp; - struct list_head *pos; int i = 0; - list_for_each(pos, &m->transfers) { - tmp = list_entry(pos, struct spi_transfer, transfer_list); + list_for_each_entry(tmp, &m->transfers, transfer_list) { if (tmp->tx_buf) tinydrm_dbg_spi_print(spi, tmp, tmp->tx_buf, i, true);