/* This function shouldn't be called from interrupt context  */
int ab4500_write(struct ab4500 *ab4500, unsigned char block, unsigned long addr, unsigned char data)
/* This function shouldn't be called from interrupt context  */
int ab4500_write(struct ab4500 *ab4500, unsigned char block, unsigned long addr, unsigned char data)
{
	struct spi_transfer xfer;
	struct spi_message	msg;
	int err;
	unsigned long spi_data =
		block << 18 | addr << 10 | data;
	mutex_lock(&ab4500->lock);
	ab4500->tx_buf[0] = spi_data;
	ab4500->rx_buf[0] = 0;
	xfer.tx_buf	= ab4500->tx_buf;
	xfer.rx_buf 	= NULL;
	xfer.len	= sizeof(unsigned long);
	spi_message_init(&msg);
	spi_message_add_tail(&xfer, &msg);
	err = spi_sync(ab4500->spi, &msg);
	mutex_unlock(&ab4500->lock);
	return err;
}