msm: mdss: error handling in the dsi driver on 8x10

This adds the error handling in the dsi command send and receive
functions.

Change-Id: I69d77a6f1981a286864e7076aee079776ed53a85
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
diff --git a/drivers/video/msm/mdss/dsi_host_v2.c b/drivers/video/msm/mdss/dsi_host_v2.c
index 452e63a..e8fe7e3 100644
--- a/drivers/video/msm/mdss/dsi_host_v2.c
+++ b/drivers/video/msm/mdss/dsi_host_v2.c
@@ -546,7 +546,12 @@
 	cm = cmds;
 	for (i = 0; i < cnt; i++) {
 		dsi_buf_init(tp);
-		dsi_cmd_dma_add(tp, cm);
+		rc = dsi_cmd_dma_add(tp, cm);
+		if (!rc) {
+			pr_err("%s: dsi_cmd_dma_add fail\n", __func__);
+			rc = -EINVAL;
+			break;
+		}
 		rc = msm_dsi_cmd_dma_tx(tp);
 		if (IS_ERR_VALUE(rc)) {
 			pr_err("%s: failed to call cmd_dma_tx\n", __func__);
@@ -634,27 +639,35 @@
 		pkt_size = len;
 		max_pktsize[0] = pkt_size;
 		dsi_buf_init(tp);
-		dsi_cmd_dma_add(tp, pkt_size_cmd);
+		rc = dsi_cmd_dma_add(tp, pkt_size_cmd);
+		if (!rc) {
+			pr_err("%s: dsi_cmd_dma_add failed\n", __func__);
+			rp->len = 0;
+			goto msm_dsi_cmds_rx_err;
+		}
 		rc = msm_dsi_cmd_dma_tx(tp);
 		if (IS_ERR_VALUE(rc)) {
-			msm_dsi_disable_irq();
-			pr_err("%s: dma_tx failed\n", __func__);
+			pr_err("%s: msm_dsi_cmd_dma_tx failed\n", __func__);
 			rp->len = 0;
-			goto end;
+			goto msm_dsi_cmds_rx_err;
 		}
 		pr_debug("%s: Max packet size sent\n", __func__);
 	}
 
 	dsi_buf_init(tp);
-	dsi_cmd_dma_add(tp, cmds);
+	rc = dsi_cmd_dma_add(tp, cmds);
+	if (!rc) {
+		pr_err("%s: dsi_cmd_dma_add failed\n", __func__);
+		rp->len = 0;
+		goto msm_dsi_cmds_rx_err;
+	}
 
 	/* transmit read comamnd to client */
-	msm_dsi_cmd_dma_tx(tp);
+	rc = msm_dsi_cmd_dma_tx(tp);
 	if (IS_ERR_VALUE(rc)) {
-		msm_dsi_disable_irq();
-		pr_err("%s: dma_tx failed\n", __func__);
+		pr_err("%s: msm_dsi_cmd_dma_tx failed\n", __func__);
 		rp->len = 0;
-		goto end;
+		goto msm_dsi_cmds_rx_err;
 	}
 	/*
 	 * once cmd_dma_done interrupt received,
@@ -672,8 +685,6 @@
 
 	msm_dsi_cmd_dma_rx(rp, cnt);
 
-	msm_dsi_disable_irq();
-
 	if (pdata->panel_info.mipi.no_max_pkt_size) {
 		/*
 		 * remove extra 2 bytes from previous
@@ -689,6 +700,7 @@
 	switch (cmd) {
 	case DTYPE_ACK_ERR_RESP:
 		pr_debug("%s: rx ACK_ERR_PACLAGE\n", __func__);
+		rp->len = 0;
 		break;
 	case DTYPE_GEN_READ1_RESP:
 	case DTYPE_DCS_READ1_RESP:
@@ -705,14 +717,17 @@
 		rp->len -= diff; /* align bytes */
 		break;
 	default:
-		pr_debug("%s: Unknown cmd received\n", __func__);
+		pr_warn("%s: Unknown cmd received\n", __func__);
+		rp->len = 0;
 		break;
 	}
 
 	if (video_mode)
 		MIPI_OUTP(ctrl_base + DSI_CTRL,
 					dsi_ctrl); /* restore */
-end:
+
+msm_dsi_cmds_rx_err:
+	msm_dsi_disable_irq();
 	return rp->len;
 }