/* Return: The number of bytes successfully transmitted or a negative error code on failure.  */
ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, const void *data, size_t len)
/* Return: The number of bytes successfully transmitted or a negative error code on failure.  */
ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, const void *data, size_t len)
{
	ssize_t err;
	size_t size;
	u8 *tx;
	if (len > 0) {
		size = 1 + len;
		tx = kmalloc(size, GFP_KERNEL);
		if (!tx)
			return -ENOMEM;
		tx[0] = cmd;
		memcpy(&tx[1], data, len);
	} else {
		tx = &cmd;
		size = 1;
	}
	err = mipi_dsi_dcs_write_buffer(dsi, tx, size);
	if (len > 0)
		kfree(tx);
	return err;
}