diff options
author | Kyle Moffett <Kyle.D.Moffett@boeing.com> | 2011-12-02 01:28:02 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-12-06 21:43:07 -0500 |
commit | 996983b75cebb1bc1c2c545f20336f24ebfa17af (patch) | |
tree | ba137847233819cf043ef441420cf6e134ba557c /arch/powerpc/sysdev/mpic.c | |
parent | e7a98675caf272a11dc1012c7a8c6c00cab09f5b (diff) |
powerpc/mpic: Search for open-pic device-tree node if NULL
Almost all PowerPC platforms use a standard "open-pic" device node so
the mpic_alloc() function now accepts NULL for the device-node. This
will cause it to perform a default search with of_find_matching_node().
Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/mpic.c')
-rw-r--r-- | arch/powerpc/sysdev/mpic.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index ef721c30f479..bb72a6266480 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -1143,8 +1143,24 @@ struct mpic * __init mpic_alloc(struct device_node *node, | |||
1143 | const char *vers; | 1143 | const char *vers; |
1144 | const u32 *psrc; | 1144 | const u32 *psrc; |
1145 | 1145 | ||
1146 | /* This code assumes that a non-NULL device node is passed in */ | 1146 | /* Default MPIC search parameters */ |
1147 | BUG_ON(!node); | 1147 | static const struct of_device_id __initconst mpic_device_id[] = { |
1148 | { .type = "open-pic", }, | ||
1149 | { .compatible = "open-pic", }, | ||
1150 | {}, | ||
1151 | }; | ||
1152 | |||
1153 | /* | ||
1154 | * If we were not passed a device-tree node, then perform the default | ||
1155 | * search for standardized a standardized OpenPIC. | ||
1156 | */ | ||
1157 | if (node) { | ||
1158 | node = of_node_get(node); | ||
1159 | } else { | ||
1160 | node = of_find_matching_node(NULL, mpic_device_id); | ||
1161 | if (!node) | ||
1162 | return NULL; | ||
1163 | } | ||
1148 | 1164 | ||
1149 | /* Pick the physical address from the device tree if unspecified */ | 1165 | /* Pick the physical address from the device tree if unspecified */ |
1150 | if (!phys_addr) { | 1166 | if (!phys_addr) { |
@@ -1154,14 +1170,14 @@ struct mpic * __init mpic_alloc(struct device_node *node, | |||
1154 | } else { | 1170 | } else { |
1155 | struct resource r; | 1171 | struct resource r; |
1156 | if (of_address_to_resource(node, 0, &r)) | 1172 | if (of_address_to_resource(node, 0, &r)) |
1157 | return NULL; | 1173 | goto err_of_node_put; |
1158 | phys_addr = r.start; | 1174 | phys_addr = r.start; |
1159 | } | 1175 | } |
1160 | } | 1176 | } |
1161 | 1177 | ||
1162 | mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); | 1178 | mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); |
1163 | if (mpic == NULL) | 1179 | if (mpic == NULL) |
1164 | return NULL; | 1180 | goto err_of_node_put; |
1165 | 1181 | ||
1166 | mpic->name = name; | 1182 | mpic->name = name; |
1167 | mpic->paddr = phys_addr; | 1183 | mpic->paddr = phys_addr; |
@@ -1325,6 +1341,11 @@ struct mpic * __init mpic_alloc(struct device_node *node, | |||
1325 | isu_size ? isu_size : mpic->num_sources, | 1341 | isu_size ? isu_size : mpic->num_sources, |
1326 | &mpic_host_ops, | 1342 | &mpic_host_ops, |
1327 | flags & MPIC_LARGE_VECTORS ? 2048 : 256); | 1343 | flags & MPIC_LARGE_VECTORS ? 2048 : 256); |
1344 | |||
1345 | /* | ||
1346 | * FIXME: The code leaks the MPIC object and mappings here; this | ||
1347 | * is very unlikely to fail but it ought to be fixed anyways. | ||
1348 | */ | ||
1328 | if (mpic->irqhost == NULL) | 1349 | if (mpic->irqhost == NULL) |
1329 | return NULL; | 1350 | return NULL; |
1330 | 1351 | ||
@@ -1359,7 +1380,12 @@ struct mpic * __init mpic_alloc(struct device_node *node, | |||
1359 | irq_set_default_host(mpic->irqhost); | 1380 | irq_set_default_host(mpic->irqhost); |
1360 | } | 1381 | } |
1361 | 1382 | ||
1383 | of_node_put(node); | ||
1362 | return mpic; | 1384 | return mpic; |
1385 | |||
1386 | err_of_node_put: | ||
1387 | of_node_put(node); | ||
1388 | return NULL; | ||
1363 | } | 1389 | } |
1364 | 1390 | ||
1365 | void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, | 1391 | void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, |