summaryrefslogtreecommitdiff
path: root/drivers/misc/m4sensorhub_als.c
diff options
context:
space:
mode:
authorViditha Hanumanthareddy <ngjq36@motorola.com>2014-07-07 15:15:01 -0500
committerViditha H <ngjq36@motorola.com>2014-07-08 20:27:16 +0000
commit859956ec4ef635c2b7fd42b53ee880aa502aa724 (patch)
treebf84ed2e6d140a7bacc644c0c38bac8838ad6998 /drivers/misc/m4sensorhub_als.c
parent649585cbe0bc50b36291576e79e90ba3072aa88d (diff)
downloadolio-linux-3.10-859956ec4ef635c2b7fd42b53ee880aa502aa724.tar.xz
olio-linux-3.10-859956ec4ef635c2b7fd42b53ee880aa502aa724.zip
IKXCLOCK-2713: Retry setrate's
If i2c communication fails while doing a set sample rate for a sensor retry the same during suspend. It is seems that sometimes omap->M4 i2c bus dies for a brief period and then recovers. But during the failure period if an app tries to turn off a sensor and this turn off fails, it could lead to wakeups after omap suspend, and so this fix retries setting the sample rate on suspend only if it had failed earlier. Change-Id: I5874738a78ed900b1b039160f852031321dd2e30
Diffstat (limited to 'drivers/misc/m4sensorhub_als.c')
-rw-r--r--drivers/misc/m4sensorhub_als.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/misc/m4sensorhub_als.c b/drivers/misc/m4sensorhub_als.c
index d0d9ab7425a..02e7ec8b31b 100644
--- a/drivers/misc/m4sensorhub_als.c
+++ b/drivers/misc/m4sensorhub_als.c
@@ -43,7 +43,7 @@ struct m4als_driver_data {
uint16_t luminosity;
int16_t samplerate;
-
+ int16_t latest_samplerate;
uint16_t status;
};
@@ -95,6 +95,10 @@ static int m4als_set_samplerate(struct m4als_driver_data *dd, int16_t rate)
int err = 0;
int size = 0;
+ /* This variabled is to be always updated ireespective of the
+ transaction status */
+ dd->latest_samplerate = rate;
+
if (rate == dd->samplerate)
goto m4als_change_interrupt_bit;
@@ -351,6 +355,7 @@ static int m4als_probe(struct platform_device *pdev)
mutex_init(&(dd->mutex));
platform_set_drvdata(pdev, dd);
dd->samplerate = -1; /* We always start disabled */
+ dd->latest_samplerate = dd->samplerate;
dd->m4 = m4sensorhub_client_get_drvdata();
if (dd->m4 == NULL) {
@@ -396,6 +401,16 @@ static int __exit m4als_remove(struct platform_device *pdev)
return 0;
}
+static int m4als_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct m4als_driver_data *dd = platform_get_drvdata(pdev);
+ mutex_lock(&(dd->mutex));
+ if (m4als_set_samplerate(dd, dd->latest_samplerate) < 0)
+ m4als_err("%s: setrate retry failed\n", __func__);
+ mutex_unlock(&(dd->mutex));
+ return 0;
+}
+
static struct of_device_id m4als_match_tbl[] = {
{ .compatible = "mot,m4als" },
{},
@@ -405,8 +420,8 @@ static struct platform_driver m4als_driver = {
.probe = m4als_probe,
.remove = __exit_p(m4als_remove),
.shutdown = NULL,
- .suspend = NULL,
- .resume = NULL,
+ .suspend = m4als_suspend,
+ .resume = NULL,
.driver = {
.name = M4ALS_DRIVER_NAME,
.owner = THIS_MODULE,