]> err.no Git - linux-2.6/blobdiff - drivers/pnp/resource.c
Merge branches 'release', 'button-sysfs', 'misc', 'mismatch', 'randconfig' and 'toshi...
[linux-2.6] / drivers / pnp / resource.c
index 635b11a0cf82977a85baaad86d478fd6890c2065..e50ebcffb96240937e3f43f4474857f6cdee8030 100644 (file)
@@ -1,9 +1,8 @@
 /*
  * resource.c - Contains functions for registering and analyzing resource information
  *
- * based on isapnp.c resource management (c) Jaroslav Kysela <perex@suse.cz>
+ * based on isapnp.c resource management (c) Jaroslav Kysela <perex@perex.cz>
  * Copyright 2003 Adam Belay <ambx1@neo.rr.com>
- *
  */
 
 #include <linux/module.h>
 #include <linux/pnp.h>
 #include "base.h"
 
-static int pnp_reserve_irq[16] = {[0...15] = -1 };     /* reserve (don't use) some IRQ */
-static int pnp_reserve_dma[8] = {[0...7] = -1 };       /* reserve (don't use) some DMA */
-static int pnp_reserve_io[16] = {[0...15] = -1 };      /* reserve (don't use) some I/O region */
-static int pnp_reserve_mem[16] = {[0...15] = -1 };     /* reserve (don't use) some memory region */
+static int pnp_reserve_irq[16] = {[0 ... 15] = -1 };   /* reserve (don't use) some IRQ */
+static int pnp_reserve_dma[8] = {[0 ... 7] = -1 };     /* reserve (don't use) some DMA */
+static int pnp_reserve_io[16] = {[0 ... 15] = -1 };    /* reserve (don't use) some I/O region */
+static int pnp_reserve_mem[16] = {[0 ... 15] = -1 };   /* reserve (don't use) some memory region */
 
 /*
  * option registration
@@ -33,7 +32,6 @@ static struct pnp_option *pnp_build_option(int priority)
 {
        struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option));
 
-       /* check if pnp_alloc ran out of memory */
        if (!option)
                return NULL;
 
@@ -48,14 +46,12 @@ static struct pnp_option *pnp_build_option(int priority)
 struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev)
 {
        struct pnp_option *option;
-       if (!dev)
-               return NULL;
 
        option = pnp_build_option(PNP_RES_PRIORITY_PREFERRED);
 
        /* this should never happen but if it does we'll try to continue */
        if (dev->independent)
-               pnp_err("independent resource already registered");
+               dev_err(&dev->dev, "independent resource already registered\n");
        dev->independent = option;
        return option;
 }
@@ -64,8 +60,6 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
                                                 int priority)
 {
        struct pnp_option *option;
-       if (!dev)
-               return NULL;
 
        option = pnp_build_option(priority);
 
@@ -82,10 +76,6 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
 int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
 {
        struct pnp_irq *ptr;
-       if (!option)
-               return -EINVAL;
-       if (!data)
-               return -EINVAL;
 
        ptr = option->irq;
        while (ptr && ptr->next)
@@ -110,10 +100,6 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
 int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
 {
        struct pnp_dma *ptr;
-       if (!option)
-               return -EINVAL;
-       if (!data)
-               return -EINVAL;
 
        ptr = option->dma;
        while (ptr && ptr->next)
@@ -129,10 +115,6 @@ int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
 int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
 {
        struct pnp_port *ptr;
-       if (!option)
-               return -EINVAL;
-       if (!data)
-               return -EINVAL;
 
        ptr = option->port;
        while (ptr && ptr->next)
@@ -148,10 +130,6 @@ int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
 int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data)
 {
        struct pnp_mem *ptr;
-       if (!option)
-               return -EINVAL;
-       if (!data)
-               return -EINVAL;
 
        ptr = option->mem;
        while (ptr && ptr->next)
@@ -240,6 +218,7 @@ int pnp_check_port(struct pnp_dev *dev, int idx)
        int tmp;
        struct pnp_dev *tdev;
        resource_size_t *port, *end, *tport, *tend;
+
        port = &dev->res.port_resource[idx].start;
        end = &dev->res.port_resource[idx].end;
 
@@ -297,6 +276,7 @@ int pnp_check_mem(struct pnp_dev *dev, int idx)
        int tmp;
        struct pnp_dev *tdev;
        resource_size_t *addr, *end, *taddr, *tend;
+
        addr = &dev->res.mem_resource[idx].start;
        end = &dev->res.mem_resource[idx].end;
 
@@ -387,8 +367,10 @@ int pnp_check_irq(struct pnp_dev *dev, int idx)
        {
                struct pci_dev *pci = NULL;
                for_each_pci_dev(pci) {
-                       if (pci->irq == *irq)
+                       if (pci->irq == *irq) {
+                               pci_dev_put(pci);
                                return 0;
+                       }
                }
        }
 #endif
@@ -474,22 +456,12 @@ int pnp_check_dma(struct pnp_dev *dev, int idx)
 
        return 1;
 #else
-       /* IA64 hasn't legacy DMA */
+       /* IA64 does not have legacy DMA */
        return 0;
 #endif
 }
 
-#if 0
-EXPORT_SYMBOL(pnp_register_dependent_option);
-EXPORT_SYMBOL(pnp_register_independent_option);
-EXPORT_SYMBOL(pnp_register_irq_resource);
-EXPORT_SYMBOL(pnp_register_dma_resource);
-EXPORT_SYMBOL(pnp_register_port_resource);
-EXPORT_SYMBOL(pnp_register_mem_resource);
-#endif /*  0  */
-
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
-
 static int __init pnp_setup_reserve_irq(char *str)
 {
        int i;
@@ -503,7 +475,6 @@ static int __init pnp_setup_reserve_irq(char *str)
 __setup("pnp_reserve_irq=", pnp_setup_reserve_irq);
 
 /* format is: pnp_reserve_dma=dma1[,dma2] .... */
-
 static int __init pnp_setup_reserve_dma(char *str)
 {
        int i;
@@ -517,7 +488,6 @@ static int __init pnp_setup_reserve_dma(char *str)
 __setup("pnp_reserve_dma=", pnp_setup_reserve_dma);
 
 /* format is: pnp_reserve_io=io1,size1[,io2,size2] .... */
-
 static int __init pnp_setup_reserve_io(char *str)
 {
        int i;
@@ -531,7 +501,6 @@ static int __init pnp_setup_reserve_io(char *str)
 __setup("pnp_reserve_io=", pnp_setup_reserve_io);
 
 /* format is: pnp_reserve_mem=mem1,size1[,mem2,size2] .... */
-
 static int __init pnp_setup_reserve_mem(char *str)
 {
        int i;