From e42ea77a5f2b389eed2c9004eab80bf6589ebf5a Mon Sep 17 00:00:00 2001
From: Icenowy Zheng <icenowy@aosc.io>
Date: Tue, 1 Aug 2017 23:42:12 +0800
Subject: [PATCH] iio: adc: sun4i-gpadc: workaroud bogus THS raw value 0
 readout

When booting the system, the THS may read out a bogus false value which
is raw value 0.

On H3 it represents a extremely high temperature and can shutdown the
system immediately.

Workaround it by make it return -EINVAL when the raw value is 0 (which
is unlikely to happen).

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/iio/adc/sun4i-gpadc-iio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index f378ca0bc0b30..a89dcb6fba4ec 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -262,6 +262,9 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
 		pm_runtime_mark_last_busy(indio_dev->dev.parent);
 		pm_runtime_put_autosuspend(indio_dev->dev.parent);
 
+		if (!*val)
+			return -EINVAL;
+
 		return 0;
 	}