/* maple_add_packet - add a single instruction to the maple bus queue @mdev: maple device @function: function on device being queried @command: maple command to add @length: length of command string (in 32 bit words) @data: remainder of command string  */
int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, size_t length, void *data)
/* maple_add_packet - add a single instruction to the maple bus queue @mdev: maple device @function: function on device being queried @command: maple command to add @length: length of command string (in 32 bit words) @data: remainder of command string  */
int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, size_t length, void *data)
{
	int ret = 0;
	void *sendbuf = NULL;
	if (length) {
		sendbuf = kzalloc(length * 4, GFP_KERNEL);
		if (!sendbuf) {
			ret = -ENOMEM;
			goto out;
		}
		((__be32 *)sendbuf)[0] = cpu_to_be32(function);
	}
	mdev->mq->command = command;
	mdev->mq->length = length;
	if (length > 1)
		memcpy(sendbuf + 4, data, (length - 1) * 4);
	mdev->mq->sendbuf = sendbuf;
	mutex_lock(&maple_wlist_lock);
	list_add_tail(&mdev->mq->list, &maple_waitq);
	mutex_unlock(&maple_wlist_lock);
out:
	return ret;
}