{
const char *name;
const char *addresses;
- int (*match)(const struct dt_device_node *parent);
+ bool_t (*match)(const struct dt_device_node *node);
void (*count_cells)(const struct dt_device_node *child,
int *addrc, int *sizec);
u64 (*map)(__be32 *addr, const __be32 *range, int na, int ns, int pna);
/*
* Default translator (generic bus)
*/
+static bool_t dt_bus_default_match(const struct dt_device_node *node)
+{
+ /* Root node doesn't have "ranges" property */
+ if ( node->parent == NULL )
+ return 1;
+
+ /* The default bus is only used when the "ranges" property exists.
+ * Otherwise we can't translate the address
+ */
+ return (dt_get_property(node, "ranges", NULL) != NULL);
+}
+
static void dt_bus_default_count_cells(const struct dt_device_node *dev,
int *addrc, int *sizec)
{
{
.name = "default",
.addresses = "reg",
- .match = NULL,
+ .match = dt_bus_default_match,
.count_cells = dt_bus_default_count_cells,
.map = dt_bus_default_map,
.translate = dt_bus_default_translate,
for ( i = 0; i < ARRAY_SIZE(dt_busses); i++ )
if ( !dt_busses[i].match || dt_busses[i].match(np) )
return &dt_busses[i];
- BUG();
return NULL;
}
parent = dt_get_parent(dev);
if ( parent == NULL )
return NULL;
+
bus = dt_match_bus(parent);
+ if ( !bus )
+ return NULL;
bus->count_cells(dev, &na, &ns);
if ( !DT_CHECK_ADDR_COUNT(na) )
if ( parent == NULL )
goto bail;
bus = dt_match_bus(parent);
+ if ( !bus )
+ goto bail;
/* Count address cells & copy address locally */
bus->count_cells(dev, &na, &ns);
/* Get new parent bus and counts */
pbus = dt_match_bus(parent);
+ if ( pbus == NULL )
+ {
+ dt_printk("DT: %s is not a valid bus\n", parent->full_name);
+ break;
+ }
pbus->count_cells(dev, &pna, &pns);
if ( !DT_CHECK_COUNTS(pna, pns) )
{
return 0;
bus = dt_match_bus(parent);
+ if ( !bus )
+ return 0;
bus->count_cells(dev, &na, &ns);
if ( !DT_CHECK_COUNTS(na, ns) )