Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/fdt/simplebus.c
Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | |||||
simplebus_add_device(device_t dev, phandle_t node, u_int order, | simplebus_add_device(device_t dev, phandle_t node, u_int order, | ||||
const char *name, int unit, struct simplebus_devinfo *di) | const char *name, int unit, struct simplebus_devinfo *di) | ||||
{ | { | ||||
struct simplebus_devinfo *ndi; | struct simplebus_devinfo *ndi; | ||||
device_t cdev; | device_t cdev; | ||||
if ((ndi = simplebus_setup_dinfo(dev, node, di)) == NULL) | if ((ndi = simplebus_setup_dinfo(dev, node, di)) == NULL) | ||||
return (NULL); | return (NULL); | ||||
/* | |||||
* If the order is unspecified, use the cell-index field, if available. | |||||
* The cell-index property is not part of any standard, but is widely | |||||
* used in NXP/Freescale and Marvell device trees. | |||||
*/ | |||||
if (order == -1) | |||||
OF_getencprop(node, "cell-index", &order, sizeof(order)); | |||||
cdev = device_add_child_ordered(dev, order, name, unit); | cdev = device_add_child_ordered(dev, order, name, unit); | ||||
if (cdev == NULL) { | if (cdev == NULL) { | ||||
device_printf(dev, "<%s>: device_add_child failed\n", | device_printf(dev, "<%s>: device_add_child failed\n", | ||||
ndi->obdinfo.obd_name); | ndi->obdinfo.obd_name); | ||||
resource_list_free(&ndi->rl); | resource_list_free(&ndi->rl); | ||||
ofw_bus_gen_destroy_devinfo(&ndi->obdinfo); | ofw_bus_gen_destroy_devinfo(&ndi->obdinfo); | ||||
if (di == NULL) | if (di == NULL) | ||||
free(ndi, M_DEVBUF); | free(ndi, M_DEVBUF); | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |