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/msm8974/init.c b/target/msm8974/init.c
index 266e091..73043df 100644
--- a/target/msm8974/init.c
+++ b/target/msm8974/init.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, 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
@@ -516,11 +516,26 @@
 	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)
 {
 	uint32_t soc_ver = 0;
 	uint8_t reset_type = 0;
 
+	/* Set cookie for dload mode */
+	if(set_download_mode(reboot_reason)) {
+		dprintf(CRITICAL, "HALT: set_download_mode not supported\n");
+		return;
+	}
+
 	soc_ver = board_soc_version();
 
 	/* Write the reboot reason */
@@ -548,14 +563,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;
-}
-
 /* Check if MSM needs VBUS mimic for USB */
 static int target_needs_vbus_mimic()
 {
@@ -830,4 +837,4 @@
 uint32_t target_get_pmic()
 {
 	return PMIC_IS_PM8941;
-}
\ No newline at end of file
+}