msm: sysmon: recognize ungraceful shutdowns

The sysmon_send_shutdown() API sends a shutdown request to a subsystem
and reads the response. The response is expected to be simply an
acknowledgment that the subsystem has received the request.

Change-Id: Ic68ee69434a2a2f6ea4f88b4f7aa73dfe3cca90b
Signed-off-by: Joel King <joelking@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/sysmon.c

Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/arch/arm/mach-msm/sysmon.c b/arch/arm/mach-msm/sysmon.c
index 0d62e6a..46f6518 100644
--- a/arch/arm/mach-msm/sysmon.c
+++ b/arch/arm/mach-msm/sysmon.c
@@ -173,7 +173,9 @@
 int sysmon_send_shutdown(enum subsys_id dest_ss)
 {
 	struct sysmon_subsys *ss = &subsys[dest_ss];
-	const char tx_buf[] = "ssr:poweroff";
+	const char tx_buf[] = "system:shutdown";
+	const char expect[] = "system:ack";
+	size_t prefix_len = ARRAY_SIZE(expect) - 1;
 	int ret;
 
 	if (dest_ss < 0 || dest_ss >= SYSMON_NUM_SS)
@@ -181,6 +183,12 @@
 
 	mutex_lock(&ss->lock);
 	ret = sysmon_send_msg(ss, tx_buf, ARRAY_SIZE(tx_buf));
+	if (ret)
+		goto out;
+
+	if (strncmp(ss->rx_buf, expect, prefix_len))
+		ret = -ENOSYS;
+out:
 	mutex_unlock(&ss->lock);
 	return ret;
 }
diff --git a/arch/arm/mach-msm/sysmon.h b/arch/arm/mach-msm/sysmon.h
index 439c617..8c2f6ea 100644
--- a/arch/arm/mach-msm/sysmon.h
+++ b/arch/arm/mach-msm/sysmon.h
@@ -51,6 +51,10 @@
 {
 	return 0;
 }
+static inline int sysmon_send_shutdown(enum subsys_id dest_ss)
+{
+	return 0;
+}
 #endif
 
 #endif