Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/puc/puc.c
| Show First 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | if (error) { | ||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| } | } | ||||
| return (res); | return (res); | ||||
| } | } | ||||
| int | int | ||||
| puc_bus_release_resource(device_t dev, device_t child, int type, int rid, | puc_bus_release_resource(device_t dev, device_t child, struct resource *res) | ||||
| struct resource *res) | |||||
| { | { | ||||
| struct puc_port *port; | struct puc_port *port; | ||||
| device_t originator; | device_t originator; | ||||
| /* Get our immediate child. */ | /* Get our immediate child. */ | ||||
| originator = child; | originator = child; | ||||
| while (child != NULL && device_get_parent(child) != dev) | while (child != NULL && device_get_parent(child) != dev) | ||||
| child = device_get_parent(child); | child = device_get_parent(child); | ||||
| if (child == NULL) | if (child == NULL) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| port = device_get_ivars(child); | port = device_get_ivars(child); | ||||
| KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); | KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); | ||||
| if (rid != 0 || res == NULL) | if (res == NULL) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| if (type == port->p_bar->b_type) { | if (res == port->p_ires) { | ||||
| if (res != port->p_rres) | |||||
| return (EINVAL); | |||||
| } else if (type == SYS_RES_IRQ) { | |||||
| if (res != port->p_ires) | |||||
| return (EINVAL); | |||||
| if (port->p_hasintr) | if (port->p_hasintr) | ||||
| return (EBUSY); | return (EBUSY); | ||||
| } else | } else if (res != port->p_rres) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| if (rman_get_device(res) != originator) | if (rman_get_device(res) != originator) | ||||
| return (ENXIO); | return (ENXIO); | ||||
| if (rman_get_flags(res) & RF_ACTIVE) | if (rman_get_flags(res) & RF_ACTIVE) | ||||
| rman_deactivate_resource(res); | rman_deactivate_resource(res); | ||||
| rman_set_device(res, NULL); | rman_set_device(res, NULL); | ||||
| return (0); | return (0); | ||||
| ▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines | |||||