| 250 | } |
| 251 | |
| 252 | static int |
| 253 | localbus_attach(device_t dev) |
| 254 | { |
| 255 | device_t dev_child; |
| 256 | struct localbus_softc *sc; |
| 257 | struct localbus_devinfo *di; |
| 258 | phandle_t dt_node, dt_child; |
| 259 | |
| 260 | sc = device_get_softc(dev); |
| 261 | sc->sc_dev = dev; |
| 262 | sc->sc_banks = localbus_banks; |
| 263 | |
| 264 | /* |
| 265 | * Walk localbus and add direct subordinates as our children. |
| 266 | */ |
| 267 | dt_node = ofw_bus_get_node(dev); |
| 268 | for (dt_child = OF_child(dt_node); dt_child != 0; |
| 269 | dt_child = OF_peer(dt_child)) { |
| 270 | /* Check and process 'status' property. */ |
| 271 | if (!(ofw_bus_node_status_okay(dt_child))) |
| 272 | continue; |
| 273 | |
| 274 | if (!(mv_fdt_pm(dt_child))) |
| 275 | continue; |
| 276 | |
| 277 | di = malloc(sizeof(*di), M_LOCALBUS, M_WAITOK | M_ZERO); |
| 278 | if (ofw_bus_gen_setup_devinfo(&di->di_ofw, dt_child) != 0) { |
| 279 | free(di, M_LOCALBUS); |
| 280 | device_printf(dev, "could not set up devinfo\n"); |
| 281 | continue; |
| 282 | } |
| 283 | |
| 284 | resource_list_init(&di->di_res); |
| 285 | if (fdt_localbus_reg_decode(dt_child, sc, di)) { |
| 286 | device_printf(dev, "could not process 'reg' " |
| 287 | "property\n"); |
| 288 | ofw_bus_gen_destroy_devinfo(&di->di_ofw); |
| 289 | free(di, M_LOCALBUS); |
| 290 | continue; |
| 291 | } |
| 292 | |
| 293 | /* Add newbus device for this FDT node */ |
| 294 | dev_child = device_add_child(dev, NULL, -1); |
| 295 | if (dev_child == NULL) { |
| 296 | device_printf(dev, "could not add child: %s\n", |
| 297 | di->di_ofw.obd_name); |
| 298 | resource_list_free(&di->di_res); |
| 299 | ofw_bus_gen_destroy_devinfo(&di->di_ofw); |
| 300 | free(di, M_LOCALBUS); |
| 301 | continue; |
| 302 | } |
| 303 | #ifdef DEBUG |
| 304 | device_printf(dev, "added child: %s\n\n", di->di_ofw.obd_name); |
| 305 | #endif |
| 306 | device_set_ivars(dev_child, di); |
| 307 | } |
| 308 | |
| 309 | return (bus_generic_attach(dev)); |
nothing calls this directly
no test coverage detected