MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mtk_pci_alloc_resource

Function mtk_pci_alloc_resource

freebsd/mips/mediatek/mtk_pcie.c:412–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412static struct resource *
413mtk_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
454static int
455mtk_pci_release_resource(device_t bus, device_t child, int type, int rid,

Callers

nothing calls this directly

Calls 5

device_get_softcFunction · 0.85
rman_reserve_resourceFunction · 0.85
rman_set_ridFunction · 0.85
bus_activate_resourceFunction · 0.85
rman_release_resourceFunction · 0.85

Tested by

no test coverage detected