linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Ram Pai <linuxram@us.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 14/21] PCI: Change free_list() to function
Date: Sat, 21 Jan 2012 02:08:30 -0800	[thread overview]
Message-ID: <1327140517-14811-15-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1327140517-14811-1-git-send-email-yinghai@kernel.org>

After merging struct pci_dev_resource_x and pci_dev_resource,
We can use function instead of macro now.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/setup-bus.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index a6e427a..c845d18 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -38,13 +38,15 @@ struct pci_dev_resource {
 	unsigned long flags;
 };
 
-#define free_list(type, head) do {				\
-	struct type *dev_res, *tmp;				\
-	list_for_each_entry_safe(dev_res, tmp, head, list) {	\
-		list_del(&dev_res->list);			\
-		kfree(dev_res);					\
-	}							\
-} while (0)
+static void free_list(struct list_head *head)
+{
+	struct pci_dev_resource *dev_res, *tmp;
+
+	list_for_each_entry_safe(dev_res, tmp, head, list) {
+		list_del(&dev_res->list);
+		kfree(dev_res);
+	}
+}
 
 int pci_realloc_enable = 0;
 #define pci_realloc_enabled() pci_realloc_enable
@@ -329,7 +331,7 @@ static void __assign_resources_sorted(struct list_head *head,
 	/* Save original start, end, flags etc at first */
 	list_for_each_entry(dev_res, head, list) {
 		if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) {
-			free_list(pci_dev_resource, &save_head);
+			free_list(&save_head);
 			goto requested_and_reassign;
 		}
 	}
@@ -347,12 +349,12 @@ static void __assign_resources_sorted(struct list_head *head,
 		/* Remove head list from realloc_head list */
 		list_for_each_entry(dev_res, head, list)
 			remove_from_list(realloc_head, dev_res->res);
-		free_list(pci_dev_resource, &save_head);
-		free_list(pci_dev_resource, head);
+		free_list(&save_head);
+		free_list(head);
 		return;
 	}
 
-	free_list(pci_dev_resource, &local_fail_head);
+	free_list(&local_fail_head);
 	/* Release assigned resource */
 	list_for_each_entry(dev_res, head, list)
 		if (dev_res->res->parent)
@@ -365,7 +367,7 @@ static void __assign_resources_sorted(struct list_head *head,
 		res->end = save_res->end;
 		res->flags = save_res->flags;
 	}
-	free_list(pci_dev_resource, &save_head);
+	free_list(&save_head);
 
 requested_and_reassign:
 	/* Satisfy the must-have resource requests */
@@ -375,7 +377,7 @@ requested_and_reassign:
 		requests */
 	if (realloc_head)
 		reassign_resources_sorted(realloc_head, head);
-	free_list(pci_dev_resource, head);
+	free_list(head);
 }
 
 static void pdev_assign_resources_sorted(struct pci_dev *dev,
@@ -1298,7 +1300,7 @@ again:
 	 */
 	failed_type &= type_mask;
 	if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) {
-		free_list(pci_dev_resource, &fail_head);
+		free_list(&fail_head);
 		goto enable_and_dump;
 	}
 
@@ -1329,7 +1331,7 @@ again:
 		if (fail_res->dev->subordinate)
 			res->flags = 0;
 	}
-	free_list(pci_dev_resource, &fail_head);
+	free_list(&fail_head);
 
 	goto again;
 
@@ -1366,7 +1368,7 @@ again:
 
 	if (tried_times >= 2) {
 		/* still fail, don't need to try more */
-		free_list(pci_dev_resource, &fail_head);
+		free_list(&fail_head);
 		goto enable_all;
 	}
 
@@ -1394,7 +1396,7 @@ again:
 		if (fail_res->dev->subordinate)
 			res->flags = 0;
 	}
-	free_list(pci_dev_resource, &fail_head);
+	free_list(&fail_head);
 
 	goto again;
 
-- 
1.7.7


  parent reply	other threads:[~2012-01-21 10:08 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-21 10:08 [PATCH 00/21] PCI : bridge resource reallocation patchset Yinghai Lu
2012-01-21 10:08 ` [PATCH 01/21] PCI : Calculate right add_size Yinghai Lu
2012-01-27 17:55   ` Jesse Barnes
2012-01-21 10:08 ` [PATCH 02/21] PCI: Make add_to_list() return status Yinghai Lu
2012-01-21 10:08 ` [PATCH 03/21] PCI: Move get_res_add_size() early Yinghai Lu
2012-01-21 10:08 ` [PATCH 04/21] PCI: Try to assign required+option size at first Yinghai Lu
2012-01-21 10:08 ` [PATCH 05/21] PCI: Using add_list in pcie hotplug path Yinghai Lu
2012-01-21 10:08 ` [PATCH 06/21] PCI: Make rescan bus could increase bridge resource size if needed Yinghai Lu
2012-01-27 18:00   ` Jesse Barnes
2012-01-21 10:08 ` [PATCH 07/21] PCI: Make pci_rescan_bus handle add_list Yinghai Lu
2012-01-21 10:08 ` [PATCH 08/21] PCI: Fixing multiple retrying with pci resource optional resources allocation under multi bridges Yinghai Lu
2012-01-21 10:08 ` [PATCH 09/21] PCI: Move pdev_sort_resources() to setup-bus.c Yinghai Lu
2012-01-21 10:08 ` [PATCH 10/21] PCI: Move struct resource_list " Yinghai Lu
2012-01-21 10:08 ` [PATCH 11/21] PCI: Replace resource_list with generic list Yinghai Lu
2012-01-21 10:08 ` [PATCH 12/21] PCI: Merge pci_dev_resource_x and pci_dev_resource Yinghai Lu
2012-01-21 10:08 ` [PATCH 13/21] PCI: Rename dev_res_x to add_res or fail_res Yinghai Lu
2012-01-21 10:08 ` Yinghai Lu [this message]
2012-01-21 10:08 ` [PATCH 15/21] PCI: add debug print out for add_size Yinghai Lu
2012-01-21 10:08 ` [PATCH 16/21] PCI: remove add_to_failed_list() Yinghai Lu
2012-01-27 18:21   ` Jesse Barnes
2012-01-21 10:08 ` [PATCH 17/21] PCI: Disable cardbus bridge MEM1 pref CTL Yinghai Lu
2012-01-27 18:22   ` Jesse Barnes
2012-01-27 18:39     ` Yinghai Lu
2012-01-21 10:08 ` [PATCH 18/21] PCI: Fix cardbus bridge resources as optional size handling Yinghai Lu
2012-01-27 18:23   ` Jesse Barnes
2012-01-27 21:37     ` Yinghai Lu
2012-02-05 21:58       ` Dominik Brodowski
2012-02-05 23:30         ` Yinghai Lu
2012-02-10 15:35           ` Dominik Brodowski
2012-02-10 17:07             ` Yinghai Lu
2012-01-21 10:08 ` [PATCH 19/21] PCI: Retry on type IORESOURCE_IO allocation Yinghai Lu
2012-01-21 10:08 ` [PATCH 20/21] PCI: Make pci bridge reallocating enabled/disabled Yinghai Lu
2012-01-21 10:08 ` [PATCH 21/21] PCI: only enable pci realloc when SRIOV bar is not assigned Yinghai Lu
2012-01-27 18:25   ` Jesse Barnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327140517-14811-15-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).