From 3ca34cc462aa26c748ea194e6c5047a00c915bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 5 Dec 2011 22:18:25 +0000 Subject: staging:iio:adc:max1363 stop reading from buffer for sysfs access No known use case and makes in kernel interface work more complex. Signed-off-by: Jonathan Cameron Acked-by: Lars-Peter Clausen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/max1363_core.c | 51 ++++++++++++++-------------------- 1 file changed, 21 insertions(+), 30 deletions(-) (limited to 'drivers/staging/iio/adc/max1363_core.c') diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 0b97123703ae..1ce89efb1b9b 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -191,7 +191,6 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, int ret = 0; s32 data; char rxbuf[2]; - const unsigned long *mask; struct max1363_state *st = iio_priv(indio_dev); struct i2c_client *client = st->client; @@ -200,46 +199,38 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, * If monitor mode is enabled, the method for reading a single * channel will have to be rather different and has not yet * been implemented. + * + * Also, cannot read directly if buffered capture enabled. */ - if (st->monitor_on) { + if (st->monitor_on || iio_buffer_enabled(indio_dev)) { ret = -EBUSY; goto error_ret; } - /* If ring buffer capture is occurring, query the buffer */ - if (iio_buffer_enabled(indio_dev)) { - mask = max1363_mode_table[chan->address].modemask; - data = max1363_single_channel_from_ring(mask, st); + /* Check to see if current scan mode is correct */ + if (st->current_mode != &max1363_mode_table[chan->address]) { + /* Update scan mode if needed */ + st->current_mode = &max1363_mode_table[chan->address]; + ret = max1363_set_scan_mode(st); + if (ret < 0) + goto error_ret; + } + if (st->chip_info->bits != 8) { + /* Get reading */ + data = i2c_master_recv(client, rxbuf, 2); if (data < 0) { ret = data; goto error_ret; } + data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8; } else { - /* Check to see if current scan mode is correct */ - if (st->current_mode != &max1363_mode_table[chan->address]) { - /* Update scan mode if needed */ - st->current_mode = &max1363_mode_table[chan->address]; - ret = max1363_set_scan_mode(st); - if (ret < 0) - goto error_ret; - } - if (st->chip_info->bits != 8) { - /* Get reading */ - data = i2c_master_recv(client, rxbuf, 2); - if (data < 0) { - ret = data; - goto error_ret; - } - data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8; - } else { - /* Get reading */ - data = i2c_master_recv(client, rxbuf, 1); - if (data < 0) { - ret = data; - goto error_ret; - } - data = rxbuf[0]; + /* Get reading */ + data = i2c_master_recv(client, rxbuf, 1); + if (data < 0) { + ret = data; + goto error_ret; } + data = rxbuf[0]; } *val = data; error_ret: -- cgit v1.2.3-59-g8ed1b