summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattis fjallstrom <mattis@acm.org>2016-03-04 13:58:51 -0800
committerEvan Wilson <evan@oliodevices.com>2016-03-04 17:11:52 -0800
commit2b6af97a260ab5eb456086e614ad9973f25445ff (patch)
treebdb58873bc88a87acb2a86950764a6e378506626
parent8d5d990eac361cc02feac7f6e41650d992db5deb (diff)
downloadolio-linux-3.10-mindtribe-suspend-again.tar.xz
olio-linux-3.10-mindtribe-suspend-again.zip
Adding suspend and resume functions for ALS, to ensure that it's off when the rest of the watch is.mindtribe-suspend-again
Change-Id: I8da5b894ec45fbc95de5115833b2785812b7b580
-rw-r--r--drivers/iio/light/cm3391.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/iio/light/cm3391.c b/drivers/iio/light/cm3391.c
index 8049446d98a..b6461852a57 100644
--- a/drivers/iio/light/cm3391.c
+++ b/drivers/iio/light/cm3391.c
@@ -828,6 +828,28 @@ static int cm3391_remove(struct i2c_client *client)
return 0;
}
+static int old_config = CM3391_CMD_DEFAULT;
+
+static int cm3391_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ old_config = i2c_smbus_read_word_data(client,
+ CM3391_REG_ADDR_CMD);
+ /* Disable device */
+ i2c_smbus_write_word_data(client, CM3391_REG_ADDR_CMD,
+ CM3391_CMD_CS_DISABLE);
+
+ return 0;
+}
+
+static int cm3391_resume(struct i2c_client *client)
+{
+ /* enable device */
+ i2c_smbus_write_word_data(client, CM3391_REG_ADDR_CMD,
+ old_config);
+
+ return 0;
+}
+
static const struct i2c_device_id cm3391_id[] = {
{ "cm3391", 0},
{ }
@@ -861,6 +883,8 @@ static struct i2c_driver cm3391_driver = {
.id_table = cm3391_id,
.probe = cm3391_probe,
.remove = cm3391_remove,
+ .suspend = cm3391_suspend,
+ .resume = cm3391_resume,
};
module_i2c_driver(cm3391_driver);