diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:34:32 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:28 -0400 |
commit | 21855d69d1e3ace3efdb8159a4a7ab1ab98a6f19 (patch) | |
tree | bfa5bc70ab7dabe5e4117fde96199df6c05cd261 /drivers/pnp/manager.c | |
parent | 0a977f15469457d9a19eed992caf71995c674064 (diff) |
PNP: add pnp_resource index for ISAPNP
Save the ISAPNP config register index in the struct pnp_resource.
We need this because it is important to write ISAPNP configuration
back to the same registers we read it from. For example, if we
read valid regions from memory descriptors 0, 1, and 3, we'd
better write them back to the same registers, without compressing
them to descriptors 0, 1, and 2.
This was previously guaranteed by using the index into the
pnp_resource_table array as the ISAPNP config register index.
However, I am removing those fixed-size arrays, so we need to
save the ISAPNP register index elsewhere.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/manager.c')
-rw-r--r-- | drivers/pnp/manager.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 4823da27e640..bea0914ff947 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c | |||
@@ -19,15 +19,18 @@ DEFINE_MUTEX(pnp_res_mutex); | |||
19 | 19 | ||
20 | static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) | 20 | static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) |
21 | { | 21 | { |
22 | struct pnp_resource *pnp_res; | ||
22 | struct resource *res; | 23 | struct resource *res; |
23 | 24 | ||
24 | res = pnp_get_resource(dev, IORESOURCE_IO, idx); | 25 | pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, idx); |
25 | if (!res) { | 26 | if (!pnp_res) { |
26 | dev_err(&dev->dev, "too many I/O port resources\n"); | 27 | dev_err(&dev->dev, "too many I/O port resources\n"); |
27 | /* pretend we were successful so at least the manager won't try again */ | 28 | /* pretend we were successful so at least the manager won't try again */ |
28 | return 1; | 29 | return 1; |
29 | } | 30 | } |
30 | 31 | ||
32 | res = &pnp_res->res; | ||
33 | |||
31 | /* check if this resource has been manually set, if so skip */ | 34 | /* check if this resource has been manually set, if so skip */ |
32 | if (!(res->flags & IORESOURCE_AUTO)) { | 35 | if (!(res->flags & IORESOURCE_AUTO)) { |
33 | dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx " | 36 | dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx " |
@@ -37,6 +40,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) | |||
37 | } | 40 | } |
38 | 41 | ||
39 | /* set the initial values */ | 42 | /* set the initial values */ |
43 | pnp_res->index = idx; | ||
40 | res->flags |= rule->flags | IORESOURCE_IO; | 44 | res->flags |= rule->flags | IORESOURCE_IO; |
41 | res->flags &= ~IORESOURCE_UNSET; | 45 | res->flags &= ~IORESOURCE_UNSET; |
42 | 46 | ||
@@ -65,15 +69,18 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) | |||
65 | 69 | ||
66 | static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | 70 | static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) |
67 | { | 71 | { |
72 | struct pnp_resource *pnp_res; | ||
68 | struct resource *res; | 73 | struct resource *res; |
69 | 74 | ||
70 | res = pnp_get_resource(dev, IORESOURCE_MEM, idx); | 75 | pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, idx); |
71 | if (!res) { | 76 | if (!pnp_res) { |
72 | dev_err(&dev->dev, "too many memory resources\n"); | 77 | dev_err(&dev->dev, "too many memory resources\n"); |
73 | /* pretend we were successful so at least the manager won't try again */ | 78 | /* pretend we were successful so at least the manager won't try again */ |
74 | return 1; | 79 | return 1; |
75 | } | 80 | } |
76 | 81 | ||
82 | res = &pnp_res->res; | ||
83 | |||
77 | /* check if this resource has been manually set, if so skip */ | 84 | /* check if this resource has been manually set, if so skip */ |
78 | if (!(res->flags & IORESOURCE_AUTO)) { | 85 | if (!(res->flags & IORESOURCE_AUTO)) { |
79 | dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx " | 86 | dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx " |
@@ -83,6 +90,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
83 | } | 90 | } |
84 | 91 | ||
85 | /* set the initial values */ | 92 | /* set the initial values */ |
93 | pnp_res->index = idx; | ||
86 | res->flags |= rule->flags | IORESOURCE_MEM; | 94 | res->flags |= rule->flags | IORESOURCE_MEM; |
87 | res->flags &= ~IORESOURCE_UNSET; | 95 | res->flags &= ~IORESOURCE_UNSET; |
88 | 96 | ||
@@ -121,6 +129,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
121 | 129 | ||
122 | static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) | 130 | static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) |
123 | { | 131 | { |
132 | struct pnp_resource *pnp_res; | ||
124 | struct resource *res; | 133 | struct resource *res; |
125 | int i; | 134 | int i; |
126 | 135 | ||
@@ -129,13 +138,15 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) | |||
129 | 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 | 138 | 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 |
130 | }; | 139 | }; |
131 | 140 | ||
132 | res = pnp_get_resource(dev, IORESOURCE_IRQ, idx); | 141 | pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, idx); |
133 | if (!res) { | 142 | if (!pnp_res) { |
134 | dev_err(&dev->dev, "too many IRQ resources\n"); | 143 | dev_err(&dev->dev, "too many IRQ resources\n"); |
135 | /* pretend we were successful so at least the manager won't try again */ | 144 | /* pretend we were successful so at least the manager won't try again */ |
136 | return 1; | 145 | return 1; |
137 | } | 146 | } |
138 | 147 | ||
148 | res = &pnp_res->res; | ||
149 | |||
139 | /* check if this resource has been manually set, if so skip */ | 150 | /* check if this resource has been manually set, if so skip */ |
140 | if (!(res->flags & IORESOURCE_AUTO)) { | 151 | if (!(res->flags & IORESOURCE_AUTO)) { |
141 | dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n", | 152 | dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n", |
@@ -144,6 +155,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) | |||
144 | } | 155 | } |
145 | 156 | ||
146 | /* set the initial values */ | 157 | /* set the initial values */ |
158 | pnp_res->index = idx; | ||
147 | res->flags |= rule->flags | IORESOURCE_IRQ; | 159 | res->flags |= rule->flags | IORESOURCE_IRQ; |
148 | res->flags &= ~IORESOURCE_UNSET; | 160 | res->flags &= ~IORESOURCE_UNSET; |
149 | 161 | ||
@@ -177,6 +189,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) | |||
177 | 189 | ||
178 | static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | 190 | static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) |
179 | { | 191 | { |
192 | struct pnp_resource *pnp_res; | ||
180 | struct resource *res; | 193 | struct resource *res; |
181 | int i; | 194 | int i; |
182 | 195 | ||
@@ -185,12 +198,14 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
185 | 1, 3, 5, 6, 7, 0, 2, 4 | 198 | 1, 3, 5, 6, 7, 0, 2, 4 |
186 | }; | 199 | }; |
187 | 200 | ||
188 | res = pnp_get_resource(dev, IORESOURCE_DMA, idx); | 201 | pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, idx); |
189 | if (!res) { | 202 | if (!pnp_res) { |
190 | dev_err(&dev->dev, "too many DMA resources\n"); | 203 | dev_err(&dev->dev, "too many DMA resources\n"); |
191 | return; | 204 | return; |
192 | } | 205 | } |
193 | 206 | ||
207 | res = &pnp_res->res; | ||
208 | |||
194 | /* check if this resource has been manually set, if so skip */ | 209 | /* check if this resource has been manually set, if so skip */ |
195 | if (!(res->flags & IORESOURCE_AUTO)) { | 210 | if (!(res->flags & IORESOURCE_AUTO)) { |
196 | dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n", | 211 | dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n", |
@@ -199,6 +214,7 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
199 | } | 214 | } |
200 | 215 | ||
201 | /* set the initial values */ | 216 | /* set the initial values */ |
217 | pnp_res->index = idx; | ||
202 | res->flags |= rule->flags | IORESOURCE_DMA; | 218 | res->flags |= rule->flags | IORESOURCE_DMA; |
203 | res->flags &= ~IORESOURCE_UNSET; | 219 | res->flags &= ~IORESOURCE_UNSET; |
204 | 220 | ||