From patchwork Fri Aug 17 23:36:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 1340111 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0959E3FC81 for ; Fri, 17 Aug 2012 23:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756892Ab2HQXgS (ORCPT ); Fri, 17 Aug 2012 19:36:18 -0400 Received: from mail-ee0-f74.google.com ([74.125.83.74]:52986 "EHLO mail-ee0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445Ab2HQXgR (ORCPT ); Fri, 17 Aug 2012 19:36:17 -0400 Received: by mail-ee0-f74.google.com with SMTP id d4so192260eek.1 for ; Fri, 17 Aug 2012 16:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=ZNL0nuILGlBHEJNFkqj0QYlBNMlMeCAJSkVU6MqRkuA=; b=FBG+oX/K5U33eanhEqeSKk85HXI8F8XuE0B2cTmJTKxNdStCamaeQUsgxdyuIbevft S6QOgYKwDbGveg8V6GpeEIUMvt6Q4a8eWAlnl6y14aOVaDNLny+HbQdtXUeljoX5JcUQ rdHCf4E8jylrr9SIinMrYtbuX/odfQxZP87VvQS9C7taxYZJjAmBNT101bKxVB4lpV4r bcIQHOMWiZeiDiZthw2ryDki1jucSD1tBD/xptYiBs6PCp3RUX9V3Ss6eB+olMGG6Gex rZIcx3Dc5zCuS4G4jeD3Au50UZZBoYGs3YhjfZLo1o7ESZG7gIDwTO4peYj7Ocw5CKrB QtVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=ZNL0nuILGlBHEJNFkqj0QYlBNMlMeCAJSkVU6MqRkuA=; b=pMmillK2POGVnuMFvaFCMOEk091IrBG4l1RLFYMOUyu9A0sEhFPR4fzPH6fLhZBgal fLHsLytzbwmnVBOEDNE7IIIH3NtsRIdWbLlQ8qNdKaRP2dAbX0nLqhp5xUeUp/B+P6yO 7qUQVLZ/d3uqr922PSMfmqWp4nco2bPZX+d2/yI4xvcUnbzsT1mM4WNNyyOq2DKcRknc 3ZrzcfDV78d2dOr4l4vX+5o5UVmR8FHxmUR9HQd+9EZpB4WojDVN7gz9ePR//lsyfN9O TUKX369/C8AIJg2P8pIYk4pN1VrUzB13lR0ve8LICMvXwUa+mKXOaJkffCmTV56um4do 5kgg== Received: by 10.180.98.234 with SMTP id el10mr705101wib.3.1345246576761; Fri, 17 Aug 2012 16:36:16 -0700 (PDT) Received: by 10.180.98.234 with SMTP id el10mr705096wib.3.1345246576725; Fri, 17 Aug 2012 16:36:16 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id d5si11753682eep.0.2012.08.17.16.36.16 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 17 Aug 2012 16:36:16 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (bhelgaas.mtv.corp.google.com [172.18.96.155]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 86A085C0050; Fri, 17 Aug 2012 16:36:16 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (unknown [IPv6:::1]) by bhelgaas.mtv.corp.google.com (Postfix) with ESMTP id E75751801BB; Fri, 17 Aug 2012 16:36:15 -0700 (PDT) Subject: [PATCH v2 06/16] PCI: Use list_for_each_entry() for bus->devices traversal To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: linux-pcmcia@lists.infradead.org, Yinghai Lu , Kenji Kaneshige Date: Fri, 17 Aug 2012 17:36:15 -0600 Message-ID: <20120817233615.10973.98099.stgit@bhelgaas.mtv.corp.google.com> In-Reply-To: <20120817233100.10973.59521.stgit@bhelgaas.mtv.corp.google.com> References: <20120817233100.10973.59521.stgit@bhelgaas.mtv.corp.google.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlcsOg+3GyawiX8fxrr/SjA9BabKXI1e5Awtw/X3hpMNHmHLTXj+pVVsQ9+KtRWo2ZkFgsRRXCAV2ThsBhuPmRrYj3J8peVaXIPGtDi4vULfE9ysWjBAQ/oN//PvsU/MuofaNO76zNutcPNhRf74/QaBrjDELPd1wvXVil8V7DX4PIT0sSZwJFcAuyGY6MVQZa/B8bDatKcN5v2HraAR2PGrd1oQA== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Replace list_for_each() + pci_dev_b() with the simpler list_for_each_entry(). Signed-off-by: Bjorn Helgaas --- drivers/pci/remove.c | 13 ++++++------- drivers/pci/search.c | 6 ++---- 2 files changed, 8 insertions(+), 11 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index b18dc2e..f17a027 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -114,16 +114,17 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) static void __pci_remove_behind_bridge(struct pci_dev *dev) { - struct list_head *l, *n; + struct pci_dev *child, *tmp; if (dev->subordinate) - list_for_each_safe(l, n, &dev->subordinate->devices) - __pci_remove_bus_device(pci_dev_b(l)); + list_for_each_entry_safe(child, tmp, + &dev->subordinate->devices, bus_list) + __pci_remove_bus_device(child); } static void pci_stop_bus_devices(struct pci_bus *bus) { - struct list_head *l, *n; + struct pci_dev *dev, *tmp; /* * VFs could be removed by pci_stop_and_remove_bus_device() in the @@ -133,10 +134,8 @@ static void pci_stop_bus_devices(struct pci_bus *bus) * We can iterate the list backwards to get prev valid PF instead * of removed VF. */ - list_for_each_prev_safe(l, n, &bus->devices) { - struct pci_dev *dev = pci_dev_b(l); + list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) pci_stop_bus_device(dev); - } } /** diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 993d4a0..f56b237 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from) * decrement the reference count by calling pci_dev_put(). * If no device is found, %NULL is returned. */ -struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) +struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) { - struct list_head *tmp; struct pci_dev *dev; WARN_ON(in_interrupt()); down_read(&pci_bus_sem); - list_for_each(tmp, &bus->devices) { - dev = pci_dev_b(tmp); + list_for_each_entry(dev, &bus->devices, bus_list) { if (dev->devfn == devfn) goto out; }