diff options
Diffstat (limited to 'drivers/pnp/resource.c')
-rw-r--r-- | drivers/pnp/resource.c | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index a685fbec4604..635b11a0cf82 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c | |||
@@ -20,17 +20,16 @@ | |||
20 | #include <linux/pnp.h> | 20 | #include <linux/pnp.h> |
21 | #include "base.h" | 21 | #include "base.h" |
22 | 22 | ||
23 | static int pnp_reserve_irq[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some IRQ */ | 23 | static int pnp_reserve_irq[16] = {[0...15] = -1 }; /* reserve (don't use) some IRQ */ |
24 | static int pnp_reserve_dma[8] = { [0 ... 7] = -1 }; /* reserve (don't use) some DMA */ | 24 | static int pnp_reserve_dma[8] = {[0...7] = -1 }; /* reserve (don't use) some DMA */ |
25 | static int pnp_reserve_io[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some I/O region */ | 25 | static int pnp_reserve_io[16] = {[0...15] = -1 }; /* reserve (don't use) some I/O region */ |
26 | static int pnp_reserve_mem[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some memory region */ | 26 | static int pnp_reserve_mem[16] = {[0...15] = -1 }; /* reserve (don't use) some memory region */ |
27 | |||
28 | 27 | ||
29 | /* | 28 | /* |
30 | * option registration | 29 | * option registration |
31 | */ | 30 | */ |
32 | 31 | ||
33 | static struct pnp_option * pnp_build_option(int priority) | 32 | static struct pnp_option *pnp_build_option(int priority) |
34 | { | 33 | { |
35 | struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); | 34 | struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); |
36 | 35 | ||
@@ -46,7 +45,7 @@ static struct pnp_option * pnp_build_option(int priority) | |||
46 | return option; | 45 | return option; |
47 | } | 46 | } |
48 | 47 | ||
49 | struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) | 48 | struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) |
50 | { | 49 | { |
51 | struct pnp_option *option; | 50 | struct pnp_option *option; |
52 | if (!dev) | 51 | if (!dev) |
@@ -61,7 +60,8 @@ struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) | |||
61 | return option; | 60 | return option; |
62 | } | 61 | } |
63 | 62 | ||
64 | struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) | 63 | struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, |
64 | int priority) | ||
65 | { | 65 | { |
66 | struct pnp_option *option; | 66 | struct pnp_option *option; |
67 | if (!dev) | 67 | if (!dev) |
@@ -222,7 +222,6 @@ void pnp_free_option(struct pnp_option *option) | |||
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | |||
226 | /* | 225 | /* |
227 | * resource validity checking | 226 | * resource validity checking |
228 | */ | 227 | */ |
@@ -236,7 +235,7 @@ void pnp_free_option(struct pnp_option *option) | |||
236 | #define cannot_compare(flags) \ | 235 | #define cannot_compare(flags) \ |
237 | ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) | 236 | ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) |
238 | 237 | ||
239 | int pnp_check_port(struct pnp_dev * dev, int idx) | 238 | int pnp_check_port(struct pnp_dev *dev, int idx) |
240 | { | 239 | { |
241 | int tmp; | 240 | int tmp; |
242 | struct pnp_dev *tdev; | 241 | struct pnp_dev *tdev; |
@@ -250,8 +249,8 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
250 | 249 | ||
251 | /* check if the resource is already in use, skip if the | 250 | /* check if the resource is already in use, skip if the |
252 | * device is active because it itself may be in use */ | 251 | * device is active because it itself may be in use */ |
253 | if(!dev->active) { | 252 | if (!dev->active) { |
254 | if (__check_region(&ioport_resource, *port, length(port,end))) | 253 | if (__check_region(&ioport_resource, *port, length(port, end))) |
255 | return 0; | 254 | return 0; |
256 | } | 255 | } |
257 | 256 | ||
@@ -259,7 +258,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
259 | for (tmp = 0; tmp < 8; tmp++) { | 258 | for (tmp = 0; tmp < 8; tmp++) { |
260 | int rport = pnp_reserve_io[tmp << 1]; | 259 | int rport = pnp_reserve_io[tmp << 1]; |
261 | int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1; | 260 | int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1; |
262 | if (ranged_conflict(port,end,&rport,&rend)) | 261 | if (ranged_conflict(port, end, &rport, &rend)) |
263 | return 0; | 262 | return 0; |
264 | } | 263 | } |
265 | 264 | ||
@@ -268,7 +267,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
268 | if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) { | 267 | if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) { |
269 | tport = &dev->res.port_resource[tmp].start; | 268 | tport = &dev->res.port_resource[tmp].start; |
270 | tend = &dev->res.port_resource[tmp].end; | 269 | tend = &dev->res.port_resource[tmp].end; |
271 | if (ranged_conflict(port,end,tport,tend)) | 270 | if (ranged_conflict(port, end, tport, tend)) |
272 | return 0; | 271 | return 0; |
273 | } | 272 | } |
274 | } | 273 | } |
@@ -279,11 +278,12 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
279 | continue; | 278 | continue; |
280 | for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { | 279 | for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { |
281 | if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) { | 280 | if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) { |
282 | if (cannot_compare(tdev->res.port_resource[tmp].flags)) | 281 | if (cannot_compare |
282 | (tdev->res.port_resource[tmp].flags)) | ||
283 | continue; | 283 | continue; |
284 | tport = &tdev->res.port_resource[tmp].start; | 284 | tport = &tdev->res.port_resource[tmp].start; |
285 | tend = &tdev->res.port_resource[tmp].end; | 285 | tend = &tdev->res.port_resource[tmp].end; |
286 | if (ranged_conflict(port,end,tport,tend)) | 286 | if (ranged_conflict(port, end, tport, tend)) |
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
289 | } | 289 | } |
@@ -292,7 +292,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
292 | return 1; | 292 | return 1; |
293 | } | 293 | } |
294 | 294 | ||
295 | int pnp_check_mem(struct pnp_dev * dev, int idx) | 295 | int pnp_check_mem(struct pnp_dev *dev, int idx) |
296 | { | 296 | { |
297 | int tmp; | 297 | int tmp; |
298 | struct pnp_dev *tdev; | 298 | struct pnp_dev *tdev; |
@@ -306,8 +306,8 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
306 | 306 | ||
307 | /* check if the resource is already in use, skip if the | 307 | /* check if the resource is already in use, skip if the |
308 | * device is active because it itself may be in use */ | 308 | * device is active because it itself may be in use */ |
309 | if(!dev->active) { | 309 | if (!dev->active) { |
310 | if (check_mem_region(*addr, length(addr,end))) | 310 | if (check_mem_region(*addr, length(addr, end))) |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | 313 | ||
@@ -315,7 +315,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
315 | for (tmp = 0; tmp < 8; tmp++) { | 315 | for (tmp = 0; tmp < 8; tmp++) { |
316 | int raddr = pnp_reserve_mem[tmp << 1]; | 316 | int raddr = pnp_reserve_mem[tmp << 1]; |
317 | int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1; | 317 | int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1; |
318 | if (ranged_conflict(addr,end,&raddr,&rend)) | 318 | if (ranged_conflict(addr, end, &raddr, &rend)) |
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
@@ -324,7 +324,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
324 | if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { | 324 | if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { |
325 | taddr = &dev->res.mem_resource[tmp].start; | 325 | taddr = &dev->res.mem_resource[tmp].start; |
326 | tend = &dev->res.mem_resource[tmp].end; | 326 | tend = &dev->res.mem_resource[tmp].end; |
327 | if (ranged_conflict(addr,end,taddr,tend)) | 327 | if (ranged_conflict(addr, end, taddr, tend)) |
328 | return 0; | 328 | return 0; |
329 | } | 329 | } |
330 | } | 330 | } |
@@ -335,11 +335,12 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
335 | continue; | 335 | continue; |
336 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { | 336 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { |
337 | if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { | 337 | if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { |
338 | if (cannot_compare(tdev->res.mem_resource[tmp].flags)) | 338 | if (cannot_compare |
339 | (tdev->res.mem_resource[tmp].flags)) | ||
339 | continue; | 340 | continue; |
340 | taddr = &tdev->res.mem_resource[tmp].start; | 341 | taddr = &tdev->res.mem_resource[tmp].start; |
341 | tend = &tdev->res.mem_resource[tmp].end; | 342 | tend = &tdev->res.mem_resource[tmp].end; |
342 | if (ranged_conflict(addr,end,taddr,tend)) | 343 | if (ranged_conflict(addr, end, taddr, tend)) |
343 | return 0; | 344 | return 0; |
344 | } | 345 | } |
345 | } | 346 | } |
@@ -353,11 +354,11 @@ static irqreturn_t pnp_test_handler(int irq, void *dev_id) | |||
353 | return IRQ_HANDLED; | 354 | return IRQ_HANDLED; |
354 | } | 355 | } |
355 | 356 | ||
356 | int pnp_check_irq(struct pnp_dev * dev, int idx) | 357 | int pnp_check_irq(struct pnp_dev *dev, int idx) |
357 | { | 358 | { |
358 | int tmp; | 359 | int tmp; |
359 | struct pnp_dev *tdev; | 360 | struct pnp_dev *tdev; |
360 | resource_size_t * irq = &dev->res.irq_resource[idx].start; | 361 | resource_size_t *irq = &dev->res.irq_resource[idx].start; |
361 | 362 | ||
362 | /* if the resource doesn't exist, don't complain about it */ | 363 | /* if the resource doesn't exist, don't complain about it */ |
363 | if (cannot_compare(dev->res.irq_resource[idx].flags)) | 364 | if (cannot_compare(dev->res.irq_resource[idx].flags)) |
@@ -394,9 +395,9 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
394 | 395 | ||
395 | /* check if the resource is already in use, skip if the | 396 | /* check if the resource is already in use, skip if the |
396 | * device is active because it itself may be in use */ | 397 | * device is active because it itself may be in use */ |
397 | if(!dev->active) { | 398 | if (!dev->active) { |
398 | if (request_irq(*irq, pnp_test_handler, | 399 | if (request_irq(*irq, pnp_test_handler, |
399 | IRQF_DISABLED|IRQF_PROBE_SHARED, "pnp", NULL)) | 400 | IRQF_DISABLED | IRQF_PROBE_SHARED, "pnp", NULL)) |
400 | return 0; | 401 | return 0; |
401 | free_irq(*irq, NULL); | 402 | free_irq(*irq, NULL); |
402 | } | 403 | } |
@@ -407,7 +408,8 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
407 | continue; | 408 | continue; |
408 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { | 409 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { |
409 | if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) { | 410 | if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) { |
410 | if (cannot_compare(tdev->res.irq_resource[tmp].flags)) | 411 | if (cannot_compare |
412 | (tdev->res.irq_resource[tmp].flags)) | ||
411 | continue; | 413 | continue; |
412 | if ((tdev->res.irq_resource[tmp].start == *irq)) | 414 | if ((tdev->res.irq_resource[tmp].start == *irq)) |
413 | return 0; | 415 | return 0; |
@@ -418,12 +420,12 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
418 | return 1; | 420 | return 1; |
419 | } | 421 | } |
420 | 422 | ||
421 | int pnp_check_dma(struct pnp_dev * dev, int idx) | 423 | int pnp_check_dma(struct pnp_dev *dev, int idx) |
422 | { | 424 | { |
423 | #ifndef CONFIG_IA64 | 425 | #ifndef CONFIG_IA64 |
424 | int tmp; | 426 | int tmp; |
425 | struct pnp_dev *tdev; | 427 | struct pnp_dev *tdev; |
426 | resource_size_t * dma = &dev->res.dma_resource[idx].start; | 428 | resource_size_t *dma = &dev->res.dma_resource[idx].start; |
427 | 429 | ||
428 | /* if the resource doesn't exist, don't complain about it */ | 430 | /* if the resource doesn't exist, don't complain about it */ |
429 | if (cannot_compare(dev->res.dma_resource[idx].flags)) | 431 | if (cannot_compare(dev->res.dma_resource[idx].flags)) |
@@ -449,7 +451,7 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
449 | 451 | ||
450 | /* check if the resource is already in use, skip if the | 452 | /* check if the resource is already in use, skip if the |
451 | * device is active because it itself may be in use */ | 453 | * device is active because it itself may be in use */ |
452 | if(!dev->active) { | 454 | if (!dev->active) { |
453 | if (request_dma(*dma, "pnp")) | 455 | if (request_dma(*dma, "pnp")) |
454 | return 0; | 456 | return 0; |
455 | free_dma(*dma); | 457 | free_dma(*dma); |
@@ -461,7 +463,8 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
461 | continue; | 463 | continue; |
462 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { | 464 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { |
463 | if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) { | 465 | if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) { |
464 | if (cannot_compare(tdev->res.dma_resource[tmp].flags)) | 466 | if (cannot_compare |
467 | (tdev->res.dma_resource[tmp].flags)) | ||
465 | continue; | 468 | continue; |
466 | if ((tdev->res.dma_resource[tmp].start == *dma)) | 469 | if ((tdev->res.dma_resource[tmp].start == *dma)) |
467 | return 0; | 470 | return 0; |
@@ -476,7 +479,6 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
476 | #endif | 479 | #endif |
477 | } | 480 | } |
478 | 481 | ||
479 | |||
480 | #if 0 | 482 | #if 0 |
481 | EXPORT_SYMBOL(pnp_register_dependent_option); | 483 | EXPORT_SYMBOL(pnp_register_dependent_option); |
482 | EXPORT_SYMBOL(pnp_register_independent_option); | 484 | EXPORT_SYMBOL(pnp_register_independent_option); |
@@ -484,8 +486,7 @@ EXPORT_SYMBOL(pnp_register_irq_resource); | |||
484 | EXPORT_SYMBOL(pnp_register_dma_resource); | 486 | EXPORT_SYMBOL(pnp_register_dma_resource); |
485 | EXPORT_SYMBOL(pnp_register_port_resource); | 487 | EXPORT_SYMBOL(pnp_register_port_resource); |
486 | EXPORT_SYMBOL(pnp_register_mem_resource); | 488 | EXPORT_SYMBOL(pnp_register_mem_resource); |
487 | #endif /* 0 */ | 489 | #endif /* 0 */ |
488 | |||
489 | 490 | ||
490 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ | 491 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ |
491 | 492 | ||
@@ -494,7 +495,7 @@ static int __init pnp_setup_reserve_irq(char *str) | |||
494 | int i; | 495 | int i; |
495 | 496 | ||
496 | for (i = 0; i < 16; i++) | 497 | for (i = 0; i < 16; i++) |
497 | if (get_option(&str,&pnp_reserve_irq[i]) != 2) | 498 | if (get_option(&str, &pnp_reserve_irq[i]) != 2) |
498 | break; | 499 | break; |
499 | return 1; | 500 | return 1; |
500 | } | 501 | } |
@@ -508,7 +509,7 @@ static int __init pnp_setup_reserve_dma(char *str) | |||
508 | int i; | 509 | int i; |
509 | 510 | ||
510 | for (i = 0; i < 8; i++) | 511 | for (i = 0; i < 8; i++) |
511 | if (get_option(&str,&pnp_reserve_dma[i]) != 2) | 512 | if (get_option(&str, &pnp_reserve_dma[i]) != 2) |
512 | break; | 513 | break; |
513 | return 1; | 514 | return 1; |
514 | } | 515 | } |
@@ -522,7 +523,7 @@ static int __init pnp_setup_reserve_io(char *str) | |||
522 | int i; | 523 | int i; |
523 | 524 | ||
524 | for (i = 0; i < 16; i++) | 525 | for (i = 0; i < 16; i++) |
525 | if (get_option(&str,&pnp_reserve_io[i]) != 2) | 526 | if (get_option(&str, &pnp_reserve_io[i]) != 2) |
526 | break; | 527 | break; |
527 | return 1; | 528 | return 1; |
528 | } | 529 | } |
@@ -536,7 +537,7 @@ static int __init pnp_setup_reserve_mem(char *str) | |||
536 | int i; | 537 | int i; |
537 | 538 | ||
538 | for (i = 0; i < 16; i++) | 539 | for (i = 0; i < 16; i++) |
539 | if (get_option(&str,&pnp_reserve_mem[i]) != 2) | 540 | if (get_option(&str, &pnp_reserve_mem[i]) != 2) |
540 | break; | 541 | break; |
541 | return 1; | 542 | return 1; |
542 | } | 543 | } |