| 410 | } |
| 411 | |
| 412 | static struct resource * |
| 413 | mtk_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, |
| 414 | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) |
| 415 | { |
| 416 | struct mtk_pci_softc *sc = device_get_softc(bus); |
| 417 | struct resource *rv; |
| 418 | struct rman *rm; |
| 419 | |
| 420 | switch (type) { |
| 421 | case PCI_RES_BUS: |
| 422 | return pci_domain_alloc_bus(0, child, rid, start, end, count, |
| 423 | flags); |
| 424 | case SYS_RES_IRQ: |
| 425 | rm = &sc->sc_irq_rman; |
| 426 | break; |
| 427 | case SYS_RES_IOPORT: |
| 428 | rm = &sc->sc_io_rman; |
| 429 | break; |
| 430 | case SYS_RES_MEMORY: |
| 431 | rm = &sc->sc_mem_rman; |
| 432 | break; |
| 433 | default: |
| 434 | return (NULL); |
| 435 | } |
| 436 | |
| 437 | rv = rman_reserve_resource(rm, start, end, count, flags, child); |
| 438 | |
| 439 | if (rv == NULL) |
| 440 | return (NULL); |
| 441 | |
| 442 | rman_set_rid(rv, *rid); |
| 443 | |
| 444 | if ((flags & RF_ACTIVE) && type != SYS_RES_IRQ) { |
| 445 | if (bus_activate_resource(child, type, *rid, rv)) { |
| 446 | rman_release_resource(rv); |
| 447 | return (NULL); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | return (rv); |
| 452 | } |
| 453 | |
| 454 | static int |
| 455 | mtk_pci_release_resource(device_t bus, device_t child, int type, int rid, |
nothing calls this directly
no test coverage detected