Subject: [PATCH] powerpc/powernv: Check image loaded or not before calling flash

From: Vasant Hegde <[email-masked]>
Date: Thu, 12 Feb 2015 15:23:27 +0530

Present code checks for update_flash_data in opal_flash_term_callback().
update_flash_data has been statically initialized to zero, and that
is the value of FLASH_IMG_READY. Also code update initialization happens
during subsys init.

So if reboot is issued before the subsys init stage then we endup displaying
"Flashing new firmware" message.. which may confuse end user.

This patch adds additional validation to make sure image is actually loaded
or not.

Reported-by: Sam Bobroff <[email-masked]>
Signed-off-by: Vasant Hegde <[email-masked]>
---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
index 5c21d9c..5455cd4 100644
--- a/arch/powerpc/platforms/powernv/opal-flash.c
+++ b/arch/powerpc/platforms/powernv/opal-flash.c
@@ -319,7 +319,8 @@ void opal_flash_term_callback(void)
 {
 	struct cpumask mask;
 
-	if (update_flash_data.status != FLASH_IMG_READY)
+	if (update_flash_data.status != FLASH_IMG_READY ||
+	    image_data.status != IMAGE_READY)
 		return;
 
 	pr_alert("FLASH: Flashing new firmware\n");