/* NOTE: It is the responsibility of the caller to kfree buffer  */
int msm_rpc_read(struct msm_rpc_endpoint *ept, void **buffer, unsigned user_len, long timeout)
/* NOTE: It is the responsibility of the caller to kfree buffer  */
int msm_rpc_read(struct msm_rpc_endpoint *ept, void **buffer, unsigned user_len, long timeout)
{
	struct rr_fragment *frag, *next;
	char *buf;
	int rc;
	rc = __msm_rpc_read(ept, &frag, user_len, timeout);
	if (rc <= 0)
		return rc;
	if (frag->next == 0) {
		*buffer = (void*) frag;
		return rc;
	}
	buf = rr_malloc(rc);
	*buffer = buf;
	while (frag != NULL) {
		memcpy(buf, frag->data, frag->length);
		next = frag->next;
		buf += frag->length;
		kfree(frag);
		frag = next;
	}
	return rc;
}