platform: msm_shared: integrate dload & normal reboot reason in a function

Integrate dload & normal reboot reason in a function, so that it could
avoid the normal reboot reason macro collision with dload mode.

Change-Id: Icc7c9d465e6c993d71e84bd793c5650bf51a4d28
diff --git a/target/fsm9010/init.c b/target/fsm9010/init.c
index 76382aa..35c19c8 100644
--- a/target/fsm9010/init.c
+++ b/target/fsm9010/init.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -328,8 +328,23 @@
 	return restart_reason;
 }
 
+int set_download_mode(enum reboot_reason mode)
+{
+	if (mode == NORMAL_DLOAD || mode == EMERGENCY_DLOAD)
+		dload_util_write_cookie(mode == NORMAL_DLOAD ?
+			DLOAD_MODE_ADDR_V2 : EMERGENCY_DLOAD_MODE_ADDR_V2, mode);
+
+	return 0;
+}
+
 void reboot_device(unsigned reboot_reason)
 {
+	/* Set cookie for dload mode */
+	if(set_download_mode(reboot_reason)) {
+		dprintf(CRITICAL, "HALT: set_download_mode not supported\n");
+		return;
+	}
+
 	/* Write the reboot reason */
 	writel(reboot_reason, RESTART_REASON_ADDR_V2);
 
@@ -352,14 +367,6 @@
 	dprintf(CRITICAL, "Rebooting failed\n");
 }
 
-int set_download_mode(enum dload_mode mode)
-{
-	dload_util_write_cookie(mode == NORMAL_DLOAD ?
-		DLOAD_MODE_ADDR_V2 : EMERGENCY_DLOAD_MODE_ADDR_V2, mode);
-
-	return 0;
-}
-
 /* Returns 1 if target supports continuous splash screen. */
 int target_cont_splash_screen()
 {