msm: smd: add smd_write_segment_avail()

Packet based SMD channels support transactions which allow the client to
send data payloads that exceed the size of the transport buffer.
Currently clients using this feature call smd_write_avail() to determine
how much free space is available in the buffer for the next segment of the
payload.

This causes inefficencies for the client, as smd_write_avail()
reserves SMD_HEADER_SIZE bytes from the client under the assumption that
a transport level header needs to be written to the transport buffer.  If
the transaction is already started, this assumption becomes incorrect and
space that could be used by the client to reduce the number of write in
some scenarios goes unused.

Add a function to the transaction API, smd_write_segment_avail(), which
is aware of if the transport level header needs to be written or not, and
return the correct ammount of usable space to the client.  Also, convert
the current clients of the transaction API to use
smd_write_segment_avail() as necessary.

CRs-Fixed: 471277
Change-Id: Ibdacd2572fa274c971eb679bc1d60eb2a7e1cab2
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
diff --git a/arch/arm/mach-msm/smd_pkt.c b/arch/arm/mach-msm/smd_pkt.c
index 7eb9ead..424d310 100644
--- a/arch/arm/mach-msm/smd_pkt.c
+++ b/arch/arm/mach-msm/smd_pkt.c
@@ -509,7 +509,7 @@
 	do {
 		prepare_to_wait(&smd_pkt_devp->ch_write_wait_queue,
 				&write_wait, TASK_UNINTERRUPTIBLE);
-		if (!smd_write_avail(smd_pkt_devp->ch) &&
+		if (!smd_write_segment_avail(smd_pkt_devp->ch) &&
 		    !smd_pkt_devp->has_reset) {
 			smd_enable_read_intr(smd_pkt_devp->ch);
 			schedule();
@@ -631,7 +631,7 @@
 		return;
 	}
 
-	sz = smd_write_avail(smd_pkt_devp->ch);
+	sz = smd_write_segment_avail(smd_pkt_devp->ch);
 	if (sz) {
 		D_WRITE("%s: %d bytes write space in smd_pkt_dev id:%d\n",
 			__func__, sz, smd_pkt_devp->i);