summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattis fjallstrom <mattis@acm.org>2016-03-04 13:58:51 -0800
committermattis fjallstrom <mattis@acm.org>2016-03-04 13:58:51 -0800
commit8f1e890744ef7690c5f969fdd726144ec5ef955e (patch)
tree7dbc463a4a4038c7c4ff4028be24fd9266bce01d
parent0c87e3a91a4a642f41b0e68e9c7d4ebe03c99246 (diff)
downloadolio-linux-3.10-8f1e890744ef7690c5f969fdd726144ec5ef955e.tar.xz
olio-linux-3.10-8f1e890744ef7690c5f969fdd726144ec5ef955e.zip
Adding suspend and resume functions for ALS, to ensure that it's off when the rest of the watch is.
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);