aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:20 -0400
commit9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (patch)
tree57ee3822b79049d38c1df952fe77e72a97c718f3 /drivers/pnp/pnpacpi
parent8ec3cf7d29aef773eee5bc6cd9b0fa4d3fb42480 (diff)
PNP: Lindent all source files
Run Lindent on all PNP source files. Produced by: $ quilt new pnp-lindent $ find drivers/pnp -name \*.[ch] | xargs quilt add $ quilt add include/linux/{pnp.h,pnpbios.h} $ scripts/Lindent drivers/pnp/*.c drivers/pnp/*/*.c include/linux/pnp*.h $ quilt refresh --sort Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Len Brown <lenb@kernel.org> Cc: Adam Belay <ambx1@neo.rr.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp/pnpacpi')
-rw-r--r--drivers/pnp/pnpacpi/core.c87
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c435
2 files changed, 283 insertions, 239 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index fcd32ac575c3..423c8e7e322d 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -36,11 +36,11 @@ static int num = 0;
36 * have irqs (PIC, Timer) because we call acpi_register_gsi. 36 * have irqs (PIC, Timer) because we call acpi_register_gsi.
37 * Finaly only devices that have a CRS method need to be in this list. 37 * Finaly only devices that have a CRS method need to be in this list.
38 */ 38 */
39static __initdata struct acpi_device_id excluded_id_list[] ={ 39static __initdata struct acpi_device_id excluded_id_list[] = {
40 {"PNP0C09", 0}, /* EC */ 40 {"PNP0C09", 0}, /* EC */
41 {"PNP0C0F", 0}, /* Link device */ 41 {"PNP0C0F", 0}, /* Link device */
42 {"PNP0000", 0}, /* PIC */ 42 {"PNP0000", 0}, /* PIC */
43 {"PNP0100", 0}, /* Timer */ 43 {"PNP0100", 0}, /* Timer */
44 {"", 0}, 44 {"", 0},
45}; 45};
46 46
@@ -84,15 +84,17 @@ static void __init pnpidacpi_to_pnpid(char *id, char *str)
84 str[7] = '\0'; 84 str[7] = '\0';
85} 85}
86 86
87static int pnpacpi_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 87static int pnpacpi_get_resources(struct pnp_dev *dev,
88 struct pnp_resource_table *res)
88{ 89{
89 acpi_status status; 90 acpi_status status;
90 status = pnpacpi_parse_allocated_resource((acpi_handle)dev->data, 91 status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data,
91 &dev->res); 92 &dev->res);
92 return ACPI_FAILURE(status) ? -ENODEV : 0; 93 return ACPI_FAILURE(status) ? -ENODEV : 0;
93} 94}
94 95
95static int pnpacpi_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 96static int pnpacpi_set_resources(struct pnp_dev *dev,
97 struct pnp_resource_table *res)
96{ 98{
97 acpi_handle handle = dev->data; 99 acpi_handle handle = dev->data;
98 struct acpi_buffer buffer; 100 struct acpi_buffer buffer;
@@ -119,27 +121,29 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
119 acpi_status status; 121 acpi_status status;
120 122
121 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 123 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
122 status = acpi_evaluate_object((acpi_handle)dev->data, 124 status = acpi_evaluate_object((acpi_handle) dev->data,
123 "_DIS", NULL, NULL); 125 "_DIS", NULL, NULL);
124 return ACPI_FAILURE(status) ? -ENODEV : 0; 126 return ACPI_FAILURE(status) ? -ENODEV : 0;
125} 127}
126 128
127static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) 129static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
128{ 130{
129 return acpi_bus_set_power((acpi_handle)dev->data, 131 return acpi_bus_set_power((acpi_handle) dev->data,
130 acpi_pm_device_sleep_state(&dev->dev, 132 acpi_pm_device_sleep_state(&dev->dev,
131 device_may_wakeup(&dev->dev), NULL)); 133 device_may_wakeup
134 (&dev->dev),
135 NULL));
132} 136}
133 137
134static int pnpacpi_resume(struct pnp_dev *dev) 138static int pnpacpi_resume(struct pnp_dev *dev)
135{ 139{
136 return acpi_bus_set_power((acpi_handle)dev->data, ACPI_STATE_D0); 140 return acpi_bus_set_power((acpi_handle) dev->data, ACPI_STATE_D0);
137} 141}
138 142
139static struct pnp_protocol pnpacpi_protocol = { 143static struct pnp_protocol pnpacpi_protocol = {
140 .name = "Plug and Play ACPI", 144 .name = "Plug and Play ACPI",
141 .get = pnpacpi_get_resources, 145 .get = pnpacpi_get_resources,
142 .set = pnpacpi_set_resources, 146 .set = pnpacpi_set_resources,
143 .disable = pnpacpi_disable_resources, 147 .disable = pnpacpi_disable_resources,
144 .suspend = pnpacpi_suspend, 148 .suspend = pnpacpi_suspend,
145 .resume = pnpacpi_resume, 149 .resume = pnpacpi_resume,
@@ -154,11 +158,11 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
154 158
155 status = acpi_get_handle(device->handle, "_CRS", &temp); 159 status = acpi_get_handle(device->handle, "_CRS", &temp);
156 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) || 160 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
157 is_exclusive_device(device)) 161 is_exclusive_device(device))
158 return 0; 162 return 0;
159 163
160 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); 164 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
161 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); 165 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
162 if (!dev) { 166 if (!dev) {
163 pnp_err("Out of memory"); 167 pnp_err("Out of memory");
164 return -ENOMEM; 168 return -ENOMEM;
@@ -194,20 +198,23 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
194 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); 198 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
195 pnp_add_id(dev_id, dev); 199 pnp_add_id(dev_id, dev);
196 200
197 if(dev->active) { 201 if (dev->active) {
198 /* parse allocated resource */ 202 /* parse allocated resource */
199 status = pnpacpi_parse_allocated_resource(device->handle, &dev->res); 203 status =
204 pnpacpi_parse_allocated_resource(device->handle, &dev->res);
200 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 205 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
201 pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", dev_id->id); 206 pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
207 dev_id->id);
202 goto err1; 208 goto err1;
203 } 209 }
204 } 210 }
205 211
206 if(dev->capabilities & PNP_CONFIGURABLE) { 212 if (dev->capabilities & PNP_CONFIGURABLE) {
207 status = pnpacpi_parse_resource_option_data(device->handle, 213 status = pnpacpi_parse_resource_option_data(device->handle,
208 dev); 214 dev);
209 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 215 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
210 pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", dev_id->id); 216 pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
217 dev_id->id);
211 goto err1; 218 goto err1;
212 } 219 }
213 } 220 }
@@ -233,18 +240,19 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
233 if (!dev->active) 240 if (!dev->active)
234 pnp_init_resource_table(&dev->res); 241 pnp_init_resource_table(&dev->res);
235 pnp_add_device(dev); 242 pnp_add_device(dev);
236 num ++; 243 num++;
237 244
238 return AE_OK; 245 return AE_OK;
239err1: 246 err1:
240 kfree(dev_id); 247 kfree(dev_id);
241err: 248 err:
242 kfree(dev); 249 kfree(dev);
243 return -EINVAL; 250 return -EINVAL;
244} 251}
245 252
246static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 253static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
247 u32 lvl, void *context, void **rv) 254 u32 lvl, void *context,
255 void **rv)
248{ 256{
249 struct acpi_device *device; 257 struct acpi_device *device;
250 258
@@ -257,23 +265,22 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
257 265
258static int __init acpi_pnp_match(struct device *dev, void *_pnp) 266static int __init acpi_pnp_match(struct device *dev, void *_pnp)
259{ 267{
260 struct acpi_device *acpi = to_acpi_device(dev); 268 struct acpi_device *acpi = to_acpi_device(dev);
261 struct pnp_dev *pnp = _pnp; 269 struct pnp_dev *pnp = _pnp;
262 270
263 /* true means it matched */ 271 /* true means it matched */
264 return acpi->flags.hardware_id 272 return acpi->flags.hardware_id
265 && !acpi_get_physical_device(acpi->handle) 273 && !acpi_get_physical_device(acpi->handle)
266 && compare_pnp_id(pnp->id, acpi->pnp.hardware_id); 274 && compare_pnp_id(pnp->id, acpi->pnp.hardware_id);
267} 275}
268 276
269static int __init acpi_pnp_find_device(struct device *dev, acpi_handle *handle) 277static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
270{ 278{
271 struct device *adev; 279 struct device *adev;
272 struct acpi_device *acpi; 280 struct acpi_device *acpi;
273 281
274 adev = bus_find_device(&acpi_bus_type, NULL, 282 adev = bus_find_device(&acpi_bus_type, NULL,
275 to_pnp_dev(dev), 283 to_pnp_dev(dev), acpi_pnp_match);
276 acpi_pnp_match);
277 if (!adev) 284 if (!adev)
278 return -ENODEV; 285 return -ENODEV;
279 286
@@ -307,6 +314,7 @@ static int __init pnpacpi_init(void)
307 pnp_platform_devices = 1; 314 pnp_platform_devices = 1;
308 return 0; 315 return 0;
309} 316}
317
310subsys_initcall(pnpacpi_init); 318subsys_initcall(pnpacpi_init);
311 319
312static int __init pnpacpi_setup(char *str) 320static int __init pnpacpi_setup(char *str)
@@ -317,6 +325,7 @@ static int __init pnpacpi_setup(char *str)
317 pnpacpi_disabled = 1; 325 pnpacpi_disabled = 1;
318 return 1; 326 return 1;
319} 327}
328
320__setup("pnpacpi=", pnpacpi_setup); 329__setup("pnpacpi=", pnpacpi_setup);
321 330
322#if 0 331#if 0
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 118ac9779b3c..2f0d66886404 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -40,8 +40,7 @@ static int irq_flags(int triggering, int polarity)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 } else {
44 else {
45 if (polarity == ACPI_ACTIVE_LOW) 44 if (polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 45 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 46 else
@@ -74,7 +73,7 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity)
74 73
75static void 74static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, 75pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi,
77 int triggering, int polarity, int shareable) 76 int triggering, int polarity, int shareable)
78{ 77{
79 int i = 0; 78 int i = 0;
80 int irq; 79 int irq;
@@ -83,12 +82,12 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi,
83 return; 82 return;
84 83
85 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && 84 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
86 i < PNP_MAX_IRQ) 85 i < PNP_MAX_IRQ)
87 i++; 86 i++;
88 if (i >= PNP_MAX_IRQ) 87 if (i >= PNP_MAX_IRQ)
89 return; 88 return;
90 89
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 90 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 res->irq_resource[i].flags |= irq_flags(triggering, polarity); 91 res->irq_resource[i].flags |= irq_flags(triggering, polarity);
93 irq = acpi_register_gsi(gsi, triggering, polarity); 92 irq = acpi_register_gsi(gsi, triggering, polarity);
94 if (irq < 0) { 93 if (irq < 0) {
@@ -149,15 +148,16 @@ static int dma_flags(int type, int bus_master, int transfer)
149 148
150static void 149static void
151pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, 150pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma,
152 int type, int bus_master, int transfer) 151 int type, int bus_master, int transfer)
153{ 152{
154 int i = 0; 153 int i = 0;
155 while (i < PNP_MAX_DMA && 154 while (i < PNP_MAX_DMA &&
156 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 155 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
157 i++; 156 i++;
158 if (i < PNP_MAX_DMA) { 157 if (i < PNP_MAX_DMA) {
159 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 158 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
160 res->dma_resource[i].flags |= dma_flags(type, bus_master, transfer); 159 res->dma_resource[i].flags |=
160 dma_flags(type, bus_master, transfer);
161 if (dma == -1) { 161 if (dma == -1) {
162 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 162 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
163 return; 163 return;
@@ -169,17 +169,17 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma,
169 169
170static void 170static void
171pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, 171pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
172 u64 io, u64 len, int io_decode) 172 u64 io, u64 len, int io_decode)
173{ 173{
174 int i = 0; 174 int i = 0;
175 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && 175 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
176 i < PNP_MAX_PORT) 176 i < PNP_MAX_PORT)
177 i++; 177 i++;
178 if (i < PNP_MAX_PORT) { 178 if (i < PNP_MAX_PORT) {
179 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 179 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
180 if (io_decode == ACPI_DECODE_16) 180 if (io_decode == ACPI_DECODE_16)
181 res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; 181 res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR;
182 if (len <= 0 || (io + len -1) >= 0x10003) { 182 if (len <= 0 || (io + len - 1) >= 0x10003) {
183 res->port_resource[i].flags |= IORESOURCE_DISABLED; 183 res->port_resource[i].flags |= IORESOURCE_DISABLED;
184 return; 184 return;
185 } 185 }
@@ -190,19 +190,19 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
190 190
191static void 191static void
192pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, 192pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
193 u64 mem, u64 len, int write_protect) 193 u64 mem, u64 len, int write_protect)
194{ 194{
195 int i = 0; 195 int i = 0;
196 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && 196 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
197 (i < PNP_MAX_MEM)) 197 (i < PNP_MAX_MEM))
198 i++; 198 i++;
199 if (i < PNP_MAX_MEM) { 199 if (i < PNP_MAX_MEM) {
200 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 200 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
201 if (len <= 0) { 201 if (len <= 0) {
202 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 202 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
203 return; 203 return;
204 } 204 }
205 if(write_protect == ACPI_READ_WRITE_MEMORY) 205 if (write_protect == ACPI_READ_WRITE_MEMORY)
206 res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; 206 res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE;
207 207
208 res->mem_resource[i].start = mem; 208 res->mem_resource[i].start = mem;
@@ -212,7 +212,7 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
212 212
213static void 213static void
214pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, 214pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
215 struct acpi_resource *res) 215 struct acpi_resource *res)
216{ 216{
217 struct acpi_resource_address64 addr, *p = &addr; 217 struct acpi_resource_address64 addr, *p = &addr;
218 acpi_status status; 218 acpi_status status;
@@ -220,7 +220,7 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
220 status = acpi_resource_to_address64(res, p); 220 status = acpi_resource_to_address64(res, p);
221 if (!ACPI_SUCCESS(status)) { 221 if (!ACPI_SUCCESS(status)) {
222 pnp_warn("PnPACPI: failed to convert resource type %d", 222 pnp_warn("PnPACPI: failed to convert resource type %d",
223 res->type); 223 res->type);
224 return; 224 return;
225 } 225 }
226 226
@@ -229,17 +229,23 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
229 229
230 if (p->resource_type == ACPI_MEMORY_RANGE) 230 if (p->resource_type == ACPI_MEMORY_RANGE)
231 pnpacpi_parse_allocated_memresource(res_table, 231 pnpacpi_parse_allocated_memresource(res_table,
232 p->minimum, p->address_length, p->info.mem.write_protect); 232 p->minimum,
233 p->address_length,
234 p->info.mem.write_protect);
233 else if (p->resource_type == ACPI_IO_RANGE) 235 else if (p->resource_type == ACPI_IO_RANGE)
234 pnpacpi_parse_allocated_ioresource(res_table, 236 pnpacpi_parse_allocated_ioresource(res_table,
235 p->minimum, p->address_length, 237 p->minimum,
236 p->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16); 238 p->address_length,
239 p->granularity ==
240 0xfff ? ACPI_DECODE_10 :
241 ACPI_DECODE_16);
237} 242}
238 243
239static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 244static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
240 void *data) 245 void *data)
241{ 246{
242 struct pnp_resource_table *res_table = (struct pnp_resource_table *)data; 247 struct pnp_resource_table *res_table =
248 (struct pnp_resource_table *)data;
243 int i; 249 int i;
244 250
245 switch (res->type) { 251 switch (res->type) {
@@ -250,27 +256,34 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
250 */ 256 */
251 for (i = 0; i < res->data.irq.interrupt_count; i++) { 257 for (i = 0; i < res->data.irq.interrupt_count; i++) {
252 pnpacpi_parse_allocated_irqresource(res_table, 258 pnpacpi_parse_allocated_irqresource(res_table,
253 res->data.irq.interrupts[i], 259 res->data.irq.
254 res->data.irq.triggering, 260 interrupts[i],
255 res->data.irq.polarity, 261 res->data.irq.
256 res->data.irq.sharable); 262 triggering,
263 res->data.irq.
264 polarity,
265 res->data.irq.
266 sharable);
257 } 267 }
258 break; 268 break;
259 269
260 case ACPI_RESOURCE_TYPE_DMA: 270 case ACPI_RESOURCE_TYPE_DMA:
261 if (res->data.dma.channel_count > 0) 271 if (res->data.dma.channel_count > 0)
262 pnpacpi_parse_allocated_dmaresource(res_table, 272 pnpacpi_parse_allocated_dmaresource(res_table,
263 res->data.dma.channels[0], 273 res->data.dma.
264 res->data.dma.type, 274 channels[0],
265 res->data.dma.bus_master, 275 res->data.dma.type,
266 res->data.dma.transfer); 276 res->data.dma.
277 bus_master,
278 res->data.dma.
279 transfer);
267 break; 280 break;
268 281
269 case ACPI_RESOURCE_TYPE_IO: 282 case ACPI_RESOURCE_TYPE_IO:
270 pnpacpi_parse_allocated_ioresource(res_table, 283 pnpacpi_parse_allocated_ioresource(res_table,
271 res->data.io.minimum, 284 res->data.io.minimum,
272 res->data.io.address_length, 285 res->data.io.address_length,
273 res->data.io.io_decode); 286 res->data.io.io_decode);
274 break; 287 break;
275 288
276 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 289 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -279,9 +292,10 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
279 292
280 case ACPI_RESOURCE_TYPE_FIXED_IO: 293 case ACPI_RESOURCE_TYPE_FIXED_IO:
281 pnpacpi_parse_allocated_ioresource(res_table, 294 pnpacpi_parse_allocated_ioresource(res_table,
282 res->data.fixed_io.address, 295 res->data.fixed_io.address,
283 res->data.fixed_io.address_length, 296 res->data.fixed_io.
284 ACPI_DECODE_10); 297 address_length,
298 ACPI_DECODE_10);
285 break; 299 break;
286 300
287 case ACPI_RESOURCE_TYPE_VENDOR: 301 case ACPI_RESOURCE_TYPE_VENDOR:
@@ -292,21 +306,28 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
292 306
293 case ACPI_RESOURCE_TYPE_MEMORY24: 307 case ACPI_RESOURCE_TYPE_MEMORY24:
294 pnpacpi_parse_allocated_memresource(res_table, 308 pnpacpi_parse_allocated_memresource(res_table,
295 res->data.memory24.minimum, 309 res->data.memory24.minimum,
296 res->data.memory24.address_length, 310 res->data.memory24.
297 res->data.memory24.write_protect); 311 address_length,
312 res->data.memory24.
313 write_protect);
298 break; 314 break;
299 case ACPI_RESOURCE_TYPE_MEMORY32: 315 case ACPI_RESOURCE_TYPE_MEMORY32:
300 pnpacpi_parse_allocated_memresource(res_table, 316 pnpacpi_parse_allocated_memresource(res_table,
301 res->data.memory32.minimum, 317 res->data.memory32.minimum,
302 res->data.memory32.address_length, 318 res->data.memory32.
303 res->data.memory32.write_protect); 319 address_length,
320 res->data.memory32.
321 write_protect);
304 break; 322 break;
305 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 323 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
306 pnpacpi_parse_allocated_memresource(res_table, 324 pnpacpi_parse_allocated_memresource(res_table,
307 res->data.fixed_memory32.address, 325 res->data.fixed_memory32.
308 res->data.fixed_memory32.address_length, 326 address,
309 res->data.fixed_memory32.write_protect); 327 res->data.fixed_memory32.
328 address_length,
329 res->data.fixed_memory32.
330 write_protect);
310 break; 331 break;
311 case ACPI_RESOURCE_TYPE_ADDRESS16: 332 case ACPI_RESOURCE_TYPE_ADDRESS16:
312 case ACPI_RESOURCE_TYPE_ADDRESS32: 333 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -325,10 +346,18 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
325 346
326 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { 347 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
327 pnpacpi_parse_allocated_irqresource(res_table, 348 pnpacpi_parse_allocated_irqresource(res_table,
328 res->data.extended_irq.interrupts[i], 349 res->data.
329 res->data.extended_irq.triggering, 350 extended_irq.
330 res->data.extended_irq.polarity, 351 interrupts[i],
331 res->data.extended_irq.sharable); 352 res->data.
353 extended_irq.
354 triggering,
355 res->data.
356 extended_irq.
357 polarity,
358 res->data.
359 extended_irq.
360 sharable);
332 } 361 }
333 break; 362 break;
334 363
@@ -343,18 +372,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
343 return AE_OK; 372 return AE_OK;
344} 373}
345 374
346acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res) 375acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle,
376 struct pnp_resource_table * res)
347{ 377{
348 /* Blank the resource table values */ 378 /* Blank the resource table values */
349 pnp_init_resource_table(res); 379 pnp_init_resource_table(res);
350 380
351 return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); 381 return acpi_walk_resources(handle, METHOD_NAME__CRS,
382 pnpacpi_allocated_resource, res);
352} 383}
353 384
354static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p) 385static void pnpacpi_parse_dma_option(struct pnp_option *option,
386 struct acpi_resource_dma *p)
355{ 387{
356 int i; 388 int i;
357 struct pnp_dma * dma; 389 struct pnp_dma *dma;
358 390
359 if (p->channel_count == 0) 391 if (p->channel_count == 0)
360 return; 392 return;
@@ -362,7 +394,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
362 if (!dma) 394 if (!dma)
363 return; 395 return;
364 396
365 for(i = 0; i < p->channel_count; i++) 397 for (i = 0; i < p->channel_count; i++)
366 dma->map |= 1 << p->channels[i]; 398 dma->map |= 1 << p->channels[i];
367 399
368 dma->flags = dma_flags(p->type, p->bus_master, p->transfer); 400 dma->flags = dma_flags(p->type, p->bus_master, p->transfer);
@@ -371,9 +403,8 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
371 return; 403 return;
372} 404}
373 405
374
375static void pnpacpi_parse_irq_option(struct pnp_option *option, 406static void pnpacpi_parse_irq_option(struct pnp_option *option,
376 struct acpi_resource_irq *p) 407 struct acpi_resource_irq *p)
377{ 408{
378 int i; 409 int i;
379 struct pnp_irq *irq; 410 struct pnp_irq *irq;
@@ -384,7 +415,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
384 if (!irq) 415 if (!irq)
385 return; 416 return;
386 417
387 for(i = 0; i < p->interrupt_count; i++) 418 for (i = 0; i < p->interrupt_count; i++)
388 if (p->interrupts[i]) 419 if (p->interrupts[i])
389 __set_bit(p->interrupts[i], irq->map); 420 __set_bit(p->interrupts[i], irq->map);
390 irq->flags = irq_flags(p->triggering, p->polarity); 421 irq->flags = irq_flags(p->triggering, p->polarity);
@@ -394,7 +425,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
394} 425}
395 426
396static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 427static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
397 struct acpi_resource_extended_irq *p) 428 struct acpi_resource_extended_irq *p)
398{ 429{
399 int i; 430 int i;
400 struct pnp_irq *irq; 431 struct pnp_irq *irq;
@@ -405,7 +436,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
405 if (!irq) 436 if (!irq)
406 return; 437 return;
407 438
408 for(i = 0; i < p->interrupt_count; i++) 439 for (i = 0; i < p->interrupt_count; i++)
409 if (p->interrupts[i]) 440 if (p->interrupts[i])
410 __set_bit(p->interrupts[i], irq->map); 441 __set_bit(p->interrupts[i], irq->map);
411 irq->flags = irq_flags(p->triggering, p->polarity); 442 irq->flags = irq_flags(p->triggering, p->polarity);
@@ -416,7 +447,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
416 447
417static void 448static void
418pnpacpi_parse_port_option(struct pnp_option *option, 449pnpacpi_parse_port_option(struct pnp_option *option,
419 struct acpi_resource_io *io) 450 struct acpi_resource_io *io)
420{ 451{
421 struct pnp_port *port; 452 struct pnp_port *port;
422 453
@@ -430,14 +461,14 @@ pnpacpi_parse_port_option(struct pnp_option *option,
430 port->align = io->alignment; 461 port->align = io->alignment;
431 port->size = io->address_length; 462 port->size = io->address_length;
432 port->flags = ACPI_DECODE_16 == io->io_decode ? 463 port->flags = ACPI_DECODE_16 == io->io_decode ?
433 PNP_PORT_FLAG_16BITADDR : 0; 464 PNP_PORT_FLAG_16BITADDR : 0;
434 pnp_register_port_resource(option, port); 465 pnp_register_port_resource(option, port);
435 return; 466 return;
436} 467}
437 468
438static void 469static void
439pnpacpi_parse_fixed_port_option(struct pnp_option *option, 470pnpacpi_parse_fixed_port_option(struct pnp_option *option,
440 struct acpi_resource_fixed_io *io) 471 struct acpi_resource_fixed_io *io)
441{ 472{
442 struct pnp_port *port; 473 struct pnp_port *port;
443 474
@@ -456,7 +487,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
456 487
457static void 488static void
458pnpacpi_parse_mem24_option(struct pnp_option *option, 489pnpacpi_parse_mem24_option(struct pnp_option *option,
459 struct acpi_resource_memory24 *p) 490 struct acpi_resource_memory24 *p)
460{ 491{
461 struct pnp_mem *mem; 492 struct pnp_mem *mem;
462 493
@@ -471,7 +502,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
471 mem->size = p->address_length; 502 mem->size = p->address_length;
472 503
473 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 504 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
474 IORESOURCE_MEM_WRITEABLE : 0; 505 IORESOURCE_MEM_WRITEABLE : 0;
475 506
476 pnp_register_mem_resource(option, mem); 507 pnp_register_mem_resource(option, mem);
477 return; 508 return;
@@ -479,7 +510,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
479 510
480static void 511static void
481pnpacpi_parse_mem32_option(struct pnp_option *option, 512pnpacpi_parse_mem32_option(struct pnp_option *option,
482 struct acpi_resource_memory32 *p) 513 struct acpi_resource_memory32 *p)
483{ 514{
484 struct pnp_mem *mem; 515 struct pnp_mem *mem;
485 516
@@ -494,7 +525,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
494 mem->size = p->address_length; 525 mem->size = p->address_length;
495 526
496 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 527 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
497 IORESOURCE_MEM_WRITEABLE : 0; 528 IORESOURCE_MEM_WRITEABLE : 0;
498 529
499 pnp_register_mem_resource(option, mem); 530 pnp_register_mem_resource(option, mem);
500 return; 531 return;
@@ -502,7 +533,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
502 533
503static void 534static void
504pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 535pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
505 struct acpi_resource_fixed_memory32 *p) 536 struct acpi_resource_fixed_memory32 *p)
506{ 537{
507 struct pnp_mem *mem; 538 struct pnp_mem *mem;
508 539
@@ -516,7 +547,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
516 mem->align = 0; 547 mem->align = 0;
517 548
518 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 549 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
519 IORESOURCE_MEM_WRITEABLE : 0; 550 IORESOURCE_MEM_WRITEABLE : 0;
520 551
521 pnp_register_mem_resource(option, mem); 552 pnp_register_mem_resource(option, mem);
522 return; 553 return;
@@ -532,7 +563,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
532 563
533 status = acpi_resource_to_address64(r, p); 564 status = acpi_resource_to_address64(r, p);
534 if (!ACPI_SUCCESS(status)) { 565 if (!ACPI_SUCCESS(status)) {
535 pnp_warn("PnPACPI: failed to convert resource type %d", r->type); 566 pnp_warn("PnPACPI: failed to convert resource type %d",
567 r->type);
536 return; 568 return;
537 } 569 }
538 570
@@ -547,7 +579,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
547 mem->size = p->address_length; 579 mem->size = p->address_length;
548 mem->align = 0; 580 mem->align = 0;
549 mem->flags = (p->info.mem.write_protect == 581 mem->flags = (p->info.mem.write_protect ==
550 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; 582 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE
583 : 0;
551 pnp_register_mem_resource(option, mem); 584 pnp_register_mem_resource(option, mem);
552 } else if (p->resource_type == ACPI_IO_RANGE) { 585 } else if (p->resource_type == ACPI_IO_RANGE) {
553 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 586 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
@@ -568,109 +601,108 @@ struct acpipnp_parse_option_s {
568}; 601};
569 602
570static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 603static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
571 void *data) 604 void *data)
572{ 605{
573 int priority = 0; 606 int priority = 0;
574 struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data; 607 struct acpipnp_parse_option_s *parse_data =
608 (struct acpipnp_parse_option_s *)data;
575 struct pnp_dev *dev = parse_data->dev; 609 struct pnp_dev *dev = parse_data->dev;
576 struct pnp_option *option = parse_data->option; 610 struct pnp_option *option = parse_data->option;
577 611
578 switch (res->type) { 612 switch (res->type) {
579 case ACPI_RESOURCE_TYPE_IRQ: 613 case ACPI_RESOURCE_TYPE_IRQ:
580 pnpacpi_parse_irq_option(option, &res->data.irq); 614 pnpacpi_parse_irq_option(option, &res->data.irq);
581 break; 615 break;
582 616
583 case ACPI_RESOURCE_TYPE_DMA: 617 case ACPI_RESOURCE_TYPE_DMA:
584 pnpacpi_parse_dma_option(option, &res->data.dma); 618 pnpacpi_parse_dma_option(option, &res->data.dma);
585 break; 619 break;
586 620
587 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 621 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
588 switch (res->data.start_dpf.compatibility_priority) { 622 switch (res->data.start_dpf.compatibility_priority) {
589 case ACPI_GOOD_CONFIGURATION: 623 case ACPI_GOOD_CONFIGURATION:
590 priority = PNP_RES_PRIORITY_PREFERRED; 624 priority = PNP_RES_PRIORITY_PREFERRED;
591 break;
592
593 case ACPI_ACCEPTABLE_CONFIGURATION:
594 priority = PNP_RES_PRIORITY_ACCEPTABLE;
595 break;
596
597 case ACPI_SUB_OPTIMAL_CONFIGURATION:
598 priority = PNP_RES_PRIORITY_FUNCTIONAL;
599 break;
600 default:
601 priority = PNP_RES_PRIORITY_INVALID;
602 break;
603 }
604 /* TBD: Considering performace/robustness bits */
605 option = pnp_register_dependent_option(dev, priority);
606 if (!option)
607 return AE_ERROR;
608 parse_data->option = option;
609 break; 625 break;
610 626
611 case ACPI_RESOURCE_TYPE_END_DEPENDENT: 627 case ACPI_ACCEPTABLE_CONFIGURATION:
612 /*only one EndDependentFn is allowed*/ 628 priority = PNP_RES_PRIORITY_ACCEPTABLE;
613 if (!parse_data->option_independent) {
614 pnp_warn("PnPACPI: more than one EndDependentFn");
615 return AE_ERROR;
616 }
617 parse_data->option = parse_data->option_independent;
618 parse_data->option_independent = NULL;
619 break; 629 break;
620 630
621 case ACPI_RESOURCE_TYPE_IO: 631 case ACPI_SUB_OPTIMAL_CONFIGURATION:
622 pnpacpi_parse_port_option(option, &res->data.io); 632 priority = PNP_RES_PRIORITY_FUNCTIONAL;
623 break; 633 break;
624 634 default:
625 case ACPI_RESOURCE_TYPE_FIXED_IO: 635 priority = PNP_RES_PRIORITY_INVALID;
626 pnpacpi_parse_fixed_port_option(option,
627 &res->data.fixed_io);
628 break; 636 break;
637 }
638 /* TBD: Considering performace/robustness bits */
639 option = pnp_register_dependent_option(dev, priority);
640 if (!option)
641 return AE_ERROR;
642 parse_data->option = option;
643 break;
629 644
630 case ACPI_RESOURCE_TYPE_VENDOR: 645 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
631 case ACPI_RESOURCE_TYPE_END_TAG: 646 /*only one EndDependentFn is allowed */
632 break; 647 if (!parse_data->option_independent) {
648 pnp_warn("PnPACPI: more than one EndDependentFn");
649 return AE_ERROR;
650 }
651 parse_data->option = parse_data->option_independent;
652 parse_data->option_independent = NULL;
653 break;
633 654
634 case ACPI_RESOURCE_TYPE_MEMORY24: 655 case ACPI_RESOURCE_TYPE_IO:
635 pnpacpi_parse_mem24_option(option, &res->data.memory24); 656 pnpacpi_parse_port_option(option, &res->data.io);
636 break; 657 break;
637 658
638 case ACPI_RESOURCE_TYPE_MEMORY32: 659 case ACPI_RESOURCE_TYPE_FIXED_IO:
639 pnpacpi_parse_mem32_option(option, &res->data.memory32); 660 pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io);
640 break; 661 break;
641 662
642 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 663 case ACPI_RESOURCE_TYPE_VENDOR:
643 pnpacpi_parse_fixed_mem32_option(option, 664 case ACPI_RESOURCE_TYPE_END_TAG:
644 &res->data.fixed_memory32); 665 break;
645 break;
646 666
647 case ACPI_RESOURCE_TYPE_ADDRESS16: 667 case ACPI_RESOURCE_TYPE_MEMORY24:
648 case ACPI_RESOURCE_TYPE_ADDRESS32: 668 pnpacpi_parse_mem24_option(option, &res->data.memory24);
649 case ACPI_RESOURCE_TYPE_ADDRESS64: 669 break;
650 pnpacpi_parse_address_option(option, res);
651 break;
652 670
653 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 671 case ACPI_RESOURCE_TYPE_MEMORY32:
654 break; 672 pnpacpi_parse_mem32_option(option, &res->data.memory32);
673 break;
655 674
656 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 675 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
657 pnpacpi_parse_ext_irq_option(option, 676 pnpacpi_parse_fixed_mem32_option(option,
658 &res->data.extended_irq); 677 &res->data.fixed_memory32);
659 break; 678 break;
660 679
661 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: 680 case ACPI_RESOURCE_TYPE_ADDRESS16:
662 break; 681 case ACPI_RESOURCE_TYPE_ADDRESS32:
682 case ACPI_RESOURCE_TYPE_ADDRESS64:
683 pnpacpi_parse_address_option(option, res);
684 break;
663 685
664 default: 686 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
665 pnp_warn("PnPACPI: unknown resource type %d", res->type); 687 break;
666 return AE_ERROR; 688
689 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
690 pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq);
691 break;
692
693 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
694 break;
695
696 default:
697 pnp_warn("PnPACPI: unknown resource type %d", res->type);
698 return AE_ERROR;
667 } 699 }
668 700
669 return AE_OK; 701 return AE_OK;
670} 702}
671 703
672acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 704acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
673 struct pnp_dev *dev) 705 struct pnp_dev * dev)
674{ 706{
675 acpi_status status; 707 acpi_status status;
676 struct acpipnp_parse_option_s parse_data; 708 struct acpipnp_parse_option_s parse_data;
@@ -681,7 +713,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
681 parse_data.option_independent = parse_data.option; 713 parse_data.option_independent = parse_data.option;
682 parse_data.dev = dev; 714 parse_data.dev = dev;
683 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 715 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
684 pnpacpi_option_resource, &parse_data); 716 pnpacpi_option_resource, &parse_data);
685 717
686 return status; 718 return status;
687} 719}
@@ -709,7 +741,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res)
709 * Set resource 741 * Set resource
710 */ 742 */
711static acpi_status pnpacpi_count_resources(struct acpi_resource *res, 743static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
712 void *data) 744 void *data)
713{ 745{
714 int *res_cnt = (int *)data; 746 int *res_cnt = (int *)data;
715 747
@@ -732,14 +764,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
732} 764}
733 765
734int pnpacpi_build_resource_template(acpi_handle handle, 766int pnpacpi_build_resource_template(acpi_handle handle,
735 struct acpi_buffer *buffer) 767 struct acpi_buffer *buffer)
736{ 768{
737 struct acpi_resource *resource; 769 struct acpi_resource *resource;
738 int res_cnt = 0; 770 int res_cnt = 0;
739 acpi_status status; 771 acpi_status status;
740 772
741 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 773 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
742 pnpacpi_count_resources, &res_cnt); 774 pnpacpi_count_resources, &res_cnt);
743 if (ACPI_FAILURE(status)) { 775 if (ACPI_FAILURE(status)) {
744 pnp_err("Evaluate _CRS failed"); 776 pnp_err("Evaluate _CRS failed");
745 return -EINVAL; 777 return -EINVAL;
@@ -753,7 +785,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
753 pnp_dbg("Res cnt %d", res_cnt); 785 pnp_dbg("Res cnt %d", res_cnt);
754 resource = (struct acpi_resource *)buffer->pointer; 786 resource = (struct acpi_resource *)buffer->pointer;
755 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 787 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
756 pnpacpi_type_resources, &resource); 788 pnpacpi_type_resources, &resource);
757 if (ACPI_FAILURE(status)) { 789 if (ACPI_FAILURE(status)) {
758 kfree(buffer->pointer); 790 kfree(buffer->pointer);
759 pnp_err("Evaluate _CRS failed"); 791 pnp_err("Evaluate _CRS failed");
@@ -766,7 +798,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
766} 798}
767 799
768static void pnpacpi_encode_irq(struct acpi_resource *resource, 800static void pnpacpi_encode_irq(struct acpi_resource *resource,
769 struct resource *p) 801 struct resource *p)
770{ 802{
771 int triggering, polarity; 803 int triggering, polarity;
772 804
@@ -782,7 +814,7 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource,
782} 814}
783 815
784static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 816static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
785 struct resource *p) 817 struct resource *p)
786{ 818{
787 int triggering, polarity; 819 int triggering, polarity;
788 820
@@ -799,32 +831,32 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
799} 831}
800 832
801static void pnpacpi_encode_dma(struct acpi_resource *resource, 833static void pnpacpi_encode_dma(struct acpi_resource *resource,
802 struct resource *p) 834 struct resource *p)
803{ 835{
804 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 836 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
805 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { 837 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
806 case IORESOURCE_DMA_TYPEA: 838 case IORESOURCE_DMA_TYPEA:
807 resource->data.dma.type = ACPI_TYPE_A; 839 resource->data.dma.type = ACPI_TYPE_A;
808 break; 840 break;
809 case IORESOURCE_DMA_TYPEB: 841 case IORESOURCE_DMA_TYPEB:
810 resource->data.dma.type = ACPI_TYPE_B; 842 resource->data.dma.type = ACPI_TYPE_B;
811 break; 843 break;
812 case IORESOURCE_DMA_TYPEF: 844 case IORESOURCE_DMA_TYPEF:
813 resource->data.dma.type = ACPI_TYPE_F; 845 resource->data.dma.type = ACPI_TYPE_F;
814 break; 846 break;
815 default: 847 default:
816 resource->data.dma.type = ACPI_COMPATIBILITY; 848 resource->data.dma.type = ACPI_COMPATIBILITY;
817 } 849 }
818 850
819 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { 851 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
820 case IORESOURCE_DMA_8BIT: 852 case IORESOURCE_DMA_8BIT:
821 resource->data.dma.transfer = ACPI_TRANSFER_8; 853 resource->data.dma.transfer = ACPI_TRANSFER_8;
822 break; 854 break;
823 case IORESOURCE_DMA_8AND16BIT: 855 case IORESOURCE_DMA_8AND16BIT:
824 resource->data.dma.transfer = ACPI_TRANSFER_8_16; 856 resource->data.dma.transfer = ACPI_TRANSFER_8_16;
825 break; 857 break;
826 default: 858 default:
827 resource->data.dma.transfer = ACPI_TRANSFER_16; 859 resource->data.dma.transfer = ACPI_TRANSFER_16;
828 } 860 }
829 861
830 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); 862 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
@@ -833,31 +865,31 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
833} 865}
834 866
835static void pnpacpi_encode_io(struct acpi_resource *resource, 867static void pnpacpi_encode_io(struct acpi_resource *resource,
836 struct resource *p) 868 struct resource *p)
837{ 869{
838 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 870 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
839 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 871 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
840 ACPI_DECODE_16 : ACPI_DECODE_10; 872 ACPI_DECODE_16 : ACPI_DECODE_10;
841 resource->data.io.minimum = p->start; 873 resource->data.io.minimum = p->start;
842 resource->data.io.maximum = p->end; 874 resource->data.io.maximum = p->end;
843 resource->data.io.alignment = 0; /* Correct? */ 875 resource->data.io.alignment = 0; /* Correct? */
844 resource->data.io.address_length = p->end - p->start + 1; 876 resource->data.io.address_length = p->end - p->start + 1;
845} 877}
846 878
847static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 879static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
848 struct resource *p) 880 struct resource *p)
849{ 881{
850 resource->data.fixed_io.address = p->start; 882 resource->data.fixed_io.address = p->start;
851 resource->data.fixed_io.address_length = p->end - p->start + 1; 883 resource->data.fixed_io.address_length = p->end - p->start + 1;
852} 884}
853 885
854static void pnpacpi_encode_mem24(struct acpi_resource *resource, 886static void pnpacpi_encode_mem24(struct acpi_resource *resource,
855 struct resource *p) 887 struct resource *p)
856{ 888{
857 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 889 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
858 resource->data.memory24.write_protect = 890 resource->data.memory24.write_protect =
859 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 891 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
860 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 892 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
861 resource->data.memory24.minimum = p->start; 893 resource->data.memory24.minimum = p->start;
862 resource->data.memory24.maximum = p->end; 894 resource->data.memory24.maximum = p->end;
863 resource->data.memory24.alignment = 0; 895 resource->data.memory24.alignment = 0;
@@ -865,11 +897,11 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource,
865} 897}
866 898
867static void pnpacpi_encode_mem32(struct acpi_resource *resource, 899static void pnpacpi_encode_mem32(struct acpi_resource *resource,
868 struct resource *p) 900 struct resource *p)
869{ 901{
870 resource->data.memory32.write_protect = 902 resource->data.memory32.write_protect =
871 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 903 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
872 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 904 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
873 resource->data.memory32.minimum = p->start; 905 resource->data.memory32.minimum = p->start;
874 resource->data.memory32.maximum = p->end; 906 resource->data.memory32.maximum = p->end;
875 resource->data.memory32.alignment = 0; 907 resource->data.memory32.alignment = 0;
@@ -877,74 +909,77 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource,
877} 909}
878 910
879static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 911static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
880 struct resource *p) 912 struct resource *p)
881{ 913{
882 resource->data.fixed_memory32.write_protect = 914 resource->data.fixed_memory32.write_protect =
883 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 915 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
884 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 916 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
885 resource->data.fixed_memory32.address = p->start; 917 resource->data.fixed_memory32.address = p->start;
886 resource->data.fixed_memory32.address_length = p->end - p->start + 1; 918 resource->data.fixed_memory32.address_length = p->end - p->start + 1;
887} 919}
888 920
889int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 921int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
890 struct acpi_buffer *buffer) 922 struct acpi_buffer *buffer)
891{ 923{
892 int i = 0; 924 int i = 0;
893 /* pnpacpi_build_resource_template allocates extra mem */ 925 /* pnpacpi_build_resource_template allocates extra mem */
894 int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1; 926 int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
895 struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer; 927 struct acpi_resource *resource =
928 (struct acpi_resource *)buffer->pointer;
896 int port = 0, irq = 0, dma = 0, mem = 0; 929 int port = 0, irq = 0, dma = 0, mem = 0;
897 930
898 pnp_dbg("res cnt %d", res_cnt); 931 pnp_dbg("res cnt %d", res_cnt);
899 while (i < res_cnt) { 932 while (i < res_cnt) {
900 switch(resource->type) { 933 switch (resource->type) {
901 case ACPI_RESOURCE_TYPE_IRQ: 934 case ACPI_RESOURCE_TYPE_IRQ:
902 pnp_dbg("Encode irq"); 935 pnp_dbg("Encode irq");
903 pnpacpi_encode_irq(resource, 936 pnpacpi_encode_irq(resource,
904 &res_table->irq_resource[irq]); 937 &res_table->irq_resource[irq]);
905 irq++; 938 irq++;
906 break; 939 break;
907 940
908 case ACPI_RESOURCE_TYPE_DMA: 941 case ACPI_RESOURCE_TYPE_DMA:
909 pnp_dbg("Encode dma"); 942 pnp_dbg("Encode dma");
910 pnpacpi_encode_dma(resource, 943 pnpacpi_encode_dma(resource,
911 &res_table->dma_resource[dma]); 944 &res_table->dma_resource[dma]);
912 dma++; 945 dma++;
913 break; 946 break;
914 case ACPI_RESOURCE_TYPE_IO: 947 case ACPI_RESOURCE_TYPE_IO:
915 pnp_dbg("Encode io"); 948 pnp_dbg("Encode io");
916 pnpacpi_encode_io(resource, 949 pnpacpi_encode_io(resource,
917 &res_table->port_resource[port]); 950 &res_table->port_resource[port]);
918 port++; 951 port++;
919 break; 952 break;
920 case ACPI_RESOURCE_TYPE_FIXED_IO: 953 case ACPI_RESOURCE_TYPE_FIXED_IO:
921 pnp_dbg("Encode fixed io"); 954 pnp_dbg("Encode fixed io");
922 pnpacpi_encode_fixed_io(resource, 955 pnpacpi_encode_fixed_io(resource,
923 &res_table->port_resource[port]); 956 &res_table->
957 port_resource[port]);
924 port++; 958 port++;
925 break; 959 break;
926 case ACPI_RESOURCE_TYPE_MEMORY24: 960 case ACPI_RESOURCE_TYPE_MEMORY24:
927 pnp_dbg("Encode mem24"); 961 pnp_dbg("Encode mem24");
928 pnpacpi_encode_mem24(resource, 962 pnpacpi_encode_mem24(resource,
929 &res_table->mem_resource[mem]); 963 &res_table->mem_resource[mem]);
930 mem++; 964 mem++;
931 break; 965 break;
932 case ACPI_RESOURCE_TYPE_MEMORY32: 966 case ACPI_RESOURCE_TYPE_MEMORY32:
933 pnp_dbg("Encode mem32"); 967 pnp_dbg("Encode mem32");
934 pnpacpi_encode_mem32(resource, 968 pnpacpi_encode_mem32(resource,
935 &res_table->mem_resource[mem]); 969 &res_table->mem_resource[mem]);
936 mem++; 970 mem++;
937 break; 971 break;
938 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 972 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
939 pnp_dbg("Encode fixed mem32"); 973 pnp_dbg("Encode fixed mem32");
940 pnpacpi_encode_fixed_mem32(resource, 974 pnpacpi_encode_fixed_mem32(resource,
941 &res_table->mem_resource[mem]); 975 &res_table->
976 mem_resource[mem]);
942 mem++; 977 mem++;
943 break; 978 break;
944 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 979 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
945 pnp_dbg("Encode ext irq"); 980 pnp_dbg("Encode ext irq");
946 pnpacpi_encode_ext_irq(resource, 981 pnpacpi_encode_ext_irq(resource,
947 &res_table->irq_resource[irq]); 982 &res_table->irq_resource[irq]);
948 irq++; 983 irq++;
949 break; 984 break;
950 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 985 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -956,7 +991,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
956 case ACPI_RESOURCE_TYPE_ADDRESS64: 991 case ACPI_RESOURCE_TYPE_ADDRESS64:
957 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 992 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
958 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: 993 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
959 default: /* other type */ 994 default: /* other type */
960 pnp_warn("unknown resource type %d", resource->type); 995 pnp_warn("unknown resource type %d", resource->type);
961 return -EINVAL; 996 return -EINVAL;
962 } 997 }