diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:34:06 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:21 -0400 |
commit | 4ab55d8d4f7b910c4c60e0f8ff70d0dfdd484f02 (patch) | |
tree | 7ae1fd11249b844b7ae53faff5ee2906a6a796c2 /drivers/pnp/pnpacpi | |
parent | 59284cb4099411bc6f4915a5a4cb76414440c447 (diff) |
PNP: remove more pnp_resource_table arguments
Stop passing around struct pnp_resource_table pointers. In most cases,
the caller doesn't need to know how the resources are stored inside
the struct pnp_dev.
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>
Diffstat (limited to 'drivers/pnp/pnpacpi')
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 11 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/pnpacpi.h | 6 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 55 |
3 files changed, 37 insertions, 35 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 590fbcb0ee89..3fd2416d6795 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -77,8 +77,7 @@ static int pnpacpi_get_resources(struct pnp_dev *dev) | |||
77 | { | 77 | { |
78 | acpi_status status; | 78 | acpi_status status; |
79 | 79 | ||
80 | status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data, | 80 | status = pnpacpi_parse_allocated_resource(dev); |
81 | &dev->res); | ||
82 | return ACPI_FAILURE(status) ? -ENODEV : 0; | 81 | return ACPI_FAILURE(status) ? -ENODEV : 0; |
83 | } | 82 | } |
84 | 83 | ||
@@ -92,7 +91,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) | |||
92 | ret = pnpacpi_build_resource_template(dev, &buffer); | 91 | ret = pnpacpi_build_resource_template(dev, &buffer); |
93 | if (ret) | 92 | if (ret) |
94 | return ret; | 93 | return ret; |
95 | ret = pnpacpi_encode_resources(&dev->res, &buffer); | 94 | ret = pnpacpi_encode_resources(dev, &buffer); |
96 | if (ret) { | 95 | if (ret) { |
97 | kfree(buffer.pointer); | 96 | kfree(buffer.pointer); |
98 | return ret; | 97 | return ret; |
@@ -183,8 +182,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
183 | 182 | ||
184 | if (dev->active) { | 183 | if (dev->active) { |
185 | /* parse allocated resource */ | 184 | /* parse allocated resource */ |
186 | status = pnpacpi_parse_allocated_resource(device->handle, | 185 | status = pnpacpi_parse_allocated_resource(dev); |
187 | &dev->res); | ||
188 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { | 186 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { |
189 | pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", | 187 | pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", |
190 | acpi_device_hid(device)); | 188 | acpi_device_hid(device)); |
@@ -192,8 +190,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
192 | } | 190 | } |
193 | 191 | ||
194 | if (dev->capabilities & PNP_CONFIGURABLE) { | 192 | if (dev->capabilities & PNP_CONFIGURABLE) { |
195 | status = pnpacpi_parse_resource_option_data(device->handle, | 193 | status = pnpacpi_parse_resource_option_data(dev); |
196 | dev); | ||
197 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { | 194 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { |
198 | pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", | 195 | pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", |
199 | acpi_device_hid(device)); | 196 | acpi_device_hid(device)); |
diff --git a/drivers/pnp/pnpacpi/pnpacpi.h b/drivers/pnp/pnpacpi/pnpacpi.h index 116c591d8634..db0c4f25c2a3 100644 --- a/drivers/pnp/pnpacpi/pnpacpi.h +++ b/drivers/pnp/pnpacpi/pnpacpi.h | |||
@@ -5,8 +5,8 @@ | |||
5 | #include <linux/acpi.h> | 5 | #include <linux/acpi.h> |
6 | #include <linux/pnp.h> | 6 | #include <linux/pnp.h> |
7 | 7 | ||
8 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*); | 8 | acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *); |
9 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*); | 9 | acpi_status pnpacpi_parse_resource_option_data(struct pnp_dev *); |
10 | int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *); | 10 | int pnpacpi_encode_resources(struct pnp_dev *, struct acpi_buffer *); |
11 | int pnpacpi_build_resource_template(struct pnp_dev *, struct acpi_buffer *); | 11 | int pnpacpi_build_resource_template(struct pnp_dev *, struct acpi_buffer *); |
12 | #endif | 12 | #endif |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 32454aa07ebc..8a0617687723 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -76,10 +76,11 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity) | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, | 79 | static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, |
80 | u32 gsi, int triggering, | 80 | u32 gsi, int triggering, |
81 | int polarity, int shareable) | 81 | int polarity, int shareable) |
82 | { | 82 | { |
83 | struct pnp_resource_table *res = &dev->res; | ||
83 | int i = 0; | 84 | int i = 0; |
84 | int irq; | 85 | int irq; |
85 | int p, t; | 86 | int p, t; |
@@ -172,9 +173,10 @@ static int dma_flags(int type, int bus_master, int transfer) | |||
172 | return flags; | 173 | return flags; |
173 | } | 174 | } |
174 | 175 | ||
175 | static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, | 176 | static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, |
176 | u32 dma, int flags) | 177 | u32 dma, int flags) |
177 | { | 178 | { |
179 | struct pnp_resource_table *res = &dev->res; | ||
178 | int i = 0; | 180 | int i = 0; |
179 | static unsigned char warned; | 181 | static unsigned char warned; |
180 | 182 | ||
@@ -197,9 +199,10 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, | |||
197 | } | 199 | } |
198 | } | 200 | } |
199 | 201 | ||
200 | static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | 202 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, |
201 | u64 io, u64 len, int io_decode) | 203 | u64 io, u64 len, int io_decode) |
202 | { | 204 | { |
205 | struct pnp_resource_table *res = &dev->res; | ||
203 | int i = 0; | 206 | int i = 0; |
204 | static unsigned char warned; | 207 | static unsigned char warned; |
205 | 208 | ||
@@ -223,10 +226,11 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | |||
223 | } | 226 | } |
224 | } | 227 | } |
225 | 228 | ||
226 | static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | 229 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, |
227 | u64 mem, u64 len, | 230 | u64 mem, u64 len, |
228 | int write_protect) | 231 | int write_protect) |
229 | { | 232 | { |
233 | struct pnp_resource_table *res = &dev->res; | ||
230 | int i = 0; | 234 | int i = 0; |
231 | static unsigned char warned; | 235 | static unsigned char warned; |
232 | 236 | ||
@@ -251,7 +255,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | |||
251 | } | 255 | } |
252 | } | 256 | } |
253 | 257 | ||
254 | static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | 258 | static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, |
255 | struct acpi_resource *res) | 259 | struct acpi_resource *res) |
256 | { | 260 | { |
257 | struct acpi_resource_address64 addr, *p = &addr; | 261 | struct acpi_resource_address64 addr, *p = &addr; |
@@ -268,11 +272,11 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res | |||
268 | return; | 272 | return; |
269 | 273 | ||
270 | if (p->resource_type == ACPI_MEMORY_RANGE) | 274 | if (p->resource_type == ACPI_MEMORY_RANGE) |
271 | pnpacpi_parse_allocated_memresource(res_table, | 275 | pnpacpi_parse_allocated_memresource(dev, |
272 | p->minimum, p->address_length, | 276 | p->minimum, p->address_length, |
273 | p->info.mem.write_protect); | 277 | p->info.mem.write_protect); |
274 | else if (p->resource_type == ACPI_IO_RANGE) | 278 | else if (p->resource_type == ACPI_IO_RANGE) |
275 | pnpacpi_parse_allocated_ioresource(res_table, | 279 | pnpacpi_parse_allocated_ioresource(dev, |
276 | p->minimum, p->address_length, | 280 | p->minimum, p->address_length, |
277 | p->granularity == 0xfff ? ACPI_DECODE_10 : | 281 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
278 | ACPI_DECODE_16); | 282 | ACPI_DECODE_16); |
@@ -281,7 +285,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res | |||
281 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | 285 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
282 | void *data) | 286 | void *data) |
283 | { | 287 | { |
284 | struct pnp_resource_table *res_table = data; | 288 | struct pnp_dev *dev = data; |
285 | struct acpi_resource_irq *irq; | 289 | struct acpi_resource_irq *irq; |
286 | struct acpi_resource_dma *dma; | 290 | struct acpi_resource_dma *dma; |
287 | struct acpi_resource_io *io; | 291 | struct acpi_resource_io *io; |
@@ -300,7 +304,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
300 | */ | 304 | */ |
301 | irq = &res->data.irq; | 305 | irq = &res->data.irq; |
302 | for (i = 0; i < irq->interrupt_count; i++) { | 306 | for (i = 0; i < irq->interrupt_count; i++) { |
303 | pnpacpi_parse_allocated_irqresource(res_table, | 307 | pnpacpi_parse_allocated_irqresource(dev, |
304 | irq->interrupts[i], | 308 | irq->interrupts[i], |
305 | irq->triggering, | 309 | irq->triggering, |
306 | irq->polarity, | 310 | irq->polarity, |
@@ -311,7 +315,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
311 | case ACPI_RESOURCE_TYPE_DMA: | 315 | case ACPI_RESOURCE_TYPE_DMA: |
312 | dma = &res->data.dma; | 316 | dma = &res->data.dma; |
313 | if (dma->channel_count > 0) | 317 | if (dma->channel_count > 0) |
314 | pnpacpi_parse_allocated_dmaresource(res_table, | 318 | pnpacpi_parse_allocated_dmaresource(dev, |
315 | dma->channels[0], | 319 | dma->channels[0], |
316 | dma_flags(dma->type, dma->bus_master, | 320 | dma_flags(dma->type, dma->bus_master, |
317 | dma->transfer)); | 321 | dma->transfer)); |
@@ -319,7 +323,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
319 | 323 | ||
320 | case ACPI_RESOURCE_TYPE_IO: | 324 | case ACPI_RESOURCE_TYPE_IO: |
321 | io = &res->data.io; | 325 | io = &res->data.io; |
322 | pnpacpi_parse_allocated_ioresource(res_table, | 326 | pnpacpi_parse_allocated_ioresource(dev, |
323 | io->minimum, | 327 | io->minimum, |
324 | io->address_length, | 328 | io->address_length, |
325 | io->io_decode); | 329 | io->io_decode); |
@@ -331,7 +335,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
331 | 335 | ||
332 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 336 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
333 | fixed_io = &res->data.fixed_io; | 337 | fixed_io = &res->data.fixed_io; |
334 | pnpacpi_parse_allocated_ioresource(res_table, | 338 | pnpacpi_parse_allocated_ioresource(dev, |
335 | fixed_io->address, | 339 | fixed_io->address, |
336 | fixed_io->address_length, | 340 | fixed_io->address_length, |
337 | ACPI_DECODE_10); | 341 | ACPI_DECODE_10); |
@@ -345,21 +349,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
345 | 349 | ||
346 | case ACPI_RESOURCE_TYPE_MEMORY24: | 350 | case ACPI_RESOURCE_TYPE_MEMORY24: |
347 | memory24 = &res->data.memory24; | 351 | memory24 = &res->data.memory24; |
348 | pnpacpi_parse_allocated_memresource(res_table, | 352 | pnpacpi_parse_allocated_memresource(dev, |
349 | memory24->minimum, | 353 | memory24->minimum, |
350 | memory24->address_length, | 354 | memory24->address_length, |
351 | memory24->write_protect); | 355 | memory24->write_protect); |
352 | break; | 356 | break; |
353 | case ACPI_RESOURCE_TYPE_MEMORY32: | 357 | case ACPI_RESOURCE_TYPE_MEMORY32: |
354 | memory32 = &res->data.memory32; | 358 | memory32 = &res->data.memory32; |
355 | pnpacpi_parse_allocated_memresource(res_table, | 359 | pnpacpi_parse_allocated_memresource(dev, |
356 | memory32->minimum, | 360 | memory32->minimum, |
357 | memory32->address_length, | 361 | memory32->address_length, |
358 | memory32->write_protect); | 362 | memory32->write_protect); |
359 | break; | 363 | break; |
360 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 364 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
361 | fixed_memory32 = &res->data.fixed_memory32; | 365 | fixed_memory32 = &res->data.fixed_memory32; |
362 | pnpacpi_parse_allocated_memresource(res_table, | 366 | pnpacpi_parse_allocated_memresource(dev, |
363 | fixed_memory32->address, | 367 | fixed_memory32->address, |
364 | fixed_memory32->address_length, | 368 | fixed_memory32->address_length, |
365 | fixed_memory32->write_protect); | 369 | fixed_memory32->write_protect); |
@@ -367,7 +371,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
367 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 371 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
368 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 372 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
369 | case ACPI_RESOURCE_TYPE_ADDRESS64: | 373 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
370 | pnpacpi_parse_allocated_address_space(res_table, res); | 374 | pnpacpi_parse_allocated_address_space(dev, res); |
371 | break; | 375 | break; |
372 | 376 | ||
373 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: | 377 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
@@ -381,7 +385,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
381 | return AE_OK; | 385 | return AE_OK; |
382 | 386 | ||
383 | for (i = 0; i < extended_irq->interrupt_count; i++) { | 387 | for (i = 0; i < extended_irq->interrupt_count; i++) { |
384 | pnpacpi_parse_allocated_irqresource(res_table, | 388 | pnpacpi_parse_allocated_irqresource(dev, |
385 | extended_irq->interrupts[i], | 389 | extended_irq->interrupts[i], |
386 | extended_irq->triggering, | 390 | extended_irq->triggering, |
387 | extended_irq->polarity, | 391 | extended_irq->polarity, |
@@ -400,14 +404,15 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
400 | return AE_OK; | 404 | return AE_OK; |
401 | } | 405 | } |
402 | 406 | ||
403 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, | 407 | acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *dev) |
404 | struct pnp_resource_table * res) | ||
405 | { | 408 | { |
409 | acpi_handle handle = dev->data; | ||
410 | |||
406 | /* Blank the resource table values */ | 411 | /* Blank the resource table values */ |
407 | pnp_init_resource_table(res); | 412 | pnp_init_resource_table(&dev->res); |
408 | 413 | ||
409 | return acpi_walk_resources(handle, METHOD_NAME__CRS, | 414 | return acpi_walk_resources(handle, METHOD_NAME__CRS, |
410 | pnpacpi_allocated_resource, res); | 415 | pnpacpi_allocated_resource, dev); |
411 | } | 416 | } |
412 | 417 | ||
413 | static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, | 418 | static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, |
@@ -727,9 +732,9 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, | |||
727 | return AE_OK; | 732 | return AE_OK; |
728 | } | 733 | } |
729 | 734 | ||
730 | acpi_status __init pnpacpi_parse_resource_option_data(acpi_handle handle, | 735 | acpi_status __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) |
731 | struct pnp_dev *dev) | ||
732 | { | 736 | { |
737 | acpi_handle handle = dev->data; | ||
733 | acpi_status status; | 738 | acpi_status status; |
734 | struct acpipnp_parse_option_s parse_data; | 739 | struct acpipnp_parse_option_s parse_data; |
735 | 740 | ||
@@ -959,9 +964,9 @@ static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, | |||
959 | fixed_memory32->address_length = p->end - p->start + 1; | 964 | fixed_memory32->address_length = p->end - p->start + 1; |
960 | } | 965 | } |
961 | 966 | ||
962 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, | 967 | int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) |
963 | struct acpi_buffer *buffer) | ||
964 | { | 968 | { |
969 | struct pnp_resource_table *res_table = &dev->res; | ||
965 | int i = 0; | 970 | int i = 0; |
966 | /* pnpacpi_build_resource_template allocates extra mem */ | 971 | /* pnpacpi_build_resource_template allocates extra mem */ |
967 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; | 972 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |