mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
iio: adc: rockchip_saradc: fix interrupt issue
Saradc interrupt status may exist forever if read saradc when system suspending which disable clock that finally lead to interrupt system dead. Add mutex in suspend to avoid this issue. Change-Id: I6a83e4bd79db90a79985685b5e94df2209b5ae81 Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
@@ -71,6 +71,7 @@ struct rockchip_saradc {
|
||||
const struct rockchip_saradc_data *data;
|
||||
u16 last_val;
|
||||
const struct iio_chan_spec *last_chan;
|
||||
bool suspended;
|
||||
#ifdef CONFIG_ROCKCHIP_SARADC_TEST_CHN
|
||||
struct timer_list timer;
|
||||
bool test;
|
||||
@@ -168,6 +169,11 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
|
||||
if (info->suspended) {
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
ret = rockchip_saradc_conversion(info, chan);
|
||||
if (ret) {
|
||||
rockchip_saradc_power_down(info);
|
||||
@@ -658,10 +664,16 @@ static int rockchip_saradc_suspend(struct device *dev)
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct rockchip_saradc *info = iio_priv(indio_dev);
|
||||
|
||||
/* Avoid reading saradc when suspending */
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
|
||||
clk_disable_unprepare(info->clk);
|
||||
clk_disable_unprepare(info->pclk);
|
||||
regulator_disable(info->vref);
|
||||
|
||||
info->suspended = true;
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -683,6 +695,8 @@ static int rockchip_saradc_resume(struct device *dev)
|
||||
if (ret)
|
||||
clk_disable_unprepare(info->pclk);
|
||||
|
||||
info->suspended = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user