From: Lars-Peter Clausen Date: Mon, 19 Dec 2011 14:23:43 +0000 (+0100) Subject: staging:iio: Disallow changing scan elements in all buffered modes X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5fd6218ca5928e4b59eb8a496aa1428fae1fb0d6;p=linux-beck.git staging:iio: Disallow changing scan elements in all buffered modes Currently we only disallow changing the scan elements, while the buffer is enabled, in triggered buffer mode. This patch changes it to disallow it for all buffered modes. Disabling or enabling scan elements while the buffer is enabled will cause undefined behavior since the reader will not be able to tell samples with the new and old scan element set apart and thus wont be able to extract any meaningful data from the buffer. Acked-by: Jonathan Cameron Signed-off-by: Lars-Peter Clausen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index 36993038b261..747b9013a666 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -153,7 +153,7 @@ static ssize_t iio_scan_el_store(struct device *dev, state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { + if (iio_buffer_enabled(indio_dev)) { ret = -EBUSY; goto error_ret; } @@ -196,7 +196,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { + if (iio_buffer_enabled(indio_dev)) { ret = -EBUSY; goto error_ret; }