/* mpi_msg_free_get- get the free message buffer for transfer inbound queue. @circularQ: the inbound queue we want to transfer to HBA. @messageSize: the message size of this transfer, normally it is 64 bytes @messagePtr: the pointer to message.  */
static int mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr)
/* mpi_msg_free_get- get the free message buffer for transfer inbound queue. @circularQ: the inbound queue we want to transfer to HBA. @messageSize: the message size of this transfer, normally it is 64 bytes @messagePtr: the pointer to message.  */
static int mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr)
{
	u32 offset, consumer_index;
	struct mpi_msg_hdr *msgHeader;
	u8 bcCount = 1;
	if (messageSize > 64) {
		*messagePtr = NULL;
		return -1;
	}
	consumer_index = pm8001_read_32(circularQ->ci_virt);
	circularQ->consumer_index = cpu_to_le32(consumer_index);
	if (((circularQ->producer_idx + bcCount) % 256) ==
		circularQ->consumer_index) {
		*messagePtr = NULL;
		return -1;
	}
	offset = circularQ->producer_idx * 64;
	circularQ->producer_idx = (circularQ->producer_idx + bcCount) % 256;
	msgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt	+ offset);
	*messagePtr = ((void *)msgHeader) + sizeof(struct mpi_msg_hdr);
	return 0;
}