aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/rsparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpbios/rsparser.c')
-rw-r--r--drivers/pnp/pnpbios/rsparser.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 9f0538af0321..d3b0a4e53692 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -56,80 +56,90 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
56 56
57static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) 57static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
58{ 58{
59 struct pnp_resource_table *res = dev->res; 59 struct resource *res;
60 int i = 0; 60 int i;
61
62 for (i = 0; i < PNP_MAX_IRQ; i++) {
63 res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
64 if (!pnp_resource_valid(res))
65 break;
66 }
61 67
62 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
63 && i < PNP_MAX_IRQ)
64 i++;
65 if (i < PNP_MAX_IRQ) { 68 if (i < PNP_MAX_IRQ) {
66 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 69 res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag
67 if (irq == -1) { 70 if (irq == -1) {
68 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 71 res->flags |= IORESOURCE_DISABLED;
69 return; 72 return;
70 } 73 }
71 res->irq_resource[i].start = 74 res->start = res->end = (unsigned long)irq;
72 res->irq_resource[i].end = (unsigned long)irq;
73 pcibios_penalize_isa_irq(irq, 1); 75 pcibios_penalize_isa_irq(irq, 1);
74 } 76 }
75} 77}
76 78
77static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) 79static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
78{ 80{
79 struct pnp_resource_table *res = dev->res; 81 struct resource *res;
80 int i = 0; 82 int i;
83
84 for (i = 0; i < PNP_MAX_DMA; i++) {
85 res = pnp_get_resource(dev, IORESOURCE_DMA, i);
86 if (!pnp_resource_valid(res))
87 break;
88 }
81 89
82 while (i < PNP_MAX_DMA &&
83 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
84 i++;
85 if (i < PNP_MAX_DMA) { 90 if (i < PNP_MAX_DMA) {
86 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 91 res->flags = IORESOURCE_DMA; // Also clears _UNSET flag
87 if (dma == -1) { 92 if (dma == -1) {
88 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 93 res->flags |= IORESOURCE_DISABLED;
89 return; 94 return;
90 } 95 }
91 res->dma_resource[i].start = 96 res->start = res->end = (unsigned long)dma;
92 res->dma_resource[i].end = (unsigned long)dma;
93 } 97 }
94} 98}
95 99
96static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, 100static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
97 int io, int len) 101 int io, int len)
98{ 102{
99 struct pnp_resource_table *res = dev->res; 103 struct resource *res;
100 int i = 0; 104 int i;
105
106 for (i = 0; i < PNP_MAX_PORT; i++) {
107 res = pnp_get_resource(dev, IORESOURCE_IO, i);
108 if (!pnp_resource_valid(res))
109 break;
110 }
101 111
102 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
103 && i < PNP_MAX_PORT)
104 i++;
105 if (i < PNP_MAX_PORT) { 112 if (i < PNP_MAX_PORT) {
106 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 113 res->flags = IORESOURCE_IO; // Also clears _UNSET flag
107 if (len <= 0 || (io + len - 1) >= 0x10003) { 114 if (len <= 0 || (io + len - 1) >= 0x10003) {
108 res->port_resource[i].flags |= IORESOURCE_DISABLED; 115 res->flags |= IORESOURCE_DISABLED;
109 return; 116 return;
110 } 117 }
111 res->port_resource[i].start = (unsigned long)io; 118 res->start = (unsigned long)io;
112 res->port_resource[i].end = (unsigned long)(io + len - 1); 119 res->end = (unsigned long)(io + len - 1);
113 } 120 }
114} 121}
115 122
116static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, 123static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
117 int mem, int len) 124 int mem, int len)
118{ 125{
119 struct pnp_resource_table *res = dev->res; 126 struct resource *res;
120 int i = 0; 127 int i;
128
129 for (i = 0; i < PNP_MAX_MEM; i++) {
130 res = pnp_get_resource(dev, IORESOURCE_MEM, i);
131 if (!pnp_resource_valid(res))
132 break;
133 }
121 134
122 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
123 && i < PNP_MAX_MEM)
124 i++;
125 if (i < PNP_MAX_MEM) { 135 if (i < PNP_MAX_MEM) {
126 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 136 res->flags = IORESOURCE_MEM; // Also clears _UNSET flag
127 if (len <= 0) { 137 if (len <= 0) {
128 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 138 res->flags |= IORESOURCE_DISABLED;
129 return; 139 return;
130 } 140 }
131 res->mem_resource[i].start = (unsigned long)mem; 141 res->start = (unsigned long)mem;
132 res->mem_resource[i].end = (unsigned long)(mem + len - 1); 142 res->end = (unsigned long)(mem + len - 1);
133 } 143 }
134} 144}
135 145