From patchwork Wed May 23 17:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 10421981 X-Patchwork-Delegate: bhelgaas@google.com 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 4EFDF60327 for ; Wed, 23 May 2018 17:48:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9201D2889C for ; Wed, 23 May 2018 17:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86B2628A28; Wed, 23 May 2018 17:48:30 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E2912889C for ; Wed, 23 May 2018 17:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933703AbeEWRs3 (ORCPT ); Wed, 23 May 2018 13:48:29 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:46059 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933144AbeEWRs1 (ORCPT ); Wed, 23 May 2018 13:48:27 -0400 Received: by mail-pf0-f194.google.com with SMTP id c10-v6so10844996pfi.12 for ; Wed, 23 May 2018 10:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UnIh8cPb7HFejLK0nmWMpXHlxA8hkVX2HrbK3wGO/rA=; b=drC3I7DKpqQ6BUkpiKEtIik7sC2S5r/TWaxW8KUxyBM8cXpyQf4OUy15knCtAdScMj saXza5Rxez4mD8haGfF3cTAyh2jGjz51wTQKzUZg8GDD0A5R7rq4iaHCCDbIUDNBi3gQ ccdut/4iKI1xQX9s4iAlC6brjjcK94/fG+oOO3/jx+UWY/JClKrGc2KbOqyDEmxu6xv7 /zeJ+MwrcQ/0fnJEOCv6LXlLPlQfEHvi//y3rZ/8+IumUnI5iHNSXtEKbUkljxEWeS0n 0ZpQpmSU/d3smj/NxNQ4WI1Yf14eV+0EyNySCBsqsuNwxqO4LK1NaM8EEv+FsapSe/fp QCqA== 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:in-reply-to :references; bh=UnIh8cPb7HFejLK0nmWMpXHlxA8hkVX2HrbK3wGO/rA=; b=nIzvZdK0AnTIDrhulM/t9PIVywnDaXyNkNiNKYNuC2tgt5TJ3bc9MD6e6MYgYhKp7f 4TnoMzxSy3YdE0xvYRaIAz4jvbPgBT2AvyATYavFdkt3YbEGE7t/5IBhYpayY4ai3UMt 0izM4K2ZsiE3VnC3CTTUUlPBb+x9mjojKPiF9JgouP61Oyj4SMkJyE7v4dlq3wTAfvju ZSRzAxOfIGn5x5zWTVa085CaTjQxzJk6aKDApqSkcGmCELV8+nZWWk6pkZKP3ozIAmbB VEPZSJ7vDqQClsk03NDQDVQ0iPPLcJ+pM8n8TyDMXo02uTKLvk4B2/2DIhio6faJXEbT zaGQ== X-Gm-Message-State: ALKqPwciG8j8FAhWifVlPwaxKsOjMo95CGok9bcMaE2tkrZGp8WXypHV Vax4HvtUW6jc7Qi9TjlV+2yO1Q== X-Google-Smtp-Source: AB8JxZrg852/L/3Uo13W1VFe9RXUlzLMdxv3QyHKAVXhn8gI47RuAvi1r8CNEQrbBV0kI5PQD14aOg== X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr3829556pfh.256.1527097706861; Wed, 23 May 2018 10:48:26 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id y197-v6sm36409118pfg.184.2018.05.23.10.48.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 10:48:25 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: bhelgaas@google.com, kys@microsoft.com, haiyangz@microsoft.com, lorenzo.pieralisi@arm.com Cc: devel@linuxdriverproject.org, linux-pci@vger.kernel.org, Stephen Hemminger Subject: [PATCH 3/3] PCI: hv: use list_for_each_entry Date: Wed, 23 May 2018 10:11:14 -0700 Message-Id: <20180523171114.5136-4-sthemmin@microsoft.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523171114.5136-1-sthemmin@microsoft.com> References: <20180523171114.5136-1-sthemmin@microsoft.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are several places where list_for_each_entry could be used to simplify the code. Signed-off-by: Stephen Hemminger --- drivers/pci/host/pci-hyperv.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 19eb47f58ccb..afc30dee6001 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1279,7 +1279,6 @@ static u64 get_bar_size(u64 bar_val) */ static void survey_child_resources(struct hv_pcibus_device *hbus) { - struct list_head *iter; struct hv_pci_dev *hpdev; resource_size_t bar_size = 0; unsigned long flags; @@ -1305,8 +1304,7 @@ static void survey_child_resources(struct hv_pcibus_device *hbus) * for a child device are a power of 2 in size and aligned in memory, * so it's sufficient to just add them up without tracking alignment. */ - list_for_each(iter, &hbus->children) { - hpdev = container_of(iter, struct hv_pci_dev, list_entry); + list_for_each_entry(hpdev, &hbus->children, list_entry) { for (i = 0; i < 6; i++) { if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) dev_err(&hbus->hdev->device, @@ -1359,7 +1357,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) resource_size_t low_base = 0; resource_size_t bar_size; struct hv_pci_dev *hpdev; - struct list_head *iter; unsigned long flags; u64 bar_val; u32 command; @@ -1381,9 +1378,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) /* Pick addresses for the BARs. */ do { - list_for_each(iter, &hbus->children) { - hpdev = container_of(iter, struct hv_pci_dev, - list_entry); + list_for_each_entry(hpdev, &hbus->children, list_entry) { for (i = 0; i < 6; i++) { bar_val = hpdev->probed_bar[i]; if (bar_val == 0) @@ -1637,7 +1632,6 @@ static void pci_devices_present_work(struct work_struct *work) { u32 child_no; bool found; - struct list_head *iter; struct pci_function_description *new_desc; struct hv_pci_dev *hpdev; struct hv_pcibus_device *hbus; @@ -1674,10 +1668,8 @@ static void pci_devices_present_work(struct work_struct *work) /* First, mark all existing children as reported missing. */ spin_lock_irqsave(&hbus->device_list_lock, flags); - list_for_each(iter, &hbus->children) { - hpdev = container_of(iter, struct hv_pci_dev, - list_entry); - hpdev->reported_missing = true; + list_for_each_entry(hpdev, &hbus->children, list_entry) { + hpdev->reported_missing = true; } spin_unlock_irqrestore(&hbus->device_list_lock, flags); @@ -1687,11 +1679,8 @@ static void pci_devices_present_work(struct work_struct *work) new_desc = &dr->func[child_no]; spin_lock_irqsave(&hbus->device_list_lock, flags); - list_for_each(iter, &hbus->children) { - hpdev = container_of(iter, struct hv_pci_dev, - list_entry); - if ((hpdev->desc.win_slot.slot == - new_desc->win_slot.slot) && + list_for_each_entry(hpdev, &hbus->children, list_entry) { + if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && (hpdev->desc.v_id == new_desc->v_id) && (hpdev->desc.d_id == new_desc->d_id) && (hpdev->desc.ser == new_desc->ser)) { @@ -1713,9 +1702,7 @@ static void pci_devices_present_work(struct work_struct *work) spin_lock_irqsave(&hbus->device_list_lock, flags); do { found = false; - list_for_each(iter, &hbus->children) { - hpdev = container_of(iter, struct hv_pci_dev, - list_entry); + list_for_each_entry(hpdev, &hbus->children, list_entry) { if (hpdev->reported_missing) { found = true; put_pcichild(hpdev);