Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp825682pxb; Fri, 22 Apr 2022 12:01:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfB46vRpiyboPIAyGBjjdqNgaEnr9ny5SrSjGhCO9msK9zmu+s6KdqlLyP7WF5ulyoD39z X-Received: by 2002:a05:6870:351:b0:e2:fde1:6ffb with SMTP id n17-20020a056870035100b000e2fde16ffbmr6675512oaf.32.1650654085291; Fri, 22 Apr 2022 12:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650654085; cv=none; d=google.com; s=arc-20160816; b=AMJAY2j7cv2TGYRgHUr1U1ImRFbqPIVOQhF/p9if8+OIN3Iij20/NxnYU57sVNxtl9 HgkkyuCuvqeVb7XGX9A9qIfC8+eyR0Qhk+vREAEcDka6fp1XFbSv0cg2DvXOLAhTgeRu /TQN9Buul8Z0jorC9VbDbDM6mmq0CZYp0Xf3/DW5TsFcjw50Cc9GxFn1/LcmgCVst+6i hurwOJ1QJH0c5k7pjEo4OvTyTp+3gpF7o99b23nZWsNrNOupHKukc3NXC1WzkkkQHShh GNft5hSJP4RPWSyDAf5LkJdVt65VT4b2est5HYnPQHgOxDfQamVJ8L4BfkRJ9PC3mt+f G4hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=N641P0kZgH3xzco/f776cJFCpsaJCbMVK4k6vEfn5F8=; b=sMLk219zy7rZXYgk0ikDRmMjwEvAlhRTkQjHvXvUR66+twwOkPL6OniJb4YxIK9eQZ Fu+lih5yTpVI0noUHukuUrMd3U8ji9vCrpywwdkCIAQ0pJ+gUfsy9xws0huCGG2dAAoQ QqQ5+q0mqhVHcCnU7+hSCQc+WpIvbog+jfu0beQzxf/EAyFV4QZ2nOyrmGUK3rcby1qQ raP35fFiM9FcnyD381wpwYwYvsRJl5fQme5TBz9bdCyWOUK2P3rFnud59JH06kQJrA/e eStGUVTjxxTvuRtK1TmvNU2mAgIil/5SPv/AkhVEx6Ahn+v7axfA09WFcZ3x0CnBLNuu ssMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=NVlgjse8; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h16-20020a056830165000b006054fabb41fsi4838629otr.99.2022.04.22.12.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:01:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=NVlgjse8; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ACF8A101D3F; Fri, 22 Apr 2022 11:23:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387110AbiDUJBR (ORCPT + 99 others); Thu, 21 Apr 2022 05:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387058AbiDUJBC (ORCPT ); Thu, 21 Apr 2022 05:01:02 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C72B21242; Thu, 21 Apr 2022 01:58:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id AF22C210DC; Thu, 21 Apr 2022 08:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1650531491; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N641P0kZgH3xzco/f776cJFCpsaJCbMVK4k6vEfn5F8=; b=NVlgjse87Rw8XYQBCoEAA+sYONIrDlhsvi/MSR/TKmI33n1YUG/81Ns13hb5PIVZ3egGLH rbfaj0Bf3uW2Btp26ywFE8XJ9o6bgxJ2VxCr4PGW6MeBMt2sSFjl8xkfHQSdLwZwuDKZcx iBZbKpwsgVWAkP+tHY2L+DukBdCmlFg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1650531491; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N641P0kZgH3xzco/f776cJFCpsaJCbMVK4k6vEfn5F8=; b=gQfk1+Np2N+mF/QFk/WYFavc/fCk6qaF0OnDPiL/lkafN4qhImEyF2jrEFp8ywlXl3Ziwx 1a5r4X34/pYTrfAQ== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 86F202C141; Thu, 21 Apr 2022 08:58:11 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 08/10] serial: icom: use list_for_each_entry() Date: Thu, 21 Apr 2022 10:58:06 +0200 Message-Id: <20220421085808.24152-9-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220421085808.24152-1-jslaby@suse.cz> References: <20220421085808.24152-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use list_for_each_entry() helper instead of explicit combo of list_for_each() and list_entry(). Note that pos is used as a reference point in list_add_tail() in icom_alloc_adapter(). This functionality remains as with an empty list, cur_adapter_entry->icom_adapter_entry is still the list head. This simplifies the code a bit. Signed-off-by: Jiri Slaby --- drivers/tty/serial/icom.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 85ecc7dfac72..8701856e2a2e 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c @@ -1675,7 +1675,6 @@ static int icom_alloc_adapter(struct icom_adapter int adapter_count = 0; struct icom_adapter *icom_adapter; struct icom_adapter *cur_adapter_entry; - struct list_head *tmp; icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); @@ -1683,10 +1682,8 @@ static int icom_alloc_adapter(struct icom_adapter return -ENOMEM; } - list_for_each(tmp, &icom_adapter_head) { - cur_adapter_entry = - list_entry(tmp, struct icom_adapter, - icom_adapter_entry); + list_for_each_entry(cur_adapter_entry, &icom_adapter_head, + icom_adapter_entry) { if (cur_adapter_entry->index != adapter_count) { break; } @@ -1694,7 +1691,8 @@ static int icom_alloc_adapter(struct icom_adapter } icom_adapter->index = adapter_count; - list_add_tail(&icom_adapter->icom_adapter_entry, tmp); + list_add_tail(&icom_adapter->icom_adapter_entry, + &cur_adapter_entry->icom_adapter_entry); *icom_adapter_ref = icom_adapter; return 0; @@ -1857,11 +1855,9 @@ static int icom_probe(struct pci_dev *dev, static void icom_remove(struct pci_dev *dev) { struct icom_adapter *icom_adapter; - struct list_head *tmp; - list_for_each(tmp, &icom_adapter_head) { - icom_adapter = list_entry(tmp, struct icom_adapter, - icom_adapter_entry); + list_for_each_entry(icom_adapter, &icom_adapter_head, + icom_adapter_entry) { if (icom_adapter->pci_dev == dev) { kref_put(&icom_adapter->kref, icom_kref_release); return; -- 2.36.0