/* ad7877_read/write are only used for initial setup and for sysfs controls. The main traffic is done using spi_async() in the interrupt handler.  */
static int ad7877_read(struct spi_device *spi, u16 reg)
/* ad7877_read/write are only used for initial setup and for sysfs controls. The main traffic is done using spi_async() in the interrupt handler.  */
static int ad7877_read(struct spi_device *spi, u16 reg)
{
	struct ser_req *req;
	int status, ret;
	req = kzalloc(sizeof *req, GFP_KERNEL);
	if (!req)
		return -ENOMEM;
	spi_message_init(&req->msg);
	req->command = (u16) (AD7877_WRITEADD(AD7877_REG_CTRL1) |
			AD7877_READADD(reg));
	req->xfer[0].tx_buf = &req->command;
	req->xfer[0].len = 2;
	req->xfer[1].rx_buf = &req->sample;
	req->xfer[1].len = 2;
	spi_message_add_tail(&req->xfer[0], &req->msg);
	spi_message_add_tail(&req->xfer[1], &req->msg);
	status = spi_sync(spi, &req->msg);
	ret = status ? : req->sample;
	kfree(req);
	return ret;
}