aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-bcm
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-04-21 17:53:03 -0400
committerMatt Porter <mporter@linaro.org>2014-04-25 08:51:32 -0400
commit5c4cee2fe8de7c14e60502b02e7c3bc7acba0530 (patch)
tree5044f39984f5d40491ed46b58ac3adde978e5eb1 /arch/arm/mach-bcm
parente80eef33f4596a247fdcf7d67d54d95d9dfaf7d3 (diff)
ARM: bcm: err, don't BUG() on SMC init failures
Several conditions in bcm_kona_smc_init() are handled with BUG_ON(). That function is capable of returning an error, so do that instead. Also, don't assume of_get_address() returns a valid pointer. Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Tim Kryger <tim.kryger@linaro.org> Reviewed-by: Markus Mayer <markus.mayer@linaro.org> Reviewed-by: Matt Porter <mporter@linaro.org> Signed-off-by: Matt Porter <mporter@linaro.org>
Diffstat (limited to 'arch/arm/mach-bcm')
-rw-r--r--arch/arm/mach-bcm/bcm_kona_smc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c
index d881c72ee878..ddc2f17217ee 100644
--- a/arch/arm/mach-bcm/bcm_kona_smc.c
+++ b/arch/arm/mach-bcm/bcm_kona_smc.c
@@ -45,6 +45,7 @@ static const struct of_device_id bcm_kona_smc_ids[] __initconst = {
45int __init bcm_kona_smc_init(void) 45int __init bcm_kona_smc_init(void)
46{ 46{
47 struct device_node *node; 47 struct device_node *node;
48 const __be32 *prop_val;
48 49
49 /* Read buffer addr and size from the device tree node */ 50 /* Read buffer addr and size from the device tree node */
50 node = of_find_matching_node(NULL, bcm_kona_smc_ids); 51 node = of_find_matching_node(NULL, bcm_kona_smc_ids);
@@ -52,12 +53,17 @@ int __init bcm_kona_smc_init(void)
52 return -ENODEV; 53 return -ENODEV;
53 54
54 /* Don't care about size or flags of the DT node */ 55 /* Don't care about size or flags of the DT node */
55 bridge_data.buffer_addr = 56 prop_val = of_get_address(node, 0, NULL, NULL);
56 be32_to_cpu(*of_get_address(node, 0, NULL, NULL)); 57 if (!prop_val)
57 BUG_ON(!bridge_data.buffer_addr); 58 return -EINVAL;
59
60 bridge_data.buffer_addr = be32_to_cpu(*prop_val);
61 if (!bridge_data.buffer_addr)
62 return -EINVAL;
58 63
59 bridge_data.bounce = of_iomap(node, 0); 64 bridge_data.bounce = of_iomap(node, 0);
60 BUG_ON(!bridge_data.bounce); 65 if (!bridge_data.bounce)
66 return -ENOMEM;
61 67
62 bridge_data.initialized = 1; 68 bridge_data.initialized = 1;
63 69