summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gilles <jgilles@multitech.com>2011-10-03 11:01:29 -0500
committerJesse Gilles <jgilles@multitech.com>2011-10-03 11:01:29 -0500
commit62ede3c85e9aac5923799f1e3f990265521da8d1 (patch)
tree14000ad7b1a73f9e643000eb2d57500164fe6fe7
parent06b6abfbbd74b97b86ee9493ecd211add42613e5 (diff)
downloadcdp-io-controller-62ede3c85e9aac5923799f1e3f990265521da8d1.tar.gz
cdp-io-controller-62ede3c85e9aac5923799f1e3f990265521da8d1.tar.bz2
cdp-io-controller-62ede3c85e9aac5923799f1e3f990265521da8d1.zip
add locking on adc readv0.5.1
-rw-r--r--io-module/mts_io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 3fc59d9..fe7fcaf 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -1573,6 +1573,8 @@ static ssize_t mts_attr_show_adc(struct device *dev,
return -ENOENT;
}
+ mutex_lock(&mts_io_mutex);
+
// disable all channels and enable the one we want
writel(0x0F, adc_base + ADC_CHDR_OFFSET);
writel(chan_mask, adc_base + ADC_CHER_OFFSET);
@@ -1586,7 +1588,12 @@ static ssize_t mts_attr_show_adc(struct device *dev,
log_debug("ADC_SR EOC [%X]", value);
}
- return sprintf(buf, "%lu\n", (unsigned long) readl(adc_base + offset));
+ // read result
+ value = readl(adc_base + offset);
+
+ mutex_unlock(&mts_io_mutex);
+
+ return sprintf(buf, "%lu\n", (unsigned long) value);
}
static struct device_attribute dev_attr_adc0 = {