Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofw_graph.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | ofw_graph_get_port_by_idx(phandle_t node, uint32_t idx) | ||||
char portnode[PORT_MAX_NAME]; | char portnode[PORT_MAX_NAME]; | ||||
/* First try to find a port@<idx> node */ | /* First try to find a port@<idx> node */ | ||||
snprintf(portnode, sizeof(portnode), "port@%d", idx); | snprintf(portnode, sizeof(portnode), "port@%d", idx); | ||||
child = ofw_bus_find_child(node, portnode); | child = ofw_bus_find_child(node, portnode); | ||||
if (child != 0) | if (child != 0) | ||||
return (child); | return (child); | ||||
/* Now check for 'port' without explicit index. */ | |||||
if (idx == 0) { | |||||
snprintf(portnode, sizeof(portnode), "port"); | |||||
child = ofw_bus_find_child(node, portnode); | |||||
if (child != 0) | |||||
return (child); | |||||
} | |||||
/* Next try to look under ports */ | /* Next try to look under ports */ | ||||
ports = ofw_bus_find_child(node, "ports"); | ports = ofw_bus_find_child(node, "ports"); | ||||
if (ports == 0) | if (ports == 0) | ||||
return (0); | return (0); | ||||
for (child = OF_child(ports); child != 0; child = OF_peer(child)) { | for (child = OF_child(ports); child != 0; child = OF_peer(child)) { | ||||
if (OF_getencprop(child, "reg", ®, sizeof(uint32_t)) <= 0 || | if (OF_getencprop(child, "reg", ®, sizeof(uint32_t)) <= 0 || | ||||
reg != idx) | reg != idx) | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |