From patchwork Thu Aug 16 23:26:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 178124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 786122C0098 for ; Fri, 17 Aug 2012 09:26:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757403Ab2HPX0X (ORCPT ); Thu, 16 Aug 2012 19:26:23 -0400 Received: from mail-ob0-f202.google.com ([209.85.214.202]:52377 "EHLO mail-ob0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755488Ab2HPX0W (ORCPT ); Thu, 16 Aug 2012 19:26:22 -0400 Received: by obbwc20 with SMTP id wc20so2313314obb.1 for ; Thu, 16 Aug 2012 16:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=epSu7tdakrHT/hx/1fqKYPK5EF90U2ptviVVr3Mem64=; b=E4D4Bm6tx87Au5ESwnw6bWQ8a/euagISKwR/kT2YM1lLRdYX+KFVforcrFRX++tXAB keNdtbDKPDNzYtSoan/QDmMMdIUszdzRoZdU26gFccqxs4HJkjlqTNYtWCE4F/Avo/mp 85I3aCgG2Ekp78DfqTuyvEtXXQ1peoplJ5EBPSa8z6R38nnEOHZMoM19363DzTzmnbuB h8yEOjjX2e4PI/K5e1lWZJpX5xSIvf3RAR+LusxzFYf/Pmz8SqIZmnlKaxPoxPp7p8TB ifLJCyinLxVocVRnUAE3tlVqz2po5EQblbqyRUBK5d43V1x6ykLXrPmUPkP5anU0BFlZ eZBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding:x-gm-message-state; bh=epSu7tdakrHT/hx/1fqKYPK5EF90U2ptviVVr3Mem64=; b=DJO1HvMzMQfzDjb8tmTxG+zcvkREskXuW1iJ4ulgyB17/usuazxqfgisCb49abg4N4 76+dC+PnKNsQbwepzTLWe6BpzuK/hYhv4JNSoOKBzlr0jvitUKXYIE2euTJLB5EZi7kt lzyOSi2pheW1P2BWYkH8oHjII0ICVROv8q96t9WDKJNHNy/bxPbowbd5rMw/LRm1s8JS ZV9vLzEwzwf3yB9KxGXpHAglPYnZUcsX85il4XY1FG/2Jf1Bzeui8kFJV+qFIibPLJwS +jxosqxf1jRo8UG9JUGtbKO8miGELIF5mecimpz/N7CxDIqNd9FwPOsJ7leLhROJ6OMM sXlA== Received: by 10.50.150.134 with SMTP id ui6mr1435005igb.4.1345159581477; Thu, 16 Aug 2012 16:26:21 -0700 (PDT) Received: by 10.50.150.134 with SMTP id ui6mr1435001igb.4.1345159581406; Thu, 16 Aug 2012 16:26:21 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id mb9si942198igc.1.2012.08.16.16.26.21 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 16 Aug 2012 16:26:21 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (bhelgaas.mtv.corp.google.com [172.18.96.155]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 087B6100047 for ; Thu, 16 Aug 2012 16:26:21 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (unknown [IPv6:::1]) by bhelgaas.mtv.corp.google.com (Postfix) with ESMTP id A0FA4180640 for ; Thu, 16 Aug 2012 16:26:20 -0700 (PDT) Subject: [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal To: linux-pci@vger.kernel.org From: Bjorn Helgaas Date: Thu, 16 Aug 2012 17:26:20 -0600 Message-ID: <20120816232620.3662.90438.stgit@bhelgaas.mtv.corp.google.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQne63jOrMrzEXz1hSvloMBFNvxpRhM72NxvwS4pgy5QERHZNVTAbt2gG1OS7tTG+bz6UCcoL5umMiOHDtdKeJaXi0tcwKqQGpetfE2S5cPPLCg71nQkfQHLS7MFs+UC3j+TtpC7LmeP02lK34ndDOeH4LZngKzxakcYYvOJzy/w/T9mDgEAaa9NjqTmD87qwryu6Cj+M4bfli4MzNNZQrQyGrSeGtOJYinEAfevwlkaW7CGJTU= 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 | 28 ++++++++++++++-------------- drivers/pci/search.c | 4 +--- 2 files changed, 15 insertions(+), 17 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 04a4861..d867056 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -111,22 +111,24 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) __pci_remove_bus_device(dev); } -static void __pci_remove_behind_bridge(struct pci_dev *dev) +static void __pci_remove_behind_bridge(struct pci_dev *bridge) { - struct list_head *l, *n; + struct pci_bus *bus = bridge->subordinate; + struct pci_dev *dev, *tmp; - if (dev->subordinate) - list_for_each_safe(l, n, &dev->subordinate->devices) - __pci_remove_bus_device(pci_dev_b(l)); + if (bus) + list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) + __pci_remove_bus_device(dev); } -static void pci_stop_behind_bridge(struct pci_dev *dev) +static void pci_stop_behind_bridge(struct pci_dev *bridge) { - struct list_head *l, *n; + struct pci_bus *bus = bridge->subordinate; + struct pci_dev *dev, *tmp; - if (dev->subordinate) - list_for_each_safe(l, n, &dev->subordinate->devices) - pci_stop_bus_device(pci_dev_b(l)); + if (bus) + list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) + pci_stop_bus_device(dev); } /** @@ -146,7 +148,7 @@ void pci_stop_and_remove_behind_bridge(struct pci_dev *dev) 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 @@ -156,10 +158,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..b169390 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -132,14 +132,12 @@ pci_find_next_bus(const struct pci_bus *from) */ 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; }