diff options
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r-- | io-module/mts_io.c | 9 |
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 = { |