From patchwork Mon Aug 28 12:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13371888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3EFDC83F37 for ; Thu, 31 Aug 2023 21:34:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56D1F10E6EE; Thu, 31 Aug 2023 21:34:27 +0000 (UTC) X-Greylist: delayed 912 seconds by postgrey-1.36 at gabe; Mon, 28 Aug 2023 12:51:11 UTC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by gabe.freedesktop.org (Postfix) with ESMTPS id 493D510E2CA; Mon, 28 Aug 2023 12:51:11 +0000 (UTC) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RZ91p2SjjzLp3f; Mon, 28 Aug 2023 20:32:46 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 28 Aug 2023 20:35:56 +0800 From: Jinjie Ruan To: , , , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Date: Mon, 28 Aug 2023 20:35:41 +0800 Message-ID: <20230828123541.361463-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-Mailman-Approved-At: Thu, 31 Aug 2023 21:33:53 +0000 Subject: [Intel-gfx] [PATCH -next] drm/i915/gvt: Use list_for_each_entry() helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ruanjinjie@huawei.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Convert list_for_each() to list_for_each_entry() so that the pos list_head pointer and list_entry() call are no longer needed, which can reduce a few lines of code. No functional changed. Signed-off-by: Jinjie Ruan --- drivers/gpu/drm/i915/gvt/dmabuf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c index 6834f9fe40cf..f136ce140a2b 100644 --- a/drivers/gpu/drm/i915/gvt/dmabuf.c +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c @@ -340,13 +340,11 @@ static struct intel_vgpu_dmabuf_obj * pick_dmabuf_by_info(struct intel_vgpu *vgpu, struct intel_vgpu_fb_info *latest_info) { - struct list_head *pos; struct intel_vgpu_fb_info *fb_info; struct intel_vgpu_dmabuf_obj *dmabuf_obj = NULL; struct intel_vgpu_dmabuf_obj *ret = NULL; - list_for_each(pos, &vgpu->dmabuf_obj_list_head) { - dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list); + list_for_each_entry(dmabuf_obj, &vgpu->dmabuf_obj_list_head, list) { if (!dmabuf_obj->info) continue; @@ -369,12 +367,10 @@ pick_dmabuf_by_info(struct intel_vgpu *vgpu, static struct intel_vgpu_dmabuf_obj * pick_dmabuf_by_num(struct intel_vgpu *vgpu, u32 id) { - struct list_head *pos; struct intel_vgpu_dmabuf_obj *dmabuf_obj = NULL; struct intel_vgpu_dmabuf_obj *ret = NULL; - list_for_each(pos, &vgpu->dmabuf_obj_list_head) { - dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list); + list_for_each_entry(dmabuf_obj, &vgpu->dmabuf_obj_list_head, list) { if (dmabuf_obj->dmabuf_id == id) { ret = dmabuf_obj; break;