[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    PNP: pass resources, not indexes, to pnp_check_port(), et al
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2008-04-30 19:37:39
Message-ID: 200804301937.m3UJbdRJ014684 () hera ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f5d94ff014cb7e6212f40fc6644f3fd68507df33
Commit:     f5d94ff014cb7e6212f40fc6644f3fd68507df33
Parent:     db9eaeab3e7ab72d773820820f1ba33960ad24c4
Author:     Bjorn Helgaas <bjorn.helgaas@hp.com>
AuthorDate: Mon Apr 28 16:34:22 2008 -0600
Committer:  Len Brown <len.brown@intel.com>
CommitDate: Tue Apr 29 03:22:25 2008 -0400

    PNP: pass resources, not indexes, to pnp_check_port(), et al
    
    The caller already has the struct resource pointer, so no need for
    pnp_check_port(), pnp_check_mem(), etc., to look it up again.
    
    Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
    Acked-By: Rene Herman <rene.herman@gmail.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/pnp/base.h     |    8 ++++----
 drivers/pnp/manager.c  |    8 ++++----
 drivers/pnp/resource.c |   20 ++++++++------------
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index eb43fc6..e739d4b 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -12,10 +12,10 @@ void pnp_free_option(struct pnp_option *option);
 int __pnp_add_device(struct pnp_dev *dev);
 void __pnp_remove_device(struct pnp_dev *dev);
 
-int pnp_check_port(struct pnp_dev * dev, int idx);
-int pnp_check_mem(struct pnp_dev * dev, int idx);
-int pnp_check_irq(struct pnp_dev * dev, int idx);
-int pnp_check_dma(struct pnp_dev * dev, int idx);
+int pnp_check_port(struct pnp_dev *dev, struct resource *res);
+int pnp_check_mem(struct pnp_dev *dev, struct resource *res);
+int pnp_check_irq(struct pnp_dev *dev, struct resource *res);
+int pnp_check_dma(struct pnp_dev *dev, struct resource *res);
 
 void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
 
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index be21dec..0886529 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -51,7 +51,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
 	res->end = res->start + rule->size - 1;
 
 	/* run through until pnp_check_port is happy */
-	while (!pnp_check_port(dev, idx)) {
+	while (!pnp_check_port(dev, res)) {
 		res->start += rule->align;
 		res->end = res->start + rule->size - 1;
 		if (res->start > rule->max || !rule->align) {
@@ -108,7 +108,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
 	res->end = res->start + rule->size - 1;
 
 	/* run through until pnp_check_mem is happy */
-	while (!pnp_check_mem(dev, idx)) {
+	while (!pnp_check_mem(dev, res)) {
 		res->start += rule->align;
 		res->end = res->start + rule->size - 1;
 		if (res->start > rule->max || !rule->align) {
@@ -167,7 +167,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
 	for (i = 0; i < 16; i++) {
 		if (test_bit(xtab[i], rule->map)) {
 			res->start = res->end = xtab[i];
-			if (pnp_check_irq(dev, idx)) {
+			if (pnp_check_irq(dev, res)) {
 				dev_dbg(&dev->dev, "  assign irq %d %d\n", idx,
 					(int) res->start);
 				return 1;
@@ -209,7 +209,7 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
 	for (i = 0; i < 8; i++) {
 		if (rule->map & (1 << xtab[i])) {
 			res->start = res->end = xtab[i];
-			if (pnp_check_dma(dev, idx)) {
+			if (pnp_check_dma(dev, res)) {
 				dev_dbg(&dev->dev, "  assign dma %d %d\n", idx,
 					(int) res->start);
 				return;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index eab16e5..93bf45e 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -239,14 +239,13 @@ void pnp_free_option(struct pnp_option *option)
 #define cannot_compare(flags) \
 ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED))
 
-int pnp_check_port(struct pnp_dev *dev, int idx)
+int pnp_check_port(struct pnp_dev *dev, struct resource *res)
 {
 	int i;
 	struct pnp_dev *tdev;
-	struct resource *res, *tres;
+	struct resource *tres;
 	resource_size_t *port, *end, *tport, *tend;
 
-	res = &dev->res.port_resource[idx];
 	port = &res->start;
 	end = &res->end;
 
@@ -300,14 +299,13 @@ int pnp_check_port(struct pnp_dev *dev, int idx)
 	return 1;
 }
 
-int pnp_check_mem(struct pnp_dev *dev, int idx)
+int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
 {
 	int i;
 	struct pnp_dev *tdev;
-	struct resource *res, *tres;
+	struct resource *tres;
 	resource_size_t *addr, *end, *taddr, *tend;
 
-	res = &dev->res.mem_resource[idx];
 	addr = &res->start;
 	end = &res->end;
 
@@ -366,14 +364,13 @@ static irqreturn_t pnp_test_handler(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-int pnp_check_irq(struct pnp_dev *dev, int idx)
+int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
 {
 	int i;
 	struct pnp_dev *tdev;
-	struct resource *res, *tres;
+	struct resource *tres;
 	resource_size_t *irq;
 
-	res = &dev->res.irq_resource[idx];
 	irq = &res->start;
 
 	/* if the resource doesn't exist, don't complain about it */
@@ -439,15 +436,14 @@ int pnp_check_irq(struct pnp_dev *dev, int idx)
 	return 1;
 }
 
-int pnp_check_dma(struct pnp_dev *dev, int idx)
+int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
 {
 #ifndef CONFIG_IA64
 	int i;
 	struct pnp_dev *tdev;
-	struct resource *res, *tres;
+	struct resource *tres;
 	resource_size_t *dma;
 
-	res = &dev->res.dma_resource[idx];
 	dma = &res->start;
 
 	/* if the resource doesn't exist, don't complain about it */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic