From patchwork Tue Feb 15 01:43:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 557481 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1F1ic5J017915 for ; Tue, 15 Feb 2011 01:44:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754066Ab1BOBnm (ORCPT ); Mon, 14 Feb 2011 20:43:42 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:57360 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752557Ab1BOBnk (ORCPT ); Mon, 14 Feb 2011 20:43:40 -0500 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e35.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p1F1THik017297; Mon, 14 Feb 2011 18:29:17 -0700 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p1F1hark086158; Mon, 14 Feb 2011 18:43:36 -0700 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p1F1hZBW027203; Mon, 14 Feb 2011 18:43:36 -0700 Received: from us.ibm.com (ram-laptop.beaverton.ibm.com [9.47.25.174]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p1F1hYXu027170; Mon, 14 Feb 2011 18:43:34 -0700 Received: by us.ibm.com (sSMTP sendmail emulation); Mon, 14 Feb 2011 17:43:33 -0800 From: Ram Pai To: linux-pci@vger.kernel.org, jbarnes@virtuousgeek.org Cc: Ram Pai , linux-kernel@vger.kernel.org, clemens@ladisch.de, Yinghai Lu , Linus Torvalds , Bjorn Helgaas Subject: [PATCH 2/4] PCI: data structure agnostic free list function Date: Mon, 14 Feb 2011 17:43:18 -0800 Message-Id: <1297734200-23327-3-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1297734200-23327-1-git-send-email-linuxram@us.ibm.com> References: <1297734200-23327-1-git-send-email-linuxram@us.ibm.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 15 Feb 2011 01:44:39 +0000 (UTC) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 2121215..bcf5752 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -36,6 +36,16 @@ struct resource_list_x { unsigned long flags; }; +#define free_list(type, head) do { \ + struct type *list, *tmp; \ + for (list = (head)->next; list;) { \ + tmp = list; \ + list = list->next; \ + kfree(tmp); \ + } \ + (head)->next = NULL; \ +} while (0) + static void add_to_failed_list(struct resource_list_x *head, struct pci_dev *dev, struct resource *res) { @@ -58,19 +68,6 @@ static void add_to_failed_list(struct resource_list_x *head, list->next = tmp; } -static void free_failed_list(struct resource_list_x *head) -{ - struct resource_list_x *list, *tmp; - - for (list = head->next; list;) { - tmp = list; - list = list->next; - kfree(tmp); - } - - head->next = NULL; -} - static void __dev_sort_resources(struct pci_dev *dev, struct resource_list *head) { @@ -900,7 +897,7 @@ again: if (tried_times >= 2) { /* still fail, don't need to try more */ - free_failed_list(&head); + free_list(resource_list_x, &head); goto enable_all; } @@ -931,7 +928,7 @@ again: list = list->next; } - free_failed_list(&head); + free_list(resource_list_x, &head); goto again;