linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: elder@linaro.org (Alex Elder)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/10] ARM: bcm: err, don't BUG() on SMC init failures
Date: Thu, 17 Apr 2014 21:30:07 -0500	[thread overview]
Message-ID: <1397788215-20279-3-git-send-email-elder@linaro.org> (raw)
In-Reply-To: <1397788215-20279-1-git-send-email-elder@linaro.org>

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>
---
 arch/arm/mach-bcm/bcm_kona_smc.c |   14 ++++++++++----
 1 file 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 d881c72..ddc2f17 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 = {
 int __init bcm_kona_smc_init(void)
 {
 	struct device_node *node;
+	const __be32 *prop_val;
 
 	/* Read buffer addr and size from the device tree node */
 	node = of_find_matching_node(NULL, bcm_kona_smc_ids);
@@ -52,12 +53,17 @@ int __init bcm_kona_smc_init(void)
 		return -ENODEV;
 
 	/* Don't care about size or flags of the DT node */
-	bridge_data.buffer_addr =
-		be32_to_cpu(*of_get_address(node, 0, NULL, NULL));
-	BUG_ON(!bridge_data.buffer_addr);
+	prop_val = of_get_address(node, 0, NULL, NULL);
+	if (!prop_val)
+		return -EINVAL;
+
+	bridge_data.buffer_addr = be32_to_cpu(*prop_val);
+	if (!bridge_data.buffer_addr)
+		return -EINVAL;
 
 	bridge_data.bounce = of_iomap(node, 0);
-	BUG_ON(!bridge_data.bounce);
+	if (!bridge_data.bounce)
+		return -ENOMEM;
 
 	bridge_data.initialized = 1;
 
-- 
1.7.9.5

  parent reply	other threads:[~2014-04-18  2:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18  2:30 [PATCH 00/10] ARM: bcm: SCM and L2 cache code cleanup Alex Elder
2014-04-18  2:30 ` [PATCH 01/10] ARM: bcm: use memory accessors for ioremapped area Alex Elder
2014-04-18  2:30 ` Alex Elder [this message]
2014-04-18  2:30 ` [PATCH 03/10] ARM: bcm: clean up SMC code Alex Elder
2014-04-18  2:30 ` [PATCH 04/10] ARM: bcm: have bcm_kona_smc() return request result Alex Elder
2014-04-18  2:30 ` [PATCH 05/10] ARM: bcm: don't special-case CPU 0 in bcm_kona_smc() Alex Elder
2014-04-18  2:30 ` [PATCH 06/10] ARM: bcm: config option for l2 cache support Alex Elder
2014-04-18  2:30 ` [PATCH 07/10] ARM: bcm: tidy up a few includes Alex Elder
2014-04-18  8:29   ` Russell King - ARM Linux
2014-04-18 12:05     ` Alex Elder
2014-04-18  2:30 ` [PATCH 08/10] ARM: bcm: use inline assembly for "smc" request Alex Elder
2014-04-18  2:30 ` [PATCH 09/10] ARM: bcm: rewrite commentary for bcm_kona_do_smc() Alex Elder
2014-04-18  2:30 ` [PATCH 10/10] ARM: bcm: rename "kona.h" and "kona.c" Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397788215-20279-3-git-send-email-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).