From a47dc3129b7b12797cea07ffe107709376e6a1ab Mon Sep 17 00:00:00 2001 From: Leo Yan Date: Mon, 19 Dec 2011 15:23:10 +0800 Subject: [PATCH] ltr502als.c: Proximity status check after mode switching in early suspend BZ: 18010 If proximity status is changed during mode switch, there may be no interrupt occurred, so we need to check the data register after mode switching in the early suspend handler. Change-Id: If0e9948568ce8320ae2efbee3fb4cd0343395b2d Signed-off-by: Leo Yan Reviewed-on: http://android.intel.com:8080/28059 Reviewed-by: Liu, Hong Reviewed-by: Du, Alek Tested-by: Wang, Zhifeng Reviewed-by: buildbot Tested-by: buildbot --- drivers/hwmon/ltr502als.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hwmon/ltr502als.c b/drivers/hwmon/ltr502als.c index 321cf20..c240b80 100644 --- a/drivers/hwmon/ltr502als.c +++ b/drivers/hwmon/ltr502als.c @@ -601,6 +601,7 @@ static struct miscdevice ambient_dev = { #ifdef CONFIG_HAS_EARLYSUSPEND static void alsps_early_suspend(struct early_suspend *h) { + u8 data; struct alsps_device *alsps = container_of(h, struct alsps_device, es); dev_dbg(&alsps->client->dev, "enter %s\n", __func__); @@ -608,6 +609,14 @@ static void alsps_early_suspend(struct early_suspend *h) mutex_lock(&alsps_dev->lock); /* Only proximity is kept actice over the suspend period */ ltr502_switch(alsps->alsps_switch & PROXIMITY_ENABLE); + + /* If proximity status is changed during mode switch, there may be no + * interrupt occurred, so we need to check the data register after mode + * switching here */ + /* Sleep 1 intergration cycle(100 ms) to ensure ADC sample */ + msleep(100); + alsps_read(alsps, DATAREG, &data); + proximity_handle_irq(alsps, data); mutex_unlock(&alsps_dev->lock); } -- 2.7.4