[COMMON] iio: exynos_adc: Insert enable_irq/disable_irq
authorChangki Kim <changki.kim@samsung.com>
Wed, 27 Apr 2016 04:57:57 +0000 (13:57 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:49 +0000 (20:27 +0900)
If interrupt is handled after clock is disable,
external abort on non-linefetch is occurred.

This patch disable interrupt before disable clock
and enable interrupt after enable clock to avoid external abort.

Change-Id: I028bd20ecd768ee3d2820249ab64dd1aae6b132e
Signed-off-by: Eunki Kim <eunki_kim@samsung.com>
Signed-off-by: Changki Kim <changki.kim@samsung.com>
Signed-off-by: Kyungwoo Kang <kwoo.kang@samsung.com>
drivers/iio/adc/exynos_adc.c

index b06bbd06069eb6b6ccd4e5f603b3afebfed29fb6..cafb117270f50591f85027ce099f9cae33f0a76a 100644 (file)
@@ -417,6 +417,9 @@ static void exynos_adc_v2_exit_hw(struct exynos_adc *info)
        con = readl(ADC_V2_CON1(info->regs));
        con &= ~ADC_CON_EN_START;
        writel(con, ADC_V2_CON1(info->regs));
+
+       /* Disable interrupts */
+       writel(0, ADC_V2_INT_EN(info->regs));
 }
 
 static void exynos_adc_v2_clear_irq(struct exynos_adc *info)
@@ -551,6 +554,10 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
        if (ret)
                goto err_unlock;
 
+       enable_irq(info->irq);
+       if (info->data->init_hw)
+               info->data->init_hw(info);
+
        /* Select the channel to be used and Trigger conversion */
        if (info->data->start_conv)
                info->data->start_conv(info, chan->address);
@@ -559,8 +566,6 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
                                              EXYNOS_ADC_TIMEOUT);
        if (timeout == 0) {
                dev_warn(&indio_dev->dev, "Conversion timed out! Resetting\n");
-               if (info->data->init_hw)
-                       info->data->init_hw(info);
                ret = -ETIMEDOUT;
        } else {
                *val = info->value;
@@ -568,6 +573,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
                ret = IIO_VAL_INT;
        }
 
+       disable_irq(info->irq);
        exynos_adc_disable_access(info);
 err_unlock:
        mutex_unlock(&indio_dev->mlock);
@@ -899,6 +905,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
+       disable_irq(info->irq);
        exynos_adc_disable_access(info);
        ret = iio_device_register(indio_dev);
        if (ret)